在 MIPS 汇编中,如果浮点寄存器中有浮点值 X.YZDEF,如何截断到小数点后两位?
如果我在 MIPS 中的“f”寄存器中有一个值,如何将其从 X.YZDEF 截断为 X.YZ?据说,您必须从浮点数转换为两个整数并显示它们......这是如何完成的?
If I have a value in an "f" register in MIPS, how do I truncate this down to X.YZ from X.YZDEF? Supposedly, you must convert from the float to two ints and display those... How is this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能想查看这些链接是否对您有帮助。
http://en.wikipedia.org/wiki/MIPS_architecture#MIPS_Assembly_Language
http://chortle.ccsu.edu/AssemblyTutorial/index.html#part8
您可以还发现这很有帮助:
http://www.uni-koblenz.de/~avolk/ MIPS/Material/MIPSFloatingPointInstructions.pdf
我已经很长时间没有进行汇编编程了,但是,如果你乘以 100
mul.s
>,那么你将复制数字到整数寄存器,那么如果除以 100 <div
>那么你就会看到右边的两位数字。我希望小数点左边的数字是 LO,右边的数字应该是 HI。You may want to look and see if these links will help you.
http://en.wikipedia.org/wiki/MIPS_architecture#MIPS_Assembly_Language
http://chortle.ccsu.edu/AssemblyTutorial/index.html#part8
You may also find this helpful:
http://www.uni-koblenz.de/~avolk/MIPS/Material/MIPSFloatingPointInstructions.pdf
It has been a long time since I did assembly programming, but, if you multiply by 100 <
mul.s
>, then you will copy the number to an integer register, then if you divide by 100 <div
> then you will have just the two digits on the right. The number to the left of the decimal will be in LO and the number to the right should be in HI, I expect.最简单的方法是:
mul.d
),round.ld
),div.d
)。The easiest thing to do is:
mul.d
),round.l.d
),cvt.d.l
), anddiv.d
).为了在 MIPS 中实现截断(而不是舍入),您可以执行以下操作
In order to implement a truncation (not rounding) in MIPS, you can do the following