-
Notifications
You must be signed in to change notification settings - Fork 39
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
Macro parameters ignore conditionals #34
Comments
I have found that my understanding of macros in DASM seems closest to reality when I think of macros as purely a text-substitution engine. It does not know of or understand the values of things. This is why it seems impossible to use values of variables inside macros, in any form. You get the text label of things, and only that. In other words, the macro first plonks down the text according to various substitution rules ({1} etc) and only after the macro is completed, then the resultant code is assembled. That is my current understanding of how to work with macros, anyway. |
On Mon 09 Mar 2020 at 00:55:34 -0700, andrew-davie wrote:
I have found that my understanding of macros in DASM seems closest to
reality when I think of macros as **purely** a text-substitution
engine. It does not know of or understand the **values** of things.
I think that is pretty much true for all macro assemblers I have ever
used. Sometime, you can do a bit of "extra" stuff, such as getting at
the number of parameters that were passed, or iterating over all
parameters in turn, or testing if a parameter is the empty string or
equal to some string or another... but that never abandons the
principle that everything is just text substitution.
Take this macro from a program in MACRO-11 (the main assembler for the
PDP-11):
.macro save things
.irp x,<things>
.if b x ; if blank, just decrease stack pointer,
; don't really store anything
tst -(p)
.iff ; "if false", meaning "else"
.if idn x,#0 ; if #0, use the clr instruction
; instead of really moving anything
clr -(sp)
.iff
mov x,-(sp)
.endc
.endc
.endr
.endm
where .irp is a repeating loop, setting 'x' in turn to the values in
<things>, which is a parameter to the macro. You use it for instance
like
save <r0,,#0,#2>
which would generate code like
mov r0,-(sp)
tst -(sp)
clr -(sp)
mov #2,-(sp)
which in turn saves the values in register 0, and the immediate values
#1 and #2.
MACRO11 even has a directive .NTYPE, which you give some string and it
parses it as an operand, and sets a variable to the addressing mode it
found. So you can use .if conditions in your macro; the macro is still
just string manipulation, but the .NTYPE directive gives you just that
extra bit of power to optimize your macro for various types of
arguments.
…-Olaf.
--
Olaf 'Rhialto' Seibert -- rhialto at falu dot nl
___ Anyone who is capable of getting themselves made President should on
\X/ no account be allowed to do the job. --Douglas Adams, "THGTTG"
|
The following code does not assemble:
It seems like the
CHECK
condition is not evaluated before checking the number of parameters required by the macro.The text was updated successfully, but these errors were encountered: