Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly ARM组装中的SMMUL指令_Assembly_Arm - Fatal编程技术网

Assembly ARM组装中的SMMUL指令

Assembly ARM组装中的SMMUL指令,assembly,arm,Assembly,Arm,参考: SMMUL意味着相乘到VARABLE,但我不明白它如何计算“结果的最高有效有符号32位” 提前感谢当您将2个32位值相乘时,您将得到一个64位值,并且您必须将结果保存在两个寄存器中,因为寄存器是32位的。但是,您可能对最低32位不感兴趣,而只对最高32位感兴趣 SMULL说明提供了这一点。首先计算64位结果,然后它可以简单地丢弃/截断较低的32位,或者将其舍入到较高的32位(SMULLR) 谢谢你的回答,我想我明白了,但我还有一个问题,关于它如何截断以将值降低到32位?@Nnez添加了一

参考:

SMMUL意味着相乘到VARABLE,但我不明白它如何计算“结果的最高有效有符号32位”


提前感谢

当您将2个32位值相乘时,您将得到一个64位值,并且您必须将结果保存在两个寄存器中,因为寄存器是32位的。但是,您可能对最低32位不感兴趣,而只对最高32位感兴趣

SMULL
说明提供了这一点。首先计算64位结果,然后它可以简单地丢弃/截断较低的32位,或者将其舍入到较高的32位(
SMULLR


谢谢你的回答,我想我明白了,但我还有一个问题,关于它如何截断以将值降低到32位?@Nnez添加了一些东西可以玩。为什么是20位?为什么不是32岁?(它也可以是圆形的)。32位小数?真的叫和森吗?
Writes the most significant signed 32 bits of the result in Rd.
$ cat smmul.c 
int smull(int a, int b, int c, int d) {
    asm volatile("smmul r0, r2, r3");
}

int main() {
    int a, b, c;
    a = 0x00000001;
    b = 0x00000001;
    c = smull(0, 0, a, b);
    printf("%x(%d) %x(%d) %x(%d)\n", a, a, b, b, c, c);
    a = 0x40000000;
    b = 0x00000004;
    c = smull(0, 0, a, b);
    printf("%x(%d) %x(%d) %x(%d)\n", a, a, b, b, c, c); 
    return 0;
}

$ smmul
1(1) 1(1) 0(0)
40000000(1073741824) 4(4) 1(1)