30 lines
647 B
Go
30 lines
647 B
Go
package asm
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.akyoto.dev/cli/q/src/cpu"
|
|
)
|
|
|
|
// RegisterNumber operates with a register and a number.
|
|
type RegisterNumber struct {
|
|
Register cpu.Register
|
|
Number int
|
|
}
|
|
|
|
// String returns a human readable version.
|
|
func (data *RegisterNumber) String() string {
|
|
return fmt.Sprintf("%s, %d", data.Register, data.Number)
|
|
}
|
|
|
|
// 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: mnemonic,
|
|
Data: &RegisterNumber{
|
|
Register: reg,
|
|
Number: number,
|
|
},
|
|
})
|
|
}
|