Implemented register push and pop
This commit is contained in:
@ -48,11 +48,23 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
case DIV:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
code = x64.MoveRegReg64(code, x64.RAX, operands.Register)
|
||||
code = x64.MoveRegNum32(code, operands.Register, uint32(operands.Number))
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivReg(code, operands.Register)
|
||||
code = x64.MoveRegReg64(code, operands.Register, x64.RAX)
|
||||
if operands.Register == x64.RAX {
|
||||
code = x64.PushReg(code, x64.RCX)
|
||||
code = x64.MoveRegNum32(code, x64.RCX, uint32(operands.Number))
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivReg(code, x64.RCX)
|
||||
code = x64.PopReg(code, x64.RCX)
|
||||
} else {
|
||||
code = x64.PushReg(code, x64.RAX)
|
||||
code = x64.PushReg(code, x64.RDX)
|
||||
code = x64.MoveRegReg64(code, x64.RAX, operands.Register)
|
||||
code = x64.MoveRegNum32(code, operands.Register, uint32(operands.Number))
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivReg(code, operands.Register)
|
||||
code = x64.MoveRegReg64(code, operands.Register, x64.RAX)
|
||||
code = x64.PopReg(code, x64.RDX)
|
||||
code = x64.PopReg(code, x64.RAX)
|
||||
}
|
||||
}
|
||||
|
||||
case CALL:
|
||||
|
Reference in New Issue
Block a user