Question

In: Computer Science

MIPS assembly language. Why do "la label" instructions always need to be translated into 2 lines...

MIPS assembly language.

Why do "la label" instructions always need to be translated into 2 lines of pseudo code? What about "lw label" instructions? Explain the similarities and differences in how they are implemented in MARS.

Solutions

Expert Solution

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)

Related Solutions

MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
Translate the following C code to MIPS assembly. The main function and subfunction are translated to...
Translate the following C code to MIPS assembly. The main function and subfunction are translated to two separate .asm files. Finish the assembly code segment for the above requirement. int main() { int x=2; int y=1; int z=0; z=Subfunc(x,y); printf(“Value of z is: %d”, z); } int Subfunc(int x, int y) { int t1=0; t1=x+y+100; return t1;} File 1: .data str: .asciiz "The value of z:" .text #.globl main main: addi $s0, $0,2 #x addi $s1, $0,1 #y addi $s2,...
Do Not Use Pseudo Insturctions or li la instructions, etc... Write and test a MIPS program...
Do Not Use Pseudo Insturctions or li la instructions, etc... Write and test a MIPS program consisting of four functions. In the following descriptions, the symbol & means “address of”. void main(): The main function must 1) print your name 2) call the readData function 3) call count function 4) complete the program. The main function must set up all parameters before calling each of the functions. int readData (&array): The starting address of an array is passed to the...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to the follow java program: int day = (int)(Math.random() * 7); switch (day) { case 1: System.out.println(“Monday”); break case 2: System.out.println(“Tuesday”); break case 3: System.out.println(“Wednesday”); break case 4: System.out.println(“Thursday”); break case 5: System.out.println(“Friday”); break case 6: System.out.println(“Saturday”); break case 0: System.out.println(“Sunday”); break }
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer"...
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer" to calculate the square root for an-8 bit integer using The Radix-2 SRT-Redundant and Non-Redundant Algorithm to approximate square root
I'm trying to code in MIPS (MIPS Assembly Language) to calculate the hamming distance between two...
I'm trying to code in MIPS (MIPS Assembly Language) to calculate the hamming distance between two integers. Ideally, the program would ask for the user to type in the two integers. Then, the program would calculate the hamming distance. Afterward, it would ask if you'd like to find another hamming distance. If the user says yes, it would loop back to the beginning and ask for two new integers. Below is the code that I've created so far. Guidance with...
Assemby language - MIPS Your assembly should implement the C code directly – i.e.,do not ’optimize’...
Assemby language - MIPS 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. Write MIPS assembly code implementing the following C/C++ statement: y = 13 - 11*x; 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 know how to express any integer as a sum...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT