kenjennings Posted March 21, 2018 Share Posted March 21, 2018 (edited) I was trying to do something that my feeble memory thought worked 30 years ago in Mac/65 and not getting any joy in atasm. I'm making macros to act as wrappers to function calls in a library of routines. Then I'm conditionally assembling routines in the library, so if they are not referenced, they don't get included and waste space. I was figuring this would work.... (only important parts included) .macro mFunc ; other stuff happens jsr libFunc .endm ; Later in the main code.... mFunc ; Later.... .if .ref libFunc libFunc ; fun stuff ensues rts .endif This does not work. The .ref does not see the libFunc referenced, so it does not build libFunc. Should this work? Or am I insane? If the forward referenced label doesn't work, how about a declared value in the macro like this?... .macro mFunc DO_FUNC .= 1 ; other stuff happens jsr libFunc .endm ; Later in the main code.... mFunc ; Later.... .if .ref DO_FUNC ; and .def does not work either. libFunc ; fun stuff ensues rts .endif DO_FUNC set in the macro is also not seen. neither .ref or .def sees it. Next fallback plan... DO_FUNC .= 0 ; Later on.... .macro mFunc DO_FUNC .= 1 ; other stuff happens jsr libFunc .endm ; Later in the main code.... mFunc ; Later.... .if DO_FUNC>0 libFunc ; fun stuff ensues rts .endif This (annoyingly) does work. DO_FUNC defined outside the scope of a macro can have its value changed in a macro, and THAT value change is seen by the conditional assembly. Rather not have to throw in a bunch of flags in a header file separate from the library file which is included in the end of the assembly. Edited March 21, 2018 by kenjennings Quote Link to comment Share on other sites More sharing options...
+JAC! Posted March 21, 2018 Share Posted March 21, 2018 Hi Ken, I don't think you can get this to work with the way the parser in ATASM works. Leaving unreferenced code out is normally done by the linker, not by the parser. That is because you have to know when the last pass is over before you can decide what is really unused. My recommendation would be to switch to MADS and use .PROC./ENDP and the option "-x Exclude unreferenced procedures".Since MADS also also 99% MAC/65-alike only few minor things have to be adapted. Here's how: https://www.wudsn.com/index.php/ide/faq#FAQATASMtoMADSConversion Regards, Peter. 2 Quote Link to comment Share on other sites More sharing options...
kenjennings Posted March 21, 2018 Author Share Posted March 21, 2018 Actually I found that its not specific to macros. Any forward reference does not count as a reference for conditional assembly. MAIN jsr FUNC1 jmp MAIN .IF .REF FUNC1 FUNC1 ; something rts .ENDIF This fails to find FUNC1. Shouldn't it keep a placeholder for "memory address FUNC1 referenced" in pass 1, and then pass 2 fills in the address? It makes me wonder what .def and .ref can do. Quote Link to comment Share on other sites More sharing options...
kenjennings Posted March 22, 2018 Author Share Posted March 22, 2018 Mac/65 says I am not insane. The 30 years added to the brain cells have not yet turned them to mush. This is the simple program version... ASM shows the forward reference is recognized by the .REF during assembly... And, the macro version... And it works too. The forward ref from macro invocation is recognized by .REF... Just to be sure Mac/65's doesn't assume the macro declaration itself causes the .REF, this is assembly with MFUNC commented out in MAIN. It does not see the reference to FUNC and so does not assemble that code. 3 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.