ARM指令集之乘法指令

ARM指令集之乘法指令文章目录

文章目录

ARM有两类乘法指令:一类指令的操作结果为32位,所以叫32位乘法指令;另一类的操作结果位64位,所以叫64位乘法指令。

为了运算高效,乘法指令要求所有操作数都位于寄存器中,所以ARM乘法指令无需指定寻址方式。

ARM共有如下乘法指令:

助记符 说明 实现逻辑
MUL 32位乘法指令 Rd = Rm * Rs
MLA 32位带加数的乘法指令 Rd = Rm * Rs + Rn
SMULL 64位有符号数乘法指令 RdHi = (Rm * Rs)[63:32];
RdLo = (Rm * Rs)[31:0];
SMLAL 64位带加数的有符号数乘法指令 RdLo = (Rm * Rs)[31:0] + RdLo;
RdHi = (Rm * Rs)[63:32] + RdHi + CarryFrom((Rm * Rs)[31:0] + RdLo);
UMULL 64位无符号数乘法指令 RdHi = (Rm * Rs)[63:32];
RdLo = (Rm * Rs)[31:0];
UMLAL 64位带加数的无符号数乘法指令 RdLo = (Rm * Rs)[31:0] + RdLo;
RdHi = (Rm * Rs)[63:32] + RdHi + CarryFrom((Rm * Rs)[31:0] + RdLo);

MUL

MUL{<cond>}{S} <Rd>, <Rm>, <Rs>

if ConditionPassed(cond) then
	Rd = (Rm * Rs)[31:0]
	if S == 1 then
		N Flag = Rd[31]
		Z Flag = if Rd == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

MLA

MLA{<cond>}{S} <Rd>, <Rm>, <Rs>, <Rn>

if ConditionPassed(cond) then
	Rd = (Rm * Rs + Rn)[31:0]
	if S == 1 then
		N Flag = Rd[31]
		Z Flag = if Rd == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

SMULL

SMULL{<cond>}{S} <RdLo>, <RdHi>, <Rm>, <Rs>, <Rn>

if ConditionPassed(cond) then
	RdHi = (Rm * Rs)[63:32] // 计算结果的高32位
	RdLo = (Rm * Rs)[31:0] // 计算结果的低32位
	if S == 1 then
		N Flag = RdHi[31]
		Z Flag = if RdHi == 0 and RdLo == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

SMLAL

SMLAL{<cond>}{S} <RdLo>, <RdHi>, <Rm>, <Rs>, <Rn>

if ConditionPassed(cond) then
	RdLo = (Rm * Rs)[31:0] + RdLo
	RdHi = (Rm * Rs)[63:32] + RdHi + CarryFrom((Rm * Rs)[31:0] + RdLo)
	if S == 1 then
		N Flag = RdHi[31]
		Z Flag = if RdHi == 0 and RdLo == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

UMULL

UMULL{<cond>}{S} <RdLo>, <RdHi>, <Rm>, <Rs>, <Rn>

if ConditionPassed(cond) then
	RdHi = (Rm * Rs)[63:32]
	RdLo = (Rm * Rs)[31:0]
	if S == 1 then
		N Flag = RdHi[31]
		Z Flag = if RdHi == 0 and RdLo == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

UMLAL

UMLAL{<cond>}{S} <RdLo>, <RdHi>, <Rm>, <Rs>, <Rn>

if ConditionPassed(cond) then
	RdLo = (Rm * Rs)[31:0] + RdLo
	RdHi = (Rm * Rs)[63:32] + RdHi + CarryFrom((Rm * Rs)[31:0] + RdLo)
	if S == 1 then
		N Flag = RdHi[31]
		Z Flag = if RdHi == 0 and RdLo == 0 then 1 else 0
		C Flag = unaffected
		V Flag = unaffected

今天的文章ARM指令集之乘法指令分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/7312.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注