Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly C函数原型和.set指令_Assembly_Avr_Avr Gcc - Fatal编程技术网

Assembly C函数原型和.set指令

Assembly C函数原型和.set指令,assembly,avr,avr-gcc,Assembly,Avr,Avr Gcc,问题在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

问题在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语法。现在我想了解的是,对于C函数原型来说,常数24,22,20意味着什么?注释表明我正在加载函数参数,但我不明白.set和那些常量是如何发生的。我过去认为参数是通过堆栈和寄存器传递的


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

AVR使用寄存器来传递前几个参数。看

寄存器在地址0处进行内存映射。因此,您在粘贴的代码中看到的数字是等于寄存器编号的地址,可用于通过内存映射引用参数

GNU asm syntax 
Syntax: .set symbol, expression 

AVR asm 
.SET label = expression