Implemented multiplication

This commit is contained in:
2024-06-24 22:43:01 +02:00
parent 625e8d5e2e
commit 34af20d7a0
11 changed files with 107 additions and 47 deletions

View File

@ -2,32 +2,10 @@ package asm
import "git.akyoto.dev/cli/q/src/build/cpu"
// AddRegisterNumber adds a number to the given register.
func (a *Assembler) AddRegisterNumber(reg cpu.Register, number int) {
// RegisterNumber adds an instruction with a register and a number.
func (a *Assembler) RegisterNumber(mnemonic Mnemonic, reg cpu.Register, number int) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: ADD,
Data: &RegisterNumber{
Register: reg,
Number: number,
},
})
}
// SubRegisterNumber subtracts a number from the given register.
func (a *Assembler) SubRegisterNumber(reg cpu.Register, number int) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: SUB,
Data: &RegisterNumber{
Register: reg,
Number: number,
},
})
}
// MoveRegisterNumber moves a number into the given register.
func (a *Assembler) MoveRegisterNumber(reg cpu.Register, number int) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: MOVE,
Mnemonic: mnemonic,
Data: &RegisterNumber{
Register: reg,
Number: number,