Question

MIPS assembly language question

If $s0 has the base address of array A, and A has the following elements: 9, 6, 4, 24, 33, 0, 1; What is the value of $t1 after the instructions are executed? addi $t1, $zero, 20 add $t0, $t1, $S0 lw $t1, (Sto)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :

addi $t1, $zero, 20
This instruction will add 20 on zero register and assign result to $t1 register.
hence $t1 will have value 20.

add $t0, $t1, $s0
This instruction will add content of $t1 and $s0 and result will be stored in $t0.
hence $t0 will store value as address of A + 20.

lw $t1, ($t0)
this will load value from memory address (address of A + 20) and store it in $t1.


one integer requries 4 bytes
hence address (address of A+20) will point to 5th element in the array A.
Hence $t1 will have 33.

if you have any doubts then you can ask in comment section if you find the solution helpful then upvote the answer. Thank you.

Add a comment
Know the answer?
Add Answer to:
MIPS assembly language question If $s0 has the base address of array A, and A has...
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 THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data...

    WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data prompt: .asciiz "\nMaximum number is : " prompt1: .asciiz "\nMinimum number is : " prompt2: .asciiz "\nRange of the array is : " size: .word 10 #load array array: .word 23, -12, 45, -32, 52, -72, 8, 13,22,876 .text #load address of array and size la $s4,array #load address of A lw $t0,size #load i to t0 jal getArrayRange li $v0, 4    la...

  • Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data...

    Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data the Array: space 160 main: li $t6, 1 li $17, 4. sw $17, the Array($0) sw $17, theArray($17) li $t0, 8 loop: addi $t3, $t0, -8 addi $t4, $t0, -4 lw 1, the Array($t3) lw $12, the Array(St4) add $15, $t1, $t2 sw $15, theArray($to) addi $t0, $t0, 4 blt $t0, 160, loop jr Sra. Question 4 Assembly code a) what is the contents...

  • B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 ...

    B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i < 10i i++) i array[i+l] - array [i8; Register assignment: i-> Şa0 Base of array -> $s0 B2. Translate the following MIPS assembly instruction into machine language: lw $t8, 100($s0) B3 Write MIPS assembly code segment for the following C code snippet: for (i - O i Şa0 Base of...

  • 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...

  • Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction...

    Question 3 (10 points) Convert the following MIPS assembly code into machine language. Write the instruction in hexadecimal. The opcode for sw 43 (101011). sw St1, -4(St3) Question 4 (10 points) Consider the following MIPS assembly code: addi $s3, $0, 5 addi $s1, S0, 3 addi Ss1, $s1, 2 beq Ss3, Ssl, target addi Ss1, Ss1, 1 target: add Ss3, Ss1, Ssl a. After running the code, what is the value of Ss3? b. If the memory address of the...

  • im trying to complete mips program code about a calculator program that can calculate integer addition...

    im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...

  • MIPS MIPS MIPS PLEASE INCLUDE COMMENTS AND OUTPUT Sort array using Bubble sort algorithm. 1) First...

    MIPS MIPS MIPS PLEASE INCLUDE COMMENTS AND OUTPUT Sort array using Bubble sort algorithm. 1) First ask the user how many elements of his/her array. 2) Then, read the integer array elements as input from the User. 3) Then, print out the array before the sorting 4) Apply Bubble sort algorithm on your array 5) Print out the array after the sorting 6) Print some welcome text to th user 7) Add comments to your code to describe how is...

  • Convert the following instructions from MIPS assembly language to machine language add $50, $t0, $s3 (op...

    Convert the following instructions from MIPS assembly language to machine language add $50, $t0, $s3 (op code: 0, function code: 32) sub $t9, $50, $zero (op code: 0, function code: 34) addi $s2, $t0, 16 (op code: 8, function code: Does not exist for I-type instructions)

  • Name B. (7 pts) MIPS short answer 1. (3pt) For the following MIPS assembly language program:...

    Name B. (7 pts) MIPS short answer 1. (3pt) For the following MIPS assembly language program: loop: addi Sto, $to,-1 bne $to, $zero, loop Translate the second instruction into MIPS machine language and write it in hex. 2. (2 pt) Which best describes the reason that we maintain the stack pointer in a register? (circle one) i. The hardware forces use of a stack pointer. ii. We need a local pointer because we are often limited to relative addressing. ili....

  • PLEASE WRITE CLEARLY AND SHOW ALL STEPS SO THAT I CAN UNDERSTAND IT. THANKS Convert the...

    PLEASE WRITE CLEARLY AND SHOW ALL STEPS SO THAT I CAN UNDERSTAND IT. THANKS Convert the following MIPS assembly code into machine language. Write the machine code in hexadecimal. add $t0, $s0, $s1 lw $t0, -10($t1) addi $s1, $0, -20

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