Improved division
This commit is contained in:
parent
745df4df2a
commit
f2858b1dc2
3 changed files with 36 additions and 60 deletions
|
@ -58,7 +58,34 @@ func (a Assembler) Finalize() ([]byte, []byte) {
|
|||
}
|
||||
|
||||
case DIV:
|
||||
code = divide(code, x.Data)
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterRegister:
|
||||
if operands.Destination != x64.RAX {
|
||||
code = x64.MoveRegisterRegister(code, x64.RAX, operands.Destination)
|
||||
}
|
||||
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivRegister(code, operands.Source)
|
||||
|
||||
if operands.Destination != x64.RAX {
|
||||
code = x64.MoveRegisterRegister(code, operands.Destination, x64.RAX)
|
||||
}
|
||||
}
|
||||
|
||||
case MODULO:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterRegister:
|
||||
if operands.Destination != x64.RAX {
|
||||
code = x64.MoveRegisterRegister(code, x64.RAX, operands.Destination)
|
||||
}
|
||||
|
||||
code = x64.ExtendRAXToRDX(code)
|
||||
code = x64.DivRegister(code, operands.Source)
|
||||
|
||||
if operands.Destination != x64.RDX {
|
||||
code = x64.MoveRegisterRegister(code, operands.Destination, x64.RDX)
|
||||
}
|
||||
}
|
||||
|
||||
case CALL:
|
||||
code = x64.Call(code, 0x00_00_00_00)
|
||||
|
@ -144,9 +171,6 @@ func (a Assembler) Finalize() ([]byte, []byte) {
|
|||
code = x64.LoadRegister(code, operands.Register, operands.Address.Offset, operands.Address.Length, operands.Address.Base)
|
||||
}
|
||||
|
||||
case MODULO:
|
||||
code = modulo(code, x.Data)
|
||||
|
||||
case MOVE:
|
||||
switch operands := x.Data.(type) {
|
||||
case *RegisterNumber:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue