neon/operator.go
2023-07-31 11:43:33 -03:00

118 lines
2.1 KiB
Go

package neon
//go:generate stringer -type Operator
type Operator byte
const (
NOP Operator = iota
LAI
LAM
LAB
LBI
LBM
LBA
SWP
STA
STB
ADI
ADM
ADB
ACI
ACM
ACB
INA
INB
SBI
SBM
SBB
SCI
SCM
SCB
DEA
DEB
TEI
TEM
TEB
TGI
TGM
TGB
TLI
TLM
TLB
TFC
TFI
JMP
JRF
JRB
JSR
RET
SET
SEC
SEI
SEJ
CLT
CLC
CLI
CLJ
INT
)
type operatorData struct {
step func(*CPU, uint16) Interrupt
mode func(*CPU) uint16
}
var operatorTable = [...]operatorData{
NOP: {stepNOP, modeImplicit},
LAI: {stepLA_, modeImmediate8},
LAM: {stepLA_, modeAbsolute},
LAB: {stepLAB, modeImplicit},
LBI: {stepLB_, modeImmediate8},
LBM: {stepLB_, modeAbsolute},
LBA: {stepLBA, modeImplicit},
SWP: {stepSWP, modeImplicit},
STA: {stepSTA, modeImmediate16},
STB: {stepSTB, modeImmediate16},
ADI: {stepAD_, modeImmediate8},
ADM: {stepAD_, modeAbsolute},
ADB: {stepADB, modeImplicit},
ACI: {stepAC_, modeImmediate8},
ACM: {stepAC_, modeAbsolute},
ACB: {stepACB, modeImplicit},
INA: {stepINA, modeImplicit},
INB: {stepINB, modeImplicit},
SBI: {stepSB_, modeImmediate8},
SBM: {stepSB_, modeAbsolute},
SBB: {stepSBB, modeImplicit},
SCI: {stepSC_, modeImmediate8},
SCM: {stepSC_, modeAbsolute},
SCB: {stepSCB, modeImplicit},
DEA: {stepDEA, modeImplicit},
DEB: {stepDEB, modeImplicit},
TEI: {stepTE_, modeImmediate8},
TEM: {stepTE_, modeAbsolute},
TEB: {stepTEB, modeImplicit},
TGI: {stepTG_, modeImmediate8},
TGM: {stepTG_, modeAbsolute},
TGB: {stepTGB, modeImplicit},
TLI: {stepTL_, modeImmediate8},
TLM: {stepTL_, modeAbsolute},
TLB: {stepTLB, modeImplicit},
TFC: {stepTFC, modeImplicit},
TFI: {stepTFI, modeImplicit},
JMP: {stepJMP, modeImmediate16},
JRF: {stepJRF, modeImmediate8},
JRB: {stepJRB, modeImmediate8},
JSR: {stepJSR, modeImmediate16},
RET: {stepRET, modeImplicit},
SET: {stepSET, modeImplicit},
SEC: {stepSEC, modeImplicit},
SEI: {stepSEI, modeImplicit},
SEJ: {stepSEJ, modeImplicit},
CLT: {stepCLT, modeImplicit},
CLC: {stepCLC, modeImplicit},
CLI: {stepCLI, modeImplicit},
CLJ: {stepCLJ, modeImplicit},
INT: {stepINT, modeImmediate8},
}