diff --git a/doc/ca65.sgml b/doc/ca65.sgml index b29912de2..4a14d0276 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -2892,7 +2892,7 @@ Here's a list of all control commands and a description, what they do: This command is often used to check if a macro parameter was given. Since an empty macro parameter will evaluate to nothing, the condition will evaluate - to FALSE if an empty parameter was given. + to TRUE if an empty parameter was given. Example: @@ -4084,41 +4084,35 @@ written more efficiently, like this: .endmacro -But imagine what happens, if you use this macro twice? Since the label -"Skip" has the same name both times, you get a "duplicate symbol" error. -Without a way to circumvent this problem, macros are not as useful, as -they could be. One solution is, to start a new lexical block inside the -macro: - - - .macro inc16 addr - .proc - inc addr - bne Skip - inc addr+1 - Skip: - .endproc - .endmacro - - -Now the label is local to the block and not visible outside. However, -sometimes you want a label inside the macro to be visible outside. To make -that possible, there's a new command that's only usable inside a macro -definition: . . +It declares one or more symbols as local to the macro expansion. The names of +local variables are replaced by a unique name in each separate macro +expansion. So we can solve the problem above by using .macro inc16 addr .local Skip ; Make Skip a local symbol - clc - lda addr - adc #$01 - sta addr - bcc Skip - inc addr+1 - Skip: ; Not visible outside + inc addr + bne Skip + inc addr+1 + Skip: ; Not visible outside + .endmacro + + +Another solution is of course to start a new lexical block inside the macro +that hides any labels: + + + .macro inc16 addr + .proc + inc addr + bne Skip + inc addr+1 + Skip: + .endproc .endmacro @@ -4199,7 +4193,7 @@ detect the end of one parameter, only the first token is used. If you don't like that, use classic macros instead: - .macro message + .macro DEBUG message .out message .endmacro