0

问题在 AVR GCC 上下文中。

我有 C 函数原型的 .s 文件,如下所示:

Mod_BigNum_by_u8: .global Mod_BigNum_by_u8 
; c-prototype ==> uint8_t Mod_BigNum_by_u8(uint8_t * pBigNum, uint8_t ByteCount, uint8_t Divisor); 

; Parameters 
    .set pBigNum, 24        ; (u16) pointer to the BigNum Dividend.  Highbyte first 
    .set ByteCount, 22      ; (u8) number of bytes in the BigNum 
    .set Divisor, 20        ; (u8) Divisor 

; Local Variables 
    .set BitCount, 23       ; (u8) Number of bits left in the current byte 
    .set CurrentByte, 21    ; (u8) Most recently used byte of BigNum 

; Return value 
    .set Dividend, 24       ; (u16) result (we only need 8bits, but WinAVR requires 16) 
... 

上面的函数在 Atmel Studio 中工作正常(我想不得不说“用 avr-gcc 编译”)。

GNU asm syntax 
Syntax: .set symbol, expression 

AVR asm 
.SET label = expression 

这意味着使用了 GNU 语法。现在我想了解的是 - 这些常数 24、22、20 在 C 函数原型方面意味着什么?评论表明我正在加载函数参数,但我不明白 .set 和那些常量是如何发生的。我曾经认为参数是通过堆栈和寄存器传递的。

第二个问题 - 我知道 AVR asm 是从 GNU 派生的,但我真的可以像上面那样将 GNU asm 语法与 AVR asm 混合吗?

4

1 回答 1

0

AVR 使用寄存器来传递前几个参数。请参阅此处的调用约定说明

The registers are memory-mapped at address zero. As such, the numbers you see in the pasted code are addresses that equal register numbers and can be used to reference the arguments through the memory mapping.

于 2012-12-02T15:07:02.170 回答