Implemented division

This commit is contained in:
2024-06-25 00:19:01 +02:00
parent 34af20d7a0
commit 2cbc064f14
7 changed files with 89 additions and 3 deletions

View File

@ -45,6 +45,16 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
code = x64.MulRegNum(code, operands.Register, operands.Number)
}
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)
}
case CALL:
code = x64.Call(code, 0x00_00_00_00)
size := 4