Question

1. Assume there are three memory locations named h hand area, translate the following expression into...

1. Assume there are three memory locations named h hand area, translate the following expression into MIPS assembly language. No Floating point.

Area= 1/2 b. h

2. Show the assembly statement that allocates a word in the data segment named area with an initial value of 10.

3. What are the contents of register $t0, $t1, and $t2?

.data
str:    .asciiz   "ab"

.text
main:   la $t0, str
li    $t1, 0
loop: lb $t2, ($t0)
beqz   $t2, eloop
addi $t1, $t1, 1
addi $t0, $t0, 1
b   loop
eloop: nop

Homework Answers

Answer #1

1.

.data
h: .word 10
b: .word 5
area: .word

.text
.globl main
main:
   la $t1, h
   lw $t1, ($t1)
   la $t2, b
   lw $t2, ($t2)
   mult $t1, $t2
   mflo $t1
   srl $t1, $t1, 1
   la $t2, area
   sw $t1, ($t2)
   li $v0, 10
   syscall

2.

#assembly statement that allocates a word in the data segment named area with an initial value of 10.

area: .word 10

3.

$t0 = 268500994

$t1 = 2

$t2 = 0

Know the answer?
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
Similar Questions
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of...
Question 1. Answer the following questions on MIPS Instruction Set. a) Show the minimal sequence of MIPS instruction for the following pseudocode segment: A[3] = A[10] + B; Assume that B corresponds to register $t3 and the array A has a base address of 1000C41016 which is required to be loaded to register $t0 in your code. Provide comments for each line of your MIPS instruction. b) Assume that Loop starts at memory location 0xC010. Provide a) instruction format of...
The C++ program steps through the array x[]. For each i, if x[i] < x[i+1], i...
The C++ program steps through the array x[]. For each i, if x[i] < x[i+1], i is saved in the array ascend[], in order. Compile and run the program; it should print 0 4 5. In this exercise, you’ll try to translate the C++ program to MIPS. Some of the more tedious parts are already given in Assignment3.F19.s. You won’t have to write the data allocation sections, some of the initializations, and the output loop at the end. So the...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If ( n is even) { n = n / 2; } else { n = 3 * n + 1; } In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the...