Implemented bitwise operations

This commit is contained in:
2024-07-25 14:17:51 +02:00
parent b8900b518a
commit d1a8f0d66c
12 changed files with 287 additions and 5 deletions

View File

@ -26,6 +26,14 @@ func (a Assembler) Finalize() ([]byte, []byte) {
code = x64.AddRegisterRegister(code, operands.Destination, operands.Source)
}
case AND:
switch operands := x.Data.(type) {
case *RegisterNumber:
code = x64.AndRegisterNumber(code, operands.Register, operands.Number)
case *RegisterRegister:
code = x64.AndRegisterRegister(code, operands.Destination, operands.Source)
}
case SUB:
switch operands := x.Data.(type) {
case *RegisterNumber:
@ -153,6 +161,14 @@ func (a Assembler) Finalize() ([]byte, []byte) {
})
}
case OR:
switch operands := x.Data.(type) {
case *RegisterNumber:
code = x64.OrRegisterNumber(code, operands.Register, operands.Number)
case *RegisterRegister:
code = x64.OrRegisterRegister(code, operands.Destination, operands.Source)
}
case POP:
switch operands := x.Data.(type) {
case *Register:
@ -177,6 +193,14 @@ func (a Assembler) Finalize() ([]byte, []byte) {
case SYSCALL:
code = x64.Syscall(code)
case XOR:
switch operands := x.Data.(type) {
case *RegisterNumber:
code = x64.XorRegisterNumber(code, operands.Register, operands.Number)
case *RegisterRegister:
code = x64.XorRegisterRegister(code, operands.Destination, operands.Source)
}
default:
panic("unknown mnemonic: " + x.Mnemonic.String())
}