Improved function names
This commit is contained in:
@ -30,57 +30,57 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
case ADD:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
code = x64.AddRegNum(code, operands.Register, operands.Number)
|
||||
code = x64.AddRegisterNumber(code, operands.Register, operands.Number)
|
||||
case *RegisterRegister:
|
||||
code = x64.AddRegReg(code, operands.Destination, operands.Source)
|
||||
code = x64.AddRegisterRegister(code, operands.Destination, operands.Source)
|
||||
}
|
||||
|
||||
case SUB:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
code = x64.SubRegNum(code, operands.Register, operands.Number)
|
||||
code = x64.SubRegisterNumber(code, operands.Register, operands.Number)
|
||||
case *RegisterRegister:
|
||||
code = x64.SubRegReg(code, operands.Destination, operands.Source)
|
||||
code = x64.SubRegisterRegister(code, operands.Destination, operands.Source)
|
||||
}
|
||||
|
||||
case MUL:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
code = x64.MulRegNum(code, operands.Register, operands.Number)
|
||||
code = x64.MulRegisterNumber(code, operands.Register, operands.Number)
|
||||
case *RegisterRegister:
|
||||
code = x64.MulRegReg(code, operands.Destination, operands.Source)
|
||||
code = x64.MulRegisterRegister(code, operands.Destination, operands.Source)
|
||||
}
|
||||
|
||||
case DIV:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
if operands.Register == x64.RAX {
|
||||
code = x64.PushReg(code, x64.RCX)
|
||||
code = x64.MoveRegNum32(code, x64.RCX, uint32(operands.Number))
|
||||
code = x64.PushRegister(code, x64.RCX)
|
||||
code = x64.MoveRegisterNumber32(code, x64.RCX, uint32(operands.Number))
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivReg(code, x64.RCX)
|
||||
code = x64.PopReg(code, x64.RCX)
|
||||
code = x64.DivRegister(code, x64.RCX)
|
||||
code = x64.PopRegister(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.PushRegister(code, x64.RAX)
|
||||
code = x64.PushRegister(code, x64.RDX)
|
||||
code = x64.MoveRegisterRegister64(code, x64.RAX, operands.Register)
|
||||
code = x64.MoveRegisterNumber32(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)
|
||||
code = x64.DivRegister(code, operands.Register)
|
||||
code = x64.MoveRegisterRegister64(code, operands.Register, x64.RAX)
|
||||
code = x64.PopRegister(code, x64.RDX)
|
||||
code = x64.PopRegister(code, x64.RAX)
|
||||
}
|
||||
|
||||
case *RegisterRegister:
|
||||
code = x64.PushReg(code, x64.RAX)
|
||||
code = x64.PushReg(code, x64.RDX)
|
||||
code = x64.MoveRegReg64(code, x64.RAX, operands.Destination)
|
||||
code = x64.PushRegister(code, x64.RAX)
|
||||
code = x64.PushRegister(code, x64.RDX)
|
||||
code = x64.MoveRegisterRegister64(code, x64.RAX, operands.Destination)
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivReg(code, operands.Source)
|
||||
code = x64.MoveRegReg64(code, operands.Destination, x64.RAX)
|
||||
code = x64.PopReg(code, x64.RDX)
|
||||
code = x64.PopReg(code, x64.RAX)
|
||||
code = x64.DivRegister(code, operands.Source)
|
||||
code = x64.MoveRegisterRegister64(code, operands.Destination, x64.RAX)
|
||||
code = x64.PopRegister(code, x64.RDX)
|
||||
code = x64.PopRegister(code, x64.RAX)
|
||||
}
|
||||
|
||||
case CALL:
|
||||
@ -121,10 +121,10 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
|
||||
case MOVE:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
code = x64.MoveRegNum32(code, operands.Register, uint32(operands.Number))
|
||||
code = x64.MoveRegisterNumber32(code, operands.Register, uint32(operands.Number))
|
||||
|
||||
case *RegisterRegister:
|
||||
code = x64.MoveRegReg64(code, operands.Destination, operands.Source)
|
||||
code = x64.MoveRegisterRegister64(code, operands.Destination, operands.Source)
|
||||
}
|
||||
|
||||
case RETURN:
|
||||
|
Reference in New Issue
Block a user