central-arch/cmd/asmtest/asmtest.go

28 lines
657 B
Go
Raw Normal View History

2024-11-01 10:54:59 +00:00
package main
import (
"fmt"
"git.elyanpoujol.fr/elyan/central-arch/pkg/cpu"
"git.elyanpoujol.fr/elyan/central-arch/pkg/instr"
"git.elyanpoujol.fr/elyan/central-arch/pkg/simcontext"
)
const (
MOV_r1_r2 instr.Instr = 0xffff_ff2a
SVC_ffffff instr.Instr = 0xffff_ffff
)
func main() {
cpu := cpu.New(simcontext.SimContext{}, nil)
cpu.RegisterInstr(instr.InstrDesc{
Mnemonic: "LDR",
VariantName: "LDRIR",
OpCode: 0x01,
Format: instr.A,
Formatter: func(i *instr.DecodedInstr) string { return "Hello" }})
fmt.Printf("MOV[6:0] = %#0x\n", cpu.GetOpCode(MOV_r1_r2))
fmt.Printf("SVC[6:0] = %#0x\n", cpu.GetOpCode(SVC_ffffff))
}