MIPS Programming: Download Address

Background

I’m just starting to learn MIPS for one of my courses, and my professor doesn’t allow us to use pseudo instructions like Load Address ( la) in our code . I am wondering how an example of the correct use of standard instructions would look like to save the address of the declared variable in a register, which will be used later in the code.

My decision

I am currently trying to use this code, although I am getting a syntax error in the instruction lui.

main:
.data
    Array:
    .space 80             #Declares that Array will hold 20 integers
.text
    lui  $s0, Array       #loads most significant bits into $s0
    ori  $s0, $s0, Array  #loads least significant bits into $s0

My question

From what I understand, this should result in the address Arraybeing put in $s0. However, since this does not seem to be the case, I am wondering if anyone can help me with what I should do here.

+1
1

lui ori. GNU ():

    .data
    Array:
    .space 80             #Declares that Array will hold 20 integers
...
.text
    lui $s0, %hi(Array)
    ori $s0, %lo(Array)
    lw  $s1, 0($s0)       # load 1st word of Array
...

% hi % lo , , "Array" . (: , , SPIM MARS.)

.

. MIPS Run - MIPS. MIPS, MIPS Linux.

+2

All Articles