From 1ddd1288c5e9a75c5a7aae870889cf5c392fa555 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 2 Sep 2012 20:09:39 +0000 Subject: [PATCH] Some documentation fixes. Errors reported by Michael Bazzinotti . git-svn-id: svn://svn.cc65.org/cc65/trunk@5813 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/ca65.sgml | 52 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) 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,16 +4084,31 @@ 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: +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 possible solution is the command . +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 + 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 + inc addr bne Skip inc addr+1 Skip: @@ -4101,27 +4116,6 @@ macro: .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: . - .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 - .endmacro - - C style macros

@@ -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 -- 2.39.5