Question

[Mips Assembly] Why do "la label" instructions always need to be translated into two lines of...

[Mips Assembly]

Why do "la label" instructions always need to be translated into two 
lines of pseudo code?  What about "lw label" instructions? Explain 
the similarities and differences in how they are implemented?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

please find the answer below:::

la will be translates in

lui $rs, upper( big )
ori $rs, $rs, lower( big )

Address will be of 32 bit in size. Upper address will be defaulted like 0x0040 is default for MARS.

So if

If you had done la $s0,main,

the lui would be lui $at,0x0040 because the default start address for .text is 0x00400000.

The lui loads the upper 16 bits of the address, and the ori loads the lower 16 bits of the address. The address can be any 32 bit value

hence to access exact address la translates in two instructions.

2) LW

Load word also required address to access the address hence it will translates into following instructions.

LUI load upper immediate

LW load word

lw    d,exp      #  Load register $d with the value at 
                 #  address exp.  exp can be any
                 #  of several expression types 
                 #  that evaluate to  an address
                 #  (pseudoinstruction) 

Here is a possible translation the pseudo instruction lw. Say that the symbol data stands for the address 0x10000004

lw $t0,data   ==   lui $1,0x1000
                   lw $8,4($1)
Add a comment
Know the answer?
Add Answer to:
[Mips Assembly] Why do "la label" instructions always need to be translated into two lines of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write MIPS code for each of the following instructions, Your assembly should implement the C code...

    Write MIPS code for each of the following instructions, Your assembly should implement the C code directly – i.e.,do not ’optimize’ the C code to change the order of operations or reduce computations. Use commands only like add, sub, lw, sw, immediate Part 1. x = 3-13*x; Do not use multiply. One way of doing the multiply without a multiply instruction is by using many add instructions (x+x+...+x). For this problem, you should do it with fewer additions. Hint: We...

  • Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...

    Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation. (8 Points) 1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the...

  • 2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2....

    2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2. $s2. 2 subi $t1. st1. 1 bne t1. 0. LOOP DONE: LOOP: it st2. $0. stl beq t2. 0. DONE addi $s2. Ss2. 2 LOOP DONE: For the loops written in MIPS assembly in the above table, assume that the register Şt1 is initialized to the value of 10. What is the value in register $s2 assuming that $s2 initially has a value of...

  • 4) Consider the following assembly language code: INSTRUCTIONS T01 T02 T03 T04 T05 T06 T07 T08...

    4) Consider the following assembly language code: INSTRUCTIONS T01 T02 T03 T04 T05 T06 T07 T08 T09 T10 T11 T12 T13 T14 (as a table) Loop: sll $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0($t1) beq $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: Use a pipeline with forwarding, hazard detection, and 1 delay slot for branches. The pipeline is the typical 5-stage IF, ID, EX, MEM, WB MIPS design. For the above code, complete the...

  • (Computer structure)For the MIPS datapath shown below, several lines are marked with "X". (a) If the line is cut...

    (Computer structure)For the MIPS datapath shown below, several lines are marked with "X". (a) If the line is cut at place 1. Which of the following two instructions will not work? Briefly explain why. Add $1, $2,$3 SW $1,100($2) (b)If the line is cut at place 2, which code snippet will not work? Briefly explain. Code snippet 1: Add $1, $2, $3 Add $4, $1, $1 Code snippet 2: Add $1, $2,$3 Add $4, $5,$6 (C) If the line is...

  • Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global...

    Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global integer variables w, x, y, z -- in the .data section function main() SysPrintStr("Enter an integer >= 0 for w? ") w ← SysReadInt() SysPrintStr("Enter an integer >= 0 for x? ") x ← SysReadInt() SysPrintStr("Enter an integer < 0 for y? ") y ← SysReadInt() z ← 16(w + x) - (3 × -y mod 7) SysPrintStr("z = ") SysPrintInt(z) SysExit() end function...

  • I AM POSTING MY QUESTION 3RD TIME . FIRST TWO TIMES I DIDNOT GET THE PROPER...

    I AM POSTING MY QUESTION 3RD TIME . FIRST TWO TIMES I DIDNOT GET THE PROPER ANSWER. PLEASE DO ALL STEPS BY LABELING THE EACH STEP. THIS IS THE ASSIGNMENT IN WHICH THE EACH STEP SHOULD BE LABEL . I MEAN EVERY THING SHOULD BE WRITTEN WHAT WE HAVE DONE IN OUR PROGRAM THIS IS THE REQUIREMENT OF TEACHER , PLEASE DO IT PROPERLY   1) MIPS to C. Assume that the variables f, g, h, i, and j are assigned...

  • 1) Do the electric field lines cross? Can two equipotential 2) Explain why the equipotential surfaces...

    1) Do the electric field lines cross? Can two equipotential 2) Explain why the equipotential surfaces should be always 3) A uniform electric field is parallel to the y-axis. What lines ever cross? Explain. perpendicular to the electric field lines? direction can a charge be displaced in this field without any external work being done on the charge?

  • Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how...

    Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT