leeshine 发表于 2017-7-19 08:42:00

请教,关于AVR的汇编指令, %A0, %A1, %A2和 %B0, %B1 , %B2分别...

本帖最后由 leeshine 于 2017-7-19 13:06 编辑

请问下面这个汇编函数, %A0, %A1, %A2和 %B0, %B1 , %B2分别代表什么?谢谢!

#define mult_shf_s16x16( a, b)    \
({                        \
int prod, val1=a, val2=b; \
__asm__ __volatile__ (    \
"muls %B1, %B2        \n\t"   \
"mov %B0, r0    \n\t"          \
"mul %A1, %A2   \n\t"          \
"mov %A0, r1    \n\t"   \
"mulsu %B1, %A2        \n\t"   \
"add %A0, r0    \n\t"   \
"adc %B0, r1    \n\t"   \
"mulsu %B2, %A1        \n\t"   \
"add %A0, r0    \n\t"   \
"adc %B0, r1    \n\t"   \
"clr r1         \n\t"   \
: "=&d" (prod)            \
: "a" (val1), "a" (val2)\
);                        \
prod;                     \
})

armok 发表于 2017-7-19 08:42:35

leeshine 发表于 2017-7-19 09:22:42

armok 发表于 2017-7-19 08:42
“ 请教,关于AVR的汇编指令”不是合格的标题。 违反版规11。请立即阅读版规(点击进入: http://www.amobbs. ...

{:sweat:} 如何修改标题?

armok 发表于 2017-7-19 10:31:05

leeshine 发表于 2017-7-19 10:57:28

armok 发表于 2017-7-19 10:31
24小时内你不修改好,ID就没了。

如何修改标题的流程给个说明?找不到修改的地方

atommann 发表于 2017-7-19 11:39:56

http://people.ece.cornell.edu/land/courses/ece4760/GCC_asm/index.html
上面的网页有讲解。定位到 Assembler Macro fixed point multiply 处。
这是 GCC 内联汇编的语法。

The suffix zero items (A0, B0) refer to the lower byte (A0) and high byte of parameter zero, which is the output of the macro. Similarly items A1 and B1 are bytes of parameter one, which is the first input, anditems A2 and B2 are bytes of parameter two, which is the second input.

avr-libc 的文档里也有讲解
http://www.nongnu.org/avr-libc/user-manual/inline_asm.html

442502587 发表于 2017-7-19 12:30:25

leeshine 发表于 2017-7-19 09:22
如何修改标题?

编辑骚年

leeshine 发表于 2017-7-19 13:06:33

442502587 发表于 2017-7-19 12:30
编辑骚年

谢谢!找到了

leeshine 发表于 2017-7-19 13:06:51

atommann 发表于 2017-7-19 11:39
http://people.ece.cornell.edu/land/courses/ece4760/GCC_asm/index.html
上面的网页有讲解。定位到 Assem ...

多些大侠
页: [1]
查看完整版本: 请教,关于AVR的汇编指令, %A0, %A1, %A2和 %B0, %B1 , %B2分别...