q/src/asm/MemoryLabel.go

24 lines
566 B
Go

package asm
// MemoryLabel operates with a memory address and a number.
type MemoryLabel struct {
Label string
Address Memory
}
// String returns a human readable version.
func (data *MemoryLabel) String() string {
return data.Address.Format(data.Label)
}
// MemoryLabel adds an instruction with a memory address and a label.
func (a *Assembler) MemoryLabel(mnemonic Mnemonic, address Memory, label string) {
a.Instructions = append(a.Instructions, Instruction{
Mnemonic: mnemonic,
Data: &MemoryLabel{
Address: address,
Label: label,
},
})
}