在汇编中添加两个 64 位数字

发布于 2024-07-30 19:33:21 字数 273 浏览 1 评论 0原文

所以我正在使用 SPIM 模拟器学习 MIPS,但我陷入了这个问题。

我想将存储在四个 32 位寄存器中的两个 64 位数字相加。 所以我添加了 LO 字节,然后添加了进位和 HI 字节。 但是没有adc/addc命令,即带进位的加法。

所以我必须在状态寄存器中添加进位位。 但是,我到底如何读取这个寄存器呢?

如果$t0是临时寄存器1,那么保存进位标志的状态寄存器相当于什么?

我在谷歌上搜索了很多,但仍然找不到任何使用状态寄存器的示例。

So I am learning MIPS using the SPIM simulator and im stuck on this problem.

I want to add two 64 bit numbers which are stored in four 32 bit registers. So I add the LO bytes and then the carry and the HI bytes. But there is no adc/addc command i.e. add with carry.

So I would have to add the carry bit in the status register. But, how exactly do I read this register?

If $t0 is temporary register 1, then what is the equivalent of the status register which holds the carry flag?

I have googled a lot I still can't find any examples that even use the status register.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

话少情深 2024-08-06 19:33:21

添加 $t2 $t3 + $t4 $t5,结果为 $t0 $t1

addu  $t1, $t3, $t5    # add least significant word
sltu  $t0, $t1, $t5    # set carry-in bit 
addu  $t0, $t0, $t2    # add in first most significant word
addu  $t0, $t0, $t4    # add in second most significant word

对于问题的第二部分,没有状态寄存器。 一个都没有。 没什么。

Add $t2 $t3 + $t4 $t5, result in $t0 $t1

addu  $t1, $t3, $t5    # add least significant word
sltu  $t0, $t1, $t5    # set carry-in bit 
addu  $t0, $t0, $t2    # add in first most significant word
addu  $t0, $t0, $t4    # add in second most significant word

For the second part of your question, there is no status register. None at all. Nada.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文