Implemented data labels
This commit is contained in:
parent
ff0b8ecb10
commit
1b75529bb3
18 changed files with 428 additions and 327 deletions
29
src/build/asm/RegisterLabel.go
Normal file
29
src/build/asm/RegisterLabel.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package asm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build/cpu"
|
||||
)
|
||||
|
||||
// RegisterLabel operates with a register and a label.
|
||||
type RegisterLabel struct {
|
||||
Register cpu.Register
|
||||
Label string
|
||||
}
|
||||
|
||||
// String returns a human readable version.
|
||||
func (data *RegisterLabel) String() string {
|
||||
return fmt.Sprintf("%s, %s", data.Register, data.Label)
|
||||
}
|
||||
|
||||
// RegisterLabel adds an instruction with a register and a label.
|
||||
func (a *Assembler) RegisterLabel(mnemonic Mnemonic, reg cpu.Register, label string) {
|
||||
a.Instructions = append(a.Instructions, Instruction{
|
||||
Mnemonic: mnemonic,
|
||||
Data: &RegisterLabel{
|
||||
Register: reg,
|
||||
Label: label,
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue