P&E assembler to Codewarrior

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

P&E assembler to Codewarrior

3,400 次查看
donw
Contributor IV
This is my first attempt to convert a P&E assembler code (S08) into
CodeWarrior . (using  _asm  in C code assembly)
Some strange things someone may be able to help with:
- Maths operators and quotes on a comment line (ie after a :smileywink: cause errors. I would have thought the line was ignored!    (putting ; //  solves the problem !)
 How do I express a binary format number?     LDA  #%01101101   causes an 'octal number' error.
- How doI express a decimal number such as LDA #01    (again an octal error if there is a leading zero. I would like to show a leading zero somehow)

标签 (1)
0 项奖励
回复
5 回复数

1,351 次查看
CompilerGuru
NXP Employee
NXP Employee
>- Maths operators and quotes on a comment line (ie after a cause errors.
>I would have thought the line was ignored!    (putting ; //  solves the problem !)

There are two forms for HLI, in the __asm nop; the semicolon is just the usual C statement terminator.
Therefore everything following it has to be legal C too.
The other form is
__asm {
  nop; comment
}
Here the assembly line is line terminated. However it is not possible to use this form in macros expand
to a single line only. Anyway, I would suggest to stick with the ";// comments". It also helps the syntax coloring.

> How do I express a binary format number?     LDA  #%01101101   causes an 'octal number' error.
There is no support for binary numbers in C. However the Metrowerks compiler supports binary numbers with a
0b0101010 syntax. In HLI code, I feel free to use that, as HLI is compiler specific anyway.
In plain C code I usually use decimal/hex only in order to just use ANSI C.

> - How do I express a decimal number such as LDA #01    (again an octal error if there is a leading zero.
> I would like to show a leading zero somehow)
Sorry, in ANSI C if it starts with a zero, it is octal. So you have to drop the 0 there. I think the compiler warns about octal numbers so at least you should not miss those.


Daiel
0 项奖励
回复

1,351 次查看
donw
Contributor IV
Thanks for the info.
Still stuck on some things:
I am using the assembly format:
_ asm {
blaa
blaa
}

- Why does the assembler NOT ignore math symbols in a comment line?  (ie    ; hello * 12   causes error)
- Label EQU causes error  'invalid opcode or : expected'
DATAREVH      EQU    1     ; DATA FORMAT
 I have tried with a colon after the label, then a  'end of line expected' error.

- The help states that there is an option to ignore label colons in the assembler. But I cant find it. CW v5.0.9 build 2404

0 项奖励
回复

1,351 次查看
CompilerGuru
NXP Employee
NXP Employee
Note that the compiler (and therefore the HLI embedded in the compiler)
does not support the EQU directive (or most of the other assembly directives).
So in order to define constants, you have to use the C-ways to do that. So
either use defines, or enums. Those things are then available in HLI code.
If you want to use EQU, then you have to use the assembler, and not the HLI (the inline assembler embedded in the compiler).

Not sure why you get errors for a multiplication operator in an assembly comment.
Works for me:
Code:
void test(void) {  __asm {    nop ; hello * 12    ; hello * 12    ;@&*$(*&@  }  }

But as I said, I would use C comments in C/HLI code anyway.

Daniel
 

0 项奖励
回复

1,351 次查看
CompilerGuru
NXP Employee
NXP Employee
and about
> - The help states that there is an option to ignore label colons in the assembler.

I think there is an option in the assembler not to require colons, not sure, not using that.
But I doubt that there is a corresponding option in the compiler. Not that the assembler and the compiler
and separate animals. The compiler does not use the assembler to generate an object file.

Daniel
0 项奖励
回复

1,351 次查看
donw
Contributor IV
OK it all becomes clear now !
I assumed the asm complier used the assembler to do the asm coding.
Thanks

0 项奖励
回复