smulwb assembly instruction

I'm trying to understand this code:

inline SInt32 smul32by16(SInt32 i32, SInt16 i16)
{
    register SInt32 r;
    asm volatile("smulwb %0, %1, %2" : "=r"(r) : "r"(i32), "r"(i16));
    return r;
}

Does anybody know what this assembly instruction does?

Update: PS I use objective C. and I should understand some code from assembly. That's why it's difficult for me to understand this code.


It does signed 32 bit by signed 16 bit multiplication and returns the top 32 bit of 48 bit result. The b specifies to use the bottom 16bit of the third operand.

So, translating it into pseudo code:

int_48 temp;
temp = i32*i16;
result = temp >> 16;

See here for the description of the ARM SMUL and SMULW instructions:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0553a/CHDIABBH.html


by using asm you can give assembler commands.

and using volatile for the reason,

volatile for the asm construct,  to prevent GCC from deleting the asm statement as unused

see this link for better understanding

command inside ask instruction means :

SMULWB       R4, R5, R3       ; Multiplies R5 with the bottom halfword of R3,
                              ; extracts top 32 bits and writes to R4.
链接地址: http://www.djcxy.com/p/87128.html

上一篇: 在64位堆栈驻留缓冲区溢出

下一篇: smulwb汇编指令