Renesas Technology, Tools FAQs
Last Updated: September 5, 2001
Document Number: 01072303_e
Q.
In NC308WA V.3.00 Release 1, the "enter" instruction is output at the start of the function. But because it is not output in V.3.10
Release 2, the stack argument cannot be correctly referenced from the in-line assembly description. How can I generate the "enter"
instruction in this case?
A.
The NC308WA optimization has been enhanced so that unnecessary "enter" instructions are not output. As the compiler does not
consider the processing contents of the in-line assembler statement, if an argument or automatic variable is not referenced at least
once somewhere other than within #pragma ASM to #pragma ENDASM, or asm(), the "enter" instruction is considered not
necessary and is not output.
NC308WA supports the following statement method for referencing C-language variables in in-line assembly: asm("...$$..." or
"...$@...", variable name);.
The compiler recognizes whether or not a variable is being used, and the "enter" instruction is generated as necessary. Other
methods used for referencing C-language variables will result in unreliable operations of the specified function or possible loss of
compatibility between compiler versions. Do not use other methods to reference variables or arguments or to set return values for
functions.
We recommend the following statement method:
[Example 1]
---------------------------------------------------
void memset(char *p, char c, unsigned short n)
{
asm(" PUSHM A1,R0,R3 "); // must exit from register to be used
asm(" MOV.L $$[FB],A1 ", d); // transfer argument d to A1
asm(" MOV.B $$[FB],R0L ", c); // transfer argument c to ROL
asm(" MOV.W $$[FB],R3 ", n); // transfer argument n to R3
asm(" SSTR.B ");
asm(" POPM A1,R0,R3 "); // original register
}
---------------------------------------------------
[Example 2]
---------------------------------------------------
void memset(char *p, char c, unsigned short n)
{
asm(" PUSHM A1,R0,R3 "); // must exit from register to be used
asm(" MOV.L $@,A1 ", d); // transfer argument d to A1
asm(" MOV.B $@,R0L ", c); // transfer argument c to ROL
asm(" MOV.W $@,R3 ", n); // transfer argument n to R3
asm(" SSTR.B ");
asm(" POPM A1,R0,R3 "); // return to original register
}
---------------------------------------------------
As an automatic variable, $$ substituted in the offset from the FB register value.
As an external variable, $$ replaces the symbol of the variable.
As a register variable, $$ replaces the register name.
$@, on the other hand, becomes the substitute for the operand that indicates an automatic, external or register variable. (The
compiler automatically determines the type of variable of $@.)
Due to optimization, function arguments and automatic variables may be modified into register variables. However, variables which
are used by asm("...$$..." or "...$@...", variable name); will not be modified in any way. For example, even a "$$" you intended to
Comentarios a estos manuales