Implemented subtraction

This commit is contained in:
2024-06-24 16:55:15 +02:00
parent 597cb9abed
commit b018d8de61
9 changed files with 92 additions and 28 deletions

View File

@ -3,7 +3,7 @@ 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 uint64) {
func (a *Assembler) AddRegisterNumber(reg cpu.Register, number int) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: ADD,
Data: &RegisterNumber{
@ -13,8 +13,19 @@ func (a *Assembler) AddRegisterNumber(reg cpu.Register, number uint64) {
})
}
// 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 uint64) {
func (a *Assembler) MoveRegisterNumber(reg cpu.Register, number int) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: MOVE,
Data: &RegisterNumber{