agon-mos icon indicating copy to clipboard operation
agon-mos copied to clipboard

Concerns about available stack space for MOS commands

Open breakintoprogram opened this issue 1 year ago • 2 comments

This issue was raised by Reinhard Schu on Facebook:

I have written a stacktest program that runs as a MOS command. Please see the output in the attached screenshot. My init.inc code automatically detects when its running as a MOS command and re-adjusts the SPS to $7FFE. Without this adjustment, if you study the output of my stacktest program, you will see that a MOS command that pushes more than 256 bytes onto the SPS with PUSH and POP instructions in Z80 (16-bit) mode will conflict with the SPL, as the top of both SPL and SPS will be at $08FFFF.

I have written my own init.inc code to correct this, but I would suggest it is best to fix the MOS to set the SPS to $7FFE when spawning a MOS ccommand, otherwise MOS commands could have unpredictable results due to SPS/SPL stack conflict.

Image

breakintoprogram avatar Dec 17 '22 15:12 breakintoprogram