Jump to content
IGNORED

Transfer directly to Stack?


Recommended Posts

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

Link to comment
Share on other sites

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
   

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...