mirror of
https://github.com/bradford-hamilton/apple-1.git
synced 2024-10-31 22:05:59 +00:00
internal/vm/{exec_funcs,opcodes}: handle INX instruction execution
This commit is contained in:
parent
71a1fa30ec
commit
35bdeac2c8
@ -9,7 +9,7 @@ func todo(a *Appleone, o op) error {
|
||||
|
||||
// interrupt, N Z C I D V
|
||||
// push PC+2, push SR - - - 1 - -
|
||||
func exec0x00(a *Appleone, o op) error {
|
||||
func execBRK(a *Appleone, o op) error {
|
||||
// set processer status flag to BRK
|
||||
a.cpu.ps = flagBreak
|
||||
|
||||
@ -24,7 +24,7 @@ func exec0x00(a *Appleone, o op) error {
|
||||
|
||||
// pull SR, pull PC N Z C I D V
|
||||
// from stack
|
||||
func exec0x40(a *Appleone, o op) error {
|
||||
func execRTI(a *Appleone, o op) error {
|
||||
a.cpu.ps = a.popStackWord()
|
||||
a.cpu.pc = a.popStackDWord()
|
||||
return nil
|
||||
@ -32,18 +32,40 @@ func exec0x40(a *Appleone, o op) error {
|
||||
|
||||
// M - 1 -> M N Z C I D V
|
||||
// + + - - - -
|
||||
func exec0xC6(a *Appleone, o op) error {
|
||||
func execDEC(a *Appleone, o op) error {
|
||||
addr, err := o.getAddr(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
b := a.mem[addr]
|
||||
b--
|
||||
a.mem[addr] = b
|
||||
|
||||
a.setZeroIfNeeded(b)
|
||||
a.setNegativeIfOverflow(b)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// M + 1 -> M N Z C I D V
|
||||
// + + - - - -
|
||||
func execINC(a *Appleone, o op) error {
|
||||
addr, err := o.getAddr(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b := a.mem[addr]
|
||||
b++
|
||||
a.mem[addr] = b
|
||||
a.setZeroIfNeeded(b)
|
||||
a.setNegativeIfOverflow(b)
|
||||
return nil
|
||||
}
|
||||
|
||||
// X + 1 -> X N Z C I D V
|
||||
// + + - - - -
|
||||
func execINX(a *Appleone, o op) error {
|
||||
b := a.cpu.x + 1
|
||||
a.cpu.x = b
|
||||
a.setZeroIfNeeded(b)
|
||||
a.setNegativeIfOverflow(b)
|
||||
return nil
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ var opcodes = map[uint8]op{
|
||||
// addressing assembler opc bytes cyles
|
||||
// --------------------------------------------
|
||||
// implied BRK 00 1 7
|
||||
0x00: newOp("BRK", 0x00, 1, implied, exec0x00),
|
||||
0x00: newOp("BRK", 0x00, 1, implied, execBRK),
|
||||
|
||||
// RTI Return from Interrupt
|
||||
// addressing assembler opc bytes cyles
|
||||
// --------------------------------------------
|
||||
// implied RTI 40 1 6
|
||||
0x40: newOp("RTI", 0x40, 1, implied, exec0x40),
|
||||
0x40: newOp("RTI", 0x40, 1, implied, execRTI),
|
||||
|
||||
// DEC Decrement Memory by One
|
||||
// addressing assembler opc bytes cyles
|
||||
@ -92,10 +92,10 @@ var opcodes = map[uint8]op{
|
||||
// zeropage,X DEC oper,X D6 2 6
|
||||
// absolute DEC oper CE 3 6
|
||||
// absolute,X DEC oper,X DE 3 7
|
||||
0xC6: newOp("DEC", 0xC6, 2, zeroPage, exec0xC6),
|
||||
0xD6: newOp("DEC", 0xD6, 2, zeroPageXIndexed, exec0xC6),
|
||||
0xCE: newOp("DEC", 0xCE, 3, absolute, exec0xC6),
|
||||
0xDE: newOp("DEC", 0xDE, 3, absoluteXIndexed, exec0xC6),
|
||||
0xC6: newOp("DEC", 0xC6, 2, zeroPage, execDEC),
|
||||
0xD6: newOp("DEC", 0xD6, 2, zeroPageXIndexed, execDEC),
|
||||
0xCE: newOp("DEC", 0xCE, 3, absolute, execDEC),
|
||||
0xDE: newOp("DEC", 0xDE, 3, absoluteXIndexed, execDEC),
|
||||
|
||||
// INC Increment Memory by One
|
||||
// addressing assembler opc bytes cyles
|
||||
@ -104,10 +104,10 @@ var opcodes = map[uint8]op{
|
||||
// zeropage,X INC oper,X F6 2 6
|
||||
// absolute INC oper EE 3 6
|
||||
// absolute,X INC oper,X FE 3 7
|
||||
0xE6: newOp("INC", 0xE6, 2, zeroPage, todo),
|
||||
0xF6: newOp("INC", 0xF6, 2, zeroPageXIndexed, todo),
|
||||
0xEE: newOp("INC", 0xEE, 3, absolute, todo),
|
||||
0xFE: newOp("INC", 0xFE, 3, absoluteXIndexed, todo),
|
||||
0xE6: newOp("INC", 0xE6, 2, zeroPage, execINC),
|
||||
0xF6: newOp("INC", 0xF6, 2, zeroPageXIndexed, execINC),
|
||||
0xEE: newOp("INC", 0xEE, 3, absolute, execINC),
|
||||
0xFE: newOp("INC", 0xFE, 3, absoluteXIndexed, execINC),
|
||||
|
||||
// INX Increment Index X by One
|
||||
// addressing assembler opc bytes cyles
|
||||
|
Loading…
Reference in New Issue
Block a user