HC12: Macro parameters

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HC12: Macro parameters

Jump to solution
3,937 Views
Pitrunner
Contributor I
Hello,

may be someone can help me with flw.
I 've to assemble old HC11 code for a HC12 µctroller.
I'm using CW 4.5 B6037

The old macros looks like:
MENUE: MACRO &ID,&SK1TXT
FCB &ID ;MENUE ENTRY IDENTIFIER
FDB &SK1TXT ;SOFT KEY1 TEXT
MEND


I changed the syntax to

MENUE: MACRO
FCB \ID ;MENUE ENTRY IDENTIFIER
FDB \SK1TXT ;SOFT KEY1 TEXT
ENDM

and got an error message.

If I change it to

MENUE: MACRO
FCB \1 ;MENUE ENTRY IDENTIFIER
FDB \2 ;SOFT KEY1 TEXT
ENDM

all is fine.
But I don't want to use numbers, because I' ve also macros with more than 10 arguments and it will be more clear if I can use the given arguments. Further I found in the CW help this sentence: "A parameter designator consists of a backlashes character (\), followed by a digit (0 - 9) or an uppercase letter (A - Z). "
So why I can't use letters.
Is this due to that I only use a special edition of CW?
May be somebody has an answer.

Message Edited by CrasyCat on 2007-04-13 11:20 AM

Labels (1)
Tags (1)
0 Kudos
1 Solution
850 Views
rocco
Senior Contributor II
Hi, Pit:

Unfortunately, the syntax for macros in the Motorola assemblers have never been very symbolic in the eight-bit world. The rules for macros go something like this:

Symbolic names for macro parameters are not supported. The "MACRO" keyword cannot be followed by arguments.

In the macro body, the first parameter is specified as "\1", the second as "\2", etcetera. If more than 9 parameters are needed, then the tenth parameter is specified as "\A", the eleventh as "\B", etcetera. No more than 35 parameters are allowed.

Macro arguments must be separated by commas. A space will terminate the argument list. A null argument is specified by two commas in a row, with no space in between.

There is also a "\0" parameter, which is used to specify the character that might follow a "." (period) at the end the macro name in its invocation. As an example, if a macro named "Alban" was invoked as "Alban.b", parameter \0 would be equal to "b".

hope that helps.

View solution in original post

0 Kudos
5 Replies
850 Views
bigmac
Specialist III
Hello,
 
It may be that "gaps" in the sequence of macro argument identifiers are not allowed.
 
The easiest way to clarify the sequence that the arguments need to be entered might be as a comment, as follows -
 
MENUE: MACRO  ; ID, SK1TXT
       FCB \1 ; MENUE ENTRY IDENTIFIER
       FDB \2 ; SOFT KEY1 TEXT
       ENDM

Regards,
Mac

0 Kudos
850 Views
Pitrunner
Contributor I
Hello Mac,

thanks for your answer.
But the gaps are not the problem, because in my last post the representation of the Macro looks not so good.
I would like to have that:

MENUE: MACRO
FCB \ID ; MENUE ENTRY IDENTIFIER
FDB \SK1TEXT ; SOFT KEY1 TEXT
ENDM


And with that kind of macro I got an error.
If I use your representation of the macro all is fine.
Any idea?

Regards,
Pit
0 Kudos
850 Views
Pitrunner
Contributor I
Hello Mac again, I saw my result of the post and I'm confused about the representation. So I try again MENUE: MACRO FCB \ID FDB \SK1TXT ENDM
0 Kudos
851 Views
rocco
Senior Contributor II
Hi, Pit:

Unfortunately, the syntax for macros in the Motorola assemblers have never been very symbolic in the eight-bit world. The rules for macros go something like this:

Symbolic names for macro parameters are not supported. The "MACRO" keyword cannot be followed by arguments.

In the macro body, the first parameter is specified as "\1", the second as "\2", etcetera. If more than 9 parameters are needed, then the tenth parameter is specified as "\A", the eleventh as "\B", etcetera. No more than 35 parameters are allowed.

Macro arguments must be separated by commas. A space will terminate the argument list. A null argument is specified by two commas in a row, with no space in between.

There is also a "\0" parameter, which is used to specify the character that might follow a "." (period) at the end the macro name in its invocation. As an example, if a macro named "Alban" was invoked as "Alban.b", parameter \0 would be equal to "b".

hope that helps.
0 Kudos
850 Views
Pitrunner
Contributor I
Hi rocco,

thank you very much for your detailed explanation.
Now I understand more, about macros.

Thanks again. Pit
0 Kudos