MIPS:LA指令,而无需使用伪codeS的相同呢? [英] MIPS: The Equivalent of la instruction without using pseudo codes?

查看:1278
本文介绍了MIPS:LA指令,而无需使用伪codeS的相同呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基准说,对LA(加载地址)的伪code被翻译成:

The reference says the pseudo code for la (load address) is translated to:

Pseudo : la $1, Label   

lui $1, Label[31:16]
ori $1,$1, label[15:0]

但是当我尝试组装在火星code我得到的错误:

but when I try to assemble the code in MARS I get the error:

无效的语言元素:16]

如果我删除[31:16]部分我得到

and if I remove the [31:16] part I get

标签:操作数是类型不正确

任何想法?

推荐答案

这意味着,标签的16个最高显著位被设置$ 1。然后,16少显著位或运算与16最显著位

That means that the 16 most significant bits of label are set in $1. Then, 16 less significant bits are or'ed with the 16 most significant bits.

的在这里,你可以找到的说明吕指令。它加载在登记册上的标签地址的16 MSB位和16归零LSB。

Here you can find the description of the lui instruction. It loads 16 msb bits of the label address on the register and zeroes 16 lsb.

这方法,你可以(在MIPS32)与32位指令加载32位地址。

This way, you can load 32 bit address (in mips32) with 32 bit instructions.

及其决不旨在是真正的code。在[31:16] / [15:0]部分是无效的MIPS,并且只在那里你了解位动作

Its in no way intended to be "real code". The [31:16] / [15:0] part is not valid mips, and is only there for you to understand bit movements.

编辑:
在回答您的意见,你必须知道你想用吕指令来加载地址。要做到这一点,你可以使用一个标签说明所需要的地址。
例如:

In response to your comment, you would have to know the address you want to load using the lui instruction. To do this, you could use a label to indicate the desired address. For example

.data 
my_var: .asciiz "This is a nul terminated string"

.text
        andi $a0,$a0,0x0000ffff
        lui $a0,my_var
        ori $a0,$a0,my_var

这篇关于MIPS:LA指令,而无需使用伪codeS的相同呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆