Implemented simple expressions

This commit is contained in:
2024-06-25 20:50:06 +02:00
parent 2569c1bf63
commit e6462266ef
12 changed files with 232 additions and 52 deletions

View File

@ -13,6 +13,17 @@ func (a *Assembler) RegisterNumber(mnemonic Mnemonic, reg cpu.Register, number i
})
}
// RegisterRegister adds an instruction using two registers.
func (a *Assembler) RegisterRegister(mnemonic Mnemonic, left cpu.Register, right cpu.Register) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: mnemonic,
Data: &RegisterRegister{
Destination: left,
Source: right,
},
})
}
// MoveRegisterRegister moves a register value into another register.
func (a *Assembler) MoveRegisterRegister(destination cpu.Register, source cpu.Register) {
a.Instructions = append(a.Instructions, Instruction{