floobydust wrote:
... a disassembly of the ROMs are available which you will likely find useful and enlightening.
http://www.zimmers.net/anonftp/pub/cbm/ ... index.htmlThanks! It looks like the top of page 1 is used for storage, which might help explain why the stack is (sometimes) initialised to a different value:
Code:
LAB_01FC = $01FC ; chain link pointer high byte
LAB_01FD = $01FD ; chain link pointer low byte
LAB_01FE = $01FE ; line number low byte before crunched line
LAB_01FF = $01FF ; line number high byte before crunched line
Here are the three initialisations:
Code:
; flush BASIC stack and clear the continue pointer
LAB_C67A
LDX #LAB_19 ; get descriptor stack start
STX LAB_16 ; set descriptor stack pointer
PLA ; pull return address low byte
TAY ; copy it
PLA ; pull return address high byte
LDX #$FA ; set cleared stack pointer
TXS ; set stack
PHA ; push return address high byte
TYA ; restore return address low byte
PHA ; push return address low byte
LDA #$00 ; clear A
STA LAB_3E ; clear continue pointer high byte
STA LAB_10 ; clear subscript/FNX flag
LAB_C68D
RTS
Code:
; BASIC cold start entry point
LAB_E378
JSR LAB_E45B ; initialise BASIC vector table
JSR LAB_E3A4 ; initialise BASIC RAM locations
JSR LAB_E404 ; print start up message and initialise memory pointers
LDX #$FB ; value for start stack
TXS ; set stack pointer
JMP LAB_C474 ; do "READY." warm start
Code:
; RESET, hardware reset starts here
LAB_FD22
LDX #$FF ; set X for stack
SEI ; disable interrupts
TXS ; clear stack
CLD ; clear decimal mode
JSR LAB_FD3F ; scan for autostart ROM at $A000
BNE LAB_FD2F ; if not there continue Vic startup
JMP (LAB_A000) ; call ROM start code
LAB_FD2F
JSR LAB_FD8D ; initialise and test RAM
JSR LAB_FD52 ; restore default I/O vectors
JSR LAB_FDF9 ; initialize I/O registers
JSR LAB_E518 ; initialise hardware
CLI ; enable interrupts
JMP (LAB_C000) ; execute BASIC