问个简单问题,也是关于马老师例子程序中的
void boot_page_ew(long p_address,char code){
asm("mov r30,r16
"
"mov r31,r17
"
"out 0x3b,r18
"); //将页地址放入Z寄存器和RAMPZ的Bit0中
SPMCSR = code; //寄存器SPMCSR中为操作码
asm("spm
"); //对指定Flash页进行操作
}
//填充Flash缓冲页中的一个字
void boot_page_fill(unsigned int address,int data)
{
asm("mov r30,r16
"
"mov r31,r17
" //Z寄存器中为填冲页内地址
"mov r0,r18
"
"mov r1,r19
"); //R0R1中为一个指令字
SPMCSR = 0x01;
asm("spm
");
}
这两个方法中怎么没有对address的处理呢,比如将address利用汇编语句写入r30,r31z寄存器呢?也没有将address赋值给r16,r17啊?那么z寄存器怎么就得到address的值呢!
原来贴在“自引导IAP”那个帖子里边,可惜大家都不回答,呵呵,贴过来了。
谢谢! 以下是ICC HELP的说明:
Argument and Return Registers
The first argument is passed in registers R16/R17 if it is an integer and R16/R17/R18/R19 if it is a long or floating point. The second argument is passed in R18/R19 if available. All other remaining arguments are passed on the software stack.
Integer arguments smaller than ints (i.e. char) are not extended to in IF the function prototype is available. If registers are used to pass byte arguments, it will use both registers but the higher register is undefined. For example, if the first argument is a byte, both R16/R17 will be used with R17 being undefined. Byte arguments passed on the software stack take up only a single byte. In the future release, byte arguments passed in registers will be packed tightly.
If R16/R17 is used to pass the first argument and the second argument is a long or float, the lower half of the second argument is passed in R18/R19 and the upper half is passed on the software stack.
Integer values are returned in R16/R17 and longs and floats are returned in R16/R17/R18/R19. Byte values are returned in R16 with R17 undefined.
页:
[1]