package asm import "git.akyoto.dev/cli/q/src/build/cpu" // 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, }, }) } // MoveRegisterRegister moves a register value into another register. func (a *Assembler) MoveRegisterRegister(destination cpu.Register, source cpu.Register) { a.Instructions = append(a.Instructions, Instruction{ Mnemonic: MOVE, Data: &RegisterRegister{ Destination: destination, Source: source, }, }) } // Label adds a label at the current position. func (a *Assembler) Label(name string) { a.Instructions = append(a.Instructions, Instruction{ Mnemonic: LABEL, Data: &Label{ Name: name, }, }) } // Call calls a function whose position is identified by a label. func (a *Assembler) Call(name string) { a.Instructions = append(a.Instructions, Instruction{ Mnemonic: CALL, Data: &Label{ Name: name, }, }) } // Jump jumps to a position that is identified by a label. func (a *Assembler) Jump(name string) { a.Instructions = append(a.Instructions, Instruction{ Mnemonic: JUMP, Data: &Label{ Name: name, }, }) } // Return returns back to the caller. func (a *Assembler) Return() { a.Instructions = append(a.Instructions, Instruction{Mnemonic: RETURN}) } // Syscall executes a kernel function. func (a *Assembler) Syscall() { a.Instructions = append(a.Instructions, Instruction{Mnemonic: SYSCALL}) }