Implemented register to register instructions

This commit is contained in:
2024-06-23 20:26:53 +02:00
parent 31845dbc48
commit 4fc1935183
11 changed files with 171 additions and 16 deletions

View File

@ -28,8 +28,13 @@ func (a *Assembler) Finalize() ([]byte, []byte) {
for _, x := range a.Instructions {
switch x.Mnemonic {
case MOVE:
regNum := x.Data.(*RegisterNumber)
code = x64.MoveRegNum32(code, uint8(regNum.Register), uint32(regNum.Number))
switch operands := x.Data.(type) {
case *RegisterNumber:
code = x64.MoveRegNum32(code, operands.Register, uint32(operands.Number))
case *RegisterRegister:
code = x64.MoveRegReg64(code, operands.Destination, operands.Source)
}
case RETURN:
code = x64.Return(code)