Armv8 - 64核心编程:整数运算与指令详解
1. 整数乘法指令
在Armv8 - 64架构中,有多个用于整数乘法的指令,以下是几个示例函数及其功能:
| 函数名 | 指令 | 功能 |
| ---- | ---- | ---- |
| IntegerMulA_ | mul w0,w0,w1 | 将寄存器W0(参数值a)与W1(参数值b)相乘,结果截断为32位后保存到W0 |
| IntegerMulB_ | mul x0,x0,x1 | 将两个64位整数相乘,128位乘积的低64位保存到X0 |
| IntegerMulC_ | smull x0,w0,w1 | 将寄存器W0和W1中的32位有符号整数相乘,完整的64位有符号整数乘积保存到X0 |
| IntegerMulD_ | umull x0,w0,w1 | 使用两个32位无符号整数操作数计算64位无符号整数乘积,结果保存到X0 |
以下是示例代码:
// Calculate a * b and save result
smull x0,w0,w1 // signed 64-bit
ret
// extern "C" unsigned long IntegerMulD_(unsigned int a, unsigned int b);
.global IntegerMulD_
IntegerMulD_:
// Calculate a * b and save result
umull x0,w0,w1 // unsign
超级会员免费看
订阅专栏 解锁全文
828

被折叠的 条评论
为什么被折叠?



