HC12: Macro parameters

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

HC12: Macro parameters

跳至解决方案
5,190 次查看
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

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
2,103 次查看
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 项奖励
回复
5 回复数
2,103 次查看
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 项奖励
回复
2,103 次查看
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 项奖励
回复
2,103 次查看
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 项奖励
回复
2,104 次查看
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 项奖励
回复
2,103 次查看
Pitrunner
Contributor I
Hi rocco,

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

Thanks again. Pit
0 项奖励
回复