intvnut Posted May 12, 2016 Share Posted May 12, 2016 I wonder if we should create IntyBASIC macros to encapsulate the segment switches? If we consider that there's, say, five segments, we could have a macro that says "SwitchRomSegment(x)" and automatically insert the "ASM ORG $xxxx" appropriate for the argument. It's not automatic, but at least it'll be easier to explain to programmers. Instead of Tarzilla's detailed but highly technical explanation above, you can say: I posted an example of this in another thread. I modified intybasic_prologue.asm and intybasic_epilogue.asm to use cart.mac. I also then modified 42k.bas to use ASM ROMSEG x, which does pretty much exactly what you propose: Switch to the current running position in a numbered ROM segment. Not fully automatic, but still a lot easier. In the intybasic_epilogue.asm, I also tagged each of the elements (procedures, tables, etc.) with ROMSEGSZ size, which is a macro that picks a ROM segment with at least size words available. That way, you don't need to end your program with a ROMSEG statement pointing to a segment big enough for a huge blob of stuff; rather, it'll semi-intelligently fill the remaining space. Not as smart as a proper linker, but smarter than what currently happens. The key is that the macros need to be assembler macros, not DEF FN macros. Without extending IntyBASIC, they still need to be ASM statements, then. Alternately, if IntyBASIC wants to make this more automated, it can batch up instructions and count the codesize itself, and then issue its own equivalent to ROMSEGSZ ahead of each of those segments. That's a bit more work on the IntyBASIC internals, but it would make things a bit more automated. It might make it slightly more difficult to squeeze every last drop out of a ROM, but it's a tradeoff. Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted May 12, 2016 Share Posted May 12, 2016 (edited) You wouldn't want CPU executable code to be emitted while you checked parameter x (from your example) to decide which asm org $xxxx directive to emit. You'd want that done by the equivalent of C/C++ preprocessor directives. Ah! DOH! I was thinking of multi-line macros like the ones for the Assembler pre-processor, complete with conditional directives. I forgot that IntyBASIC macros are more limited. dZ. Edited May 12, 2016 by DZ-Jay Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.