internal/cpu: add cpu status register flags
This commit is contained in:
parent
f77b94f885
commit
11dc1bdad9
|
@ -5,4 +5,5 @@ Current references:
|
||||||
- [6502 memory test](http://www.willegal.net/appleii/6502mem.htm)
|
- [6502 memory test](http://www.willegal.net/appleii/6502mem.htm)
|
||||||
- [6502 instructions description with undocumented commands](http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/64doc)
|
- [6502 instructions description with undocumented commands](http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/64doc)
|
||||||
- [a rust implementation](https://github.com/alexander-akhmetov/mos6502)
|
- [a rust implementation](https://github.com/alexander-akhmetov/mos6502)
|
||||||
- [MOS hardware manual](http://bytecollector.com/archive/misc/6500-10A_MCS6500hwMan_Jan76.pdf)
|
- [MOS hardware manual](http://bytecollector.com/archive/misc/6500-10A_MCS6500hwMan_Jan76.pdf)
|
||||||
|
- [6502 registers](http://www.obelisk.me.uk/6502/registers.html)
|
|
@ -28,6 +28,8 @@
|
||||||
//
|
//
|
||||||
// Processor Stack:
|
// Processor Stack:
|
||||||
// LIFO, top down, 8 bit range, 0x0100 - 0x01FF
|
// LIFO, top down, 8 bit range, 0x0100 - 0x01FF
|
||||||
|
//
|
||||||
|
// 6502 instructions have the general form AAABBBCC, where AAA and CC define the opcode, and BBB defines the addressing mode
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
// addrMode is a type alias for a string, used below for defining addressing modes
|
// addrMode is a type alias for a string, used below for defining addressing modes
|
||||||
|
@ -50,15 +52,27 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Available cpu flags written as binary integer literals
|
// Available cpu flags written as binary integer literals
|
||||||
|
// https://wiki.nesdev.com/w/index.php/Status_flags
|
||||||
|
// 7 bit 0
|
||||||
|
// - - - - - - - -
|
||||||
|
// N V s s D I Z C
|
||||||
|
// | | | | | | | |
|
||||||
|
// | | | | | | | +- Carry
|
||||||
|
// | | | | | | +--- Zero
|
||||||
|
// | | | | | + ---- Interrupt Disable
|
||||||
|
// | | | | + ------ Decimal
|
||||||
|
// | | + +--------- No CPU effect, see: the B flag
|
||||||
|
// | + ------------ Overflow
|
||||||
|
// +--------------- Negative
|
||||||
const (
|
const (
|
||||||
flagDefault uint8 = 0B_00110000
|
flagDefault uint8 = 0B_00110000
|
||||||
flagNegative uint8 = 0B_10000000
|
flagNegative uint8 = 0B_10000000
|
||||||
flagOverflow uint8 = 0B_01000000
|
flagOverflow uint8 = 0B_01000000
|
||||||
flagB uint8 = 0B_00010000
|
flagBrk uint8 = 0B_00010000
|
||||||
flagDecimal uint8 = 0B_00001000
|
flagDecimalMode uint8 = 0B_00001000
|
||||||
flagInterrupt uint8 = 0B_00000100
|
flagDisableInterrupts uint8 = 0B_00000100
|
||||||
flagZero uint8 = 0B_00000010
|
flagZero uint8 = 0B_00000010
|
||||||
flagCarry uint8 = 0B_00000001
|
flagCarry uint8 = 0B_00000001
|
||||||
)
|
)
|
||||||
|
|
||||||
// StackBottom represents the bottom address
|
// StackBottom represents the bottom address
|
||||||
|
@ -69,9 +83,9 @@ type Mos6502 struct {
|
||||||
sp uint8 // stack pointer
|
sp uint8 // stack pointer
|
||||||
pc uint16 // program counter
|
pc uint16 // program counter
|
||||||
a uint8 // accumulator register
|
a uint8 // accumulator register
|
||||||
x uint8 // X index register
|
x uint8 // x index register
|
||||||
y uint8 // Y index register
|
y uint8 // y index register
|
||||||
p uint8 // processor flags
|
ps uint8 // processor status register
|
||||||
}
|
}
|
||||||
|
|
||||||
// New TODO: docs
|
// New TODO: docs
|
||||||
|
@ -82,6 +96,6 @@ func New() *Mos6502 {
|
||||||
a: 0,
|
a: 0,
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
p: flagDefault,
|
ps: flagDefault,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue