- 论坛徽章:
- 0
|
求助:求高手指点AVRGCC内嵌汇编写法。
想实现两个16位定点小数相乘,得到一个32位定点小数。
在AVRGCC上编译不通。
- int32_t fmuls16(int16_t A,int16_t B)
- {
- int32_t result; //32位定点小数
- int16_t val0=(int16_t)A,val1=(int16_t)B; //16位定点小数
- int8_t zero=0;
- asm
- (
- "fmuls %b1,%b2" "\n\t"
- "movw %c0,r0" "\n\t"
- "fmul %a1,%a2" "\n\t"
- "movw %a0,r0" "\n\t"
- "adc %c0,%3" "\n\t"
- "fmulsu %b1,%a2" "\n\t"
- "sbc %d0,%3" "\n\t"
- "add %b0,r0" "\n\t"
- "adc %c0,r1" "\n\t"
- "adc %d0,%3" "\n\t"
- "fmulsu %a1,%b2" "\n\t"
- "sbc %d0,%3" "\n\t"
- "add %b0,r0" "\n\t"
- "adc %c0,r1" "\n\t"
- "adc %d0,%3" "\n\t"
- :"=r"(result)
- :"d"(val0),"d"(val1),"r"(zero)
- :"r0","r1"
- );
- return result;
- }
复制代码 |
|