How to change the assembly code %hi and %lo to run in 'MARS'?

烂漫一生 提交于 2019-12-02 08:33:48

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

As the la macro is expanded to two instructions,that is an extra instruction compared to the use of %hi/%lo but it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!