Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PUSH and POP from an INCLUDEd file doesn't work #27

Open
eevilactually opened this issue Jun 23, 2019 · 0 comments
Open

Using PUSH and POP from an INCLUDEd file doesn't work #27

eevilactually opened this issue Jun 23, 2019 · 0 comments

Comments

@eevilactually
Copy link

eevilactually commented Jun 23, 2019

I'm calling use_stack from top level file that includes multiple other files with subroutines. Those routines use stack operations like PUSH and POP to save registers. When I try to assemble I'm getting the error:

Stack is not initialized. Use use_stack() before any operation  stdin line 7
ERROR: m4 failure on file serial.psm

It seems to me like M4 pre-processor is ran on included files before the top file, so it doesn't recognize that I'm setting up the stack in in the top file. How can I reorganize my code so that I can use stack macros and still have it split up in multiple files? Is this an issue with macros or am I doing something wrong?

My code looks like this:

; program.psm:
namereg s3, SP      ; Protect s3 for use as the stack pointer
use_stack(SP, 0x3F) ; Start stack at end of 64-byte scratchpad

INCLUDE "subroutines.psm"
;subroutines.psm:
foo:
       PUSH(s7,s6)
       ...  
       POP(s7,s6)
       RETURN

EDIT:
I'm working around it by adding use_stack at the top of all included files, not sure if that's actually a good idea, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant