Executing preprocessor in RAMSECTIONs? #634
-
So, I've made a file which kind of looks like this. .include "SYS.map"
.DEFINE STACK_SIZE 8
.DEFINE STACK_START $00FF-(STACK_SIZE*4) ; Adjusted to 4 for testing purposes, it's meant to be 2.
.MACRO STACK_GEN
.REPEAT STACK_SIZE
. dw
.ENDR
.ENDM
.PRINT "Reserved ", HEX (STACK_SIZE*2), " bytes for stack, stored @ ", HEX STACK_GEN, ". (", HEX STACK_SIZE, " values)\r\n"
.RAMSECTION "Stack" SLOT 1 FORCE ORGA STACK_START ; ORG throws a linker error about not having any space in bank 0, by the ways.
STACK_GEN ; This does not work.
.REPEAT STACK_SIZE ; This will also throw an assembling error.
. dw
.ENDR
.ENDS I believe the issue is that both of these treat the preprocessor instructions STACK_GEN and .REPEAT as names, which is a bit annoying. I'm hoping there's some way to prevent this behavior, such as a behavioral escape character which doesn't appear to have been mentioned in documentation. For expedient testing, my absolute behemoth of a SYS.map file is provided. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Just a quick note: .MACRO and .REPEAT are not processed by the preprocessor, they are traversed when parsing the code. Also: .RAMSECTIONs accept only variable labels and variable sizes (see .ENUM) so you cannot use .MACRO or .REPEAT inside them. I'm not 100% I understand what you want to achieve here, but couldn't you do something like .RAMSECTION "Stack" SLOT 1 FORCE ORGA STACK_START ? |
Beta Was this translation helpful? Give feedback.
-
Also not sure (cannot test code right now), but a workaround where you create .RAMSECTIONs (pieces of the big one you want to create) inside a .MACRO/.REPEAT and then use APPENDTO to join the pieces might also work? |
Beta Was this translation helpful? Give feedback.
Just a quick note: .MACRO and .REPEAT are not processed by the preprocessor, they are traversed when parsing the code. Also: .RAMSECTIONs accept only variable labels and variable sizes (see .ENUM) so you cannot use .MACRO or .REPEAT inside them.
I'm not 100% I understand what you want to achieve here, but couldn't you do something like
.RAMSECTION "Stack" SLOT 1 FORCE ORGA STACK_START
. dsw STACK_SIZE
.ENDS
?