如何更改汇编代码%hi和%lo在'MARS'中运行? [英] How to change the assembly code %hi and %lo to run in 'MARS'?
问题描述
我使用编译器资源管理器"将c ++转换为MIPS 但由于%hi和%lo
I used 'compiler explorer' to convert c++ to MIPS but it doesn't work well in the MARS because of %hi and %lo
我知道我应该更改零件,但是我不知道如何更改...
I know I should change the part, but I don't know how to change...
请帮助
$L5:
lui $2,%hi($LC1)
lwc1 $f0,%lo($LC1+4)($2)
lwc1 $f1,%lo($LC1)($2)
b $L3
$LC1:
.word 1100470148
.word 0
$L17:
lw $2,16($fp)
addiu $3,$2,1
sw $3,16($fp)
lui $4,%hi(savepath)
sll $3,$2,2
addiu $2,$4,%lo(savepath)
addu $2,$3,$2
li $3,1 # 0x1
sw $3,0($2)
move $sp,$fp
lw $fp,36($sp)
addiu $sp,$sp,40
j $31
推荐答案
AFAIK,在火星上无法像气体%lo(label)或%hi(label)功能一样.
一个简单的解决方法是使用标准宏la
,该宏通过一对或lui
/ori
指令将标签加载到寄存器中.
AFAIK, there is no way in Mars to have something like the gas %lo(label) or %hi(label) feature.
A simple workaround is to use the standard macro la
that loads a label in a register with a pair or lui
/ori
instructions.
代码的第一部分可以这样重写:
The first part of your code can be rewritten like that:
$L5:
la $2, $LC1
lwc1 $f0,4($2)
lwc1 $f1,0($2)
b $L3
$LC1:
.word 1100470148
.word 0
由于la
宏被扩展为两条指令,与%hi/%lo
的使用相比,这是一个额外的指令,但是它可以工作.
As the la
macro is expanded to two instructions,that is an extra instruction compared to the use of %hi/%lo
but it works.
这篇关于如何更改汇编代码%hi和%lo在'MARS'中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!