mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-01-02 20:29:44 +00:00
Added SEx and CLx
This commit is contained in:
parent
964f5bc3be
commit
858d6acac5
59
execute.go
59
execute.go
@ -150,6 +150,56 @@ func buildOpLoad(addressMode int, regDst int) opFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func buildOpUpdateFlag(flag uint8, value bool) opFunc {
|
||||
return func(s *state, line []uint8, opcode opcode) {
|
||||
s.registers.updateFlag(flag, value)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TODO:
|
||||
|
||||
ADC
|
||||
SBC
|
||||
|
||||
AND
|
||||
ORA
|
||||
|
||||
ASL
|
||||
EOR
|
||||
LSR
|
||||
|
||||
BIT
|
||||
CMP
|
||||
CPX
|
||||
CPY
|
||||
|
||||
BRK
|
||||
|
||||
BCC
|
||||
BCS
|
||||
BEQ
|
||||
BMI
|
||||
BPL
|
||||
BVC
|
||||
BVS
|
||||
|
||||
JMP
|
||||
JSR
|
||||
RTI
|
||||
RTS
|
||||
|
||||
PHA
|
||||
PHP
|
||||
PLA
|
||||
PLP
|
||||
|
||||
STA
|
||||
STX
|
||||
STY
|
||||
|
||||
*/
|
||||
|
||||
var opcodes = [256]opcode{
|
||||
0x2A: opcode{"ROL", 1, 2, buildRotate(modeAccumulator, true)},
|
||||
0x26: opcode{"ROL", 2, 5, buildRotate(modeZeroPage, true)},
|
||||
@ -163,6 +213,15 @@ var opcodes = [256]opcode{
|
||||
0x6E: opcode{"ROR", 3, 6, buildRotate(modeAbsolute, false)},
|
||||
0x7E: opcode{"ROR", 3, 7, buildRotate(modeAbsoluteX, false)},
|
||||
|
||||
0x38: opcode{"SEC", 1, 2, buildOpUpdateFlag(flagC, true)},
|
||||
0xF8: opcode{"SED", 1, 2, buildOpUpdateFlag(flagD, true)},
|
||||
0x78: opcode{"SEI", 1, 2, buildOpUpdateFlag(flagI, true)},
|
||||
|
||||
0x18: opcode{"CLC", 1, 2, buildOpUpdateFlag(flagC, false)},
|
||||
0xD8: opcode{"CLD", 1, 2, buildOpUpdateFlag(flagD, false)},
|
||||
0x58: opcode{"CLI", 1, 2, buildOpUpdateFlag(flagI, false)},
|
||||
0xB8: opcode{"CLV", 1, 2, buildOpUpdateFlag(flagV, false)},
|
||||
|
||||
0xE6: opcode{"INC", 2, 5, buildOpIncDec(modeZeroPage, true)},
|
||||
0xF6: opcode{"INC", 2, 6, buildOpIncDec(modeZeroPageX, true)},
|
||||
0xEE: opcode{"INC", 3, 6, buildOpIncDec(modeAbsolute, true)},
|
||||
|
@ -168,5 +168,20 @@ func TestRotate(t *testing.T) {
|
||||
if !s.registers.getFlag(flagC) {
|
||||
t.Errorf("Error in ROR carry")
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearSetFlag(t *testing.T) {
|
||||
var s state
|
||||
s.registers.setP(0x00)
|
||||
|
||||
executeLine(&s, []uint8{0xF8})
|
||||
if !s.registers.getFlag(flagD) {
|
||||
t.Errorf("Error in SED. %v", s.registers)
|
||||
}
|
||||
|
||||
executeLine(&s, []uint8{0xD8})
|
||||
if s.registers.getFlag(flagD) {
|
||||
t.Errorf("Error in CLD. %v", s.registers)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user