From 4d698bf18c89e8426e4ba8a37e4b72d1d51ee7ba Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 03:05:14 -0400 Subject: [PATCH] Don't use a,x,y in macro parameter example, document why not. #392 --- doc/ca65.sgml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/ca65.sgml b/doc/ca65.sgml index 360b0bab2..2f95a032e 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4262,8 +4262,13 @@ macro actually takes in the definition. You may also leave intermediate parameters empty. Empty parameters are replaced by empty space (that is, they are removed when the macro is expanded). If you have a look at our macro definition above, you will see, that replacing the "addr" parameter -by nothing will lead to wrong code in most lines. To help you, writing -macros with a variable parameter list, there are some control commands: +by nothing will lead to wrong code in most lines. + +The names "a", "x" and "y" should be avoided for macro parameters, as these +will usually conflict with the 6502 registers. + +For writing macros with a variable parameter list, control commands are +available: tests the rest of the line and returns true, if there are any tokens on the remainder of the line. Since @@ -4274,15 +4279,15 @@ opposite. Look at this example: -.macro ldaxy a, x, y -.ifnblank a - lda #a +.macro ldaxy i, j, k +.ifnblank i + lda #i .endif -.ifnblank x - ldx #x +.ifnblank j + ldx #j .endif -.ifnblank y - ldy #y +.ifnblank k + ldy #k .endif .endmacro