This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/MSP430G2452:乘法 int32 = int16 * int16

Guru**** 3038710 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/902944/ccs-msp430g2452-multiplying-int32-int16-int16

器件型号:MSP430G2452

工具/软件:Code Composer Studio

我的代码中有以下行:

struct system_info{
  unsigned int battery_gain;
  int battery_offset;
}系统信息;

unsigned int read_battery (void);

return (((unsigned long) read_battery ()* SystemInfo.battery_gain)>> 10)+ SystemInfo.battery_offset;

编译此行时、我获取 int32 = int32 x int32乘法、在库中调用__mpyl。

我尝试按照乘法运算指南(www.ti.com/.../spra683):)中的指令操作

返回((unsigned long)(unsigned int) read_battery ()*(unsigned long)(unsigned int) SystemInfo.battery_gain)>> 10)+ SystemInfo.battery_offset;

我仍然得到相同的乘法调用_mpyl。

如何使用更高效的乘法 int32 = int16 x int16?