[英]Assembly file (.s) throwing error: unknown use of instruction mnemonic without a size suffix
[英]smulwb assembly instruction
我正在嘗試理解以下代碼:
inline SInt32 smul32by16(SInt32 i32, SInt16 i16)
{
register SInt32 r;
asm volatile("smulwb %0, %1, %2" : "=r"(r) : "r"(i32), "r"(i16));
return r;
}
有人知道這個匯編指令做什么嗎?
更新: PS我使用目標C。我應該從匯編中了解一些代碼。 這就是為什么我很難理解此代碼的原因。
它確實以有符號的16位乘法乘以有符號的32位,並返回48位結果的前32位。 b指定使用第三個操作數的低16位。
因此,將其轉換為偽代碼:
int_48 temp;
temp = i32*i16;
result = temp >> 16;
有關ARM SMUL和SMULW指令的描述,請參見此處:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CHDIABBH.html
通過使用asm
您可以給匯編器命令。
並使用volatile
的原因
volatile for the asm construct, to prevent GCC from deleting the asm statement as unused
請參閱此鏈接以更好地了解
里面的命令問指令的意思是:
SMULWB R4, R5, R3 ; Multiplies R5 with the bottom halfword of R3,
; extracts top 32 bits and writes to R4.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.