dot command stack [til/spectrum]

When writing dot commands for the Spectrum Next the bytes are loaded into memory position $2000. Normally “free” memory is $8000 onwards to $FFFF (or so I understood), but the stack is sitting at $FF41 (or so) so paging in a bank to the last MMU position will nuke the stack.
Straightforward work around for this is to swap in your own stack:
;; as early as possible
ld (oldStack), sp
ld sp, stackTop
jr Start ; jump to the start of the program

oldStack DW 0
stack DS $80, $AA ; $AA is just debug filler of stack area
stackTop DW $AAAA

cleanUp:
;; then on exit restore the oldStack to SP
ld sp, (oldStack)
ei
ret

This way I can now safely use the page of memory at $E000.


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log

When writing dot commands for the Spectrum Next the bytes are loaded into memory position $2000. Normally "free" memory is $8000 onwards to $FFFF (or so I understood), but the stack is sitting at $FF41 (or so) so paging in a bank to the last MMU position will nuke the stack.

Straightforward work around for this is to swap in your own stack:

          ;; as early as possible
          ld (oldStack), sp
          ld sp, stackTop
          jr Start                ; jump to the start of the program

oldStack  DW 0
stack     DS $80, $AA ; $AA is just debug filler of stack area
stackTop  DW $AAAA

cleanUp:
          ;; then on exit restore the oldStack to SP
          ld sp, (oldStack)
          ei
          ret

This way I can now safely use the page of memory at $E000.

Originally published on Remy Sharp's b:log


This content originally appeared on remy sharp's b:log and was authored by remy sharp's b:log


Print Share Comment Cite Upload Translate Updates
APA

remy sharp's b:log | Sciencx (2021-02-21T17:01:27+00:00) dot command stack [til/spectrum]. Retrieved from https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/

MLA
" » dot command stack [til/spectrum]." remy sharp's b:log | Sciencx - Sunday February 21, 2021, https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/
HARVARD
remy sharp's b:log | Sciencx Sunday February 21, 2021 » dot command stack [til/spectrum]., viewed ,<https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/>
VANCOUVER
remy sharp's b:log | Sciencx - » dot command stack [til/spectrum]. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/
CHICAGO
" » dot command stack [til/spectrum]." remy sharp's b:log | Sciencx - Accessed . https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/
IEEE
" » dot command stack [til/spectrum]." remy sharp's b:log | Sciencx [Online]. Available: https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/. [Accessed: ]
rf:citation
» dot command stack [til/spectrum] | remy sharp's b:log | Sciencx | https://www.scien.cx/2021/02/21/dot-command-stack-til-spectrum/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.