docs: update some funcs with light docs
This commit is contained in:
parent
cdca8f735d
commit
2bd748fccd
|
@ -68,7 +68,7 @@ const (
|
|||
flagCarry uint8 = 0B_00000001
|
||||
)
|
||||
|
||||
// StackBottom represents the bottom address
|
||||
// StackBottom represents the start of the stack
|
||||
const StackBottom uint16 = 0x0100 // 256
|
||||
|
||||
// Mos6502 TODO: docs
|
||||
|
@ -81,7 +81,7 @@ type Mos6502 struct {
|
|||
ps uint8 // register - processor status
|
||||
}
|
||||
|
||||
// newCPU TODO: docs
|
||||
// newCPU initializes and returns a new Mos6502 CPU
|
||||
func newCPU() *Mos6502 {
|
||||
return &Mos6502{
|
||||
sp: 0xFF,
|
||||
|
|
|
@ -36,11 +36,13 @@ func (a *Appleone) step() {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *Appleone) pushWordToStack(data byte) {
|
||||
a.mem[StackBottom+uint16(a.cpu.sp)] = data
|
||||
// pushWordToStack pushes the given word (byte) into memory and sets the new stack pointer
|
||||
func (a *Appleone) pushWordToStack(b byte) {
|
||||
a.mem[StackBottom+uint16(a.cpu.sp)] = b
|
||||
a.cpu.sp = uint8((uint16(a.cpu.sp) - 1) & 0xFF)
|
||||
}
|
||||
|
||||
// pushWordToStack splits the high and low byte of the data passed in, and pushes them to the stack
|
||||
func (a *Appleone) pushDWordToStack(data uint16) {
|
||||
h := uint8((data >> 8) & 0xFF)
|
||||
l := uint8(data & 0xFF)
|
||||
|
@ -48,11 +50,13 @@ func (a *Appleone) pushDWordToStack(data uint16) {
|
|||
a.pushWordToStack(l)
|
||||
}
|
||||
|
||||
// popStackWord sets the new stack pointer and returns the appropriate byte in memory
|
||||
func (a *Appleone) popStackWord() uint8 {
|
||||
a.cpu.sp = uint8((uint16(a.cpu.sp) + 1) & 0xFF)
|
||||
return a.mem[StackBottom+uint16(a.cpu.sp)]
|
||||
}
|
||||
|
||||
// popStackDWord pops two stack words (a double word - uint16) off the stack
|
||||
func (a *Appleone) popStackDWord() uint16 {
|
||||
l := a.popStackWord()
|
||||
h := a.popStackWord()
|
||||
|
|
Loading…
Reference in New Issue