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"
I'm calling
use_stack
from top level file that includes multiple other files with subroutines. Those routines use stack operations likePUSH
andPOP
to save registers. When I try to assemble I'm getting the error: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:
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.