JohnnyRockets Posted January 19, 2021 Share Posted January 19, 2021 Hi all, In the following "newbie" code snippet: -------------- processor 6502 seg code org $F000 ; defines the code origin at $F000 Start: sei ; disables the interrupts cld ; disable the BCD decimal map mode ldx #$FF ; loads the X register with #$FF txs ; transfers X register to S(tack) register -------------------- Could we have just loaded #$FF directly into the Stack register, thus saving a step/instruction? Thank you, JR Quote Link to comment Share on other sites More sharing options...
+Stephen Posted January 19, 2021 Share Posted January 19, 2021 No - there's no direct loading from or saving to the stack on the 6502(7). We can only push, or pull Accumulator values, or use the above transfer from another internal register. Quote Link to comment Share on other sites More sharing options...
JohnnyRockets Posted January 19, 2021 Author Share Posted January 19, 2021 Thanks Stephen! Now looking at this snippet: --------------------------- processor 6502 seg code org $F000 ; defines the code origin at $F000 Start: sei ; disables the interrupts cld ; disable the BCD decimal map mode ldx #$FF ; loads the X register with #$FF txs ; transfers X register to S(tack) register ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Clear the Zero Page region ($00 to $FF) ; Meaning the entire TIA register space and also RAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; lda #0 ; A = 0 ldx #$FF ; X = #$FF sta $FF ; make sure $FF is zeroed before the loop starts MemLoop: dex ; x-- sta $0,X ; store zero in A, at address $0 + X bne MemLoop ; loop until X==0 (z-flag set) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Fill ROM size to exactly 4KB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $FFFC .word Start ; reset vector at $FFFC (where program starts) .word Start ; interrupt vector at $FFFE (unused in VCS) --------------------------- Question: What values are now stored in $FFFC and $FFFE? And why? My guess is Zeros? Thanks! JR Quote Link to comment Share on other sites More sharing options...
+Andrew Davie Posted January 19, 2021 Share Posted January 19, 2021 They both contain a 16-bit pointer to the label "Start", which is $F000 The stack lives at $FF downwards (on the '2600). Technically $1FF downwards on the 6502. The code you post is inefficient -- use the CLEAN_START macro! Quote Link to comment Share on other sites More sharing options...
JohnnyRockets Posted January 19, 2021 Author Share Posted January 19, 2021 Thank you Andrew, I will study this macro! JR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.