Question

Assume that $s1 = 0x87654321. Determine the content of registers $s2 to $s4 after executing the...

Assume that $s1 = 0x87654321. Determine the content of registers $s2 to $s4 after executing

the following instructions:


sll $s2,$s1, 16 # $s2 =


srl $s3,$s1, 8 # $s3 =


sra $s4,$s1, 12 # $s4 =


Write a mips assembly language program to execute these instructions and verify the content of registers $s2 to $s4.

Homework Answers

Answer #1

1)

sll $s2, $s1, 16 => $s2 = $s1 << 16 => $s2 = 0x87654321 << 16 => $s2 = 0x4321

srl $s3, $s1, 8 => $s2 = $s1 >> 8 => $s2 = 0x87654321 >> 8 => $s2 = 0x00876543

sra $s4, $s1, 12 => $s2 = $s1 >> 12 => $s2 = 0x87654321 >> 12 => $s2 = 0xFFF87654

2)

MIPS PROGRAM :-

.data

.text

.globl main

main:

sll $s2, $s1, 16

addi $v0, $0, 1

add $a0, $0, $s2 #printing $s2

syscall

srl $s3, $s1, 8

addi $v0, $0, 1

add $a0, $0, $s3 #printing $s3

syscall

sra $s4, $s1, 12

addi $v0, $0, 1

add $a0, $0, $s4 #printing $s4

syscall

#system exit

addi $v0, $0, 10

syscall

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
Assume that $s1 = 0x87654321. Determine the content of registers $s2 to $s4 after executing the...
Assume that $s1 = 0x87654321. Determine the content of registers $s2 to $s4 after executing the following instructions: sll $s2,$s1, 16 # $s2 = srl $s3,$s1, 8 # $s3 = sra $s4,$s1, 12 # $s4 = Write mips assembly language program to execute these instructions and verify the content of registers $s2 to $s4. COMMENT COMPLETE CODE PLEASE
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i...
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i $s4 = address of ar[0] Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, and I are assigned to registers $s0 - $s3, respectively. Assume that the base address of arrays X, Y, and Z are in registers $s4 - $s6, respectively. Be conservative and use a single temp register as possible. It is a C arithmetic command with two source operands and a destination. Each part is 3 points. Add $t0, $s0, $s1 addi...
Let S = {s1, s2, s3, s4, s5, s6} be the sample space associated with the...
Let S = {s1, s2, s3, s4, s5, s6} be the sample space associated with the experiment having the following probability distribution. (Enter your answers as fractions.) Outcome s1 s2 s3 s4 s5 s6 Probability 3 12 1 12 4 12 1 12 2 12 1 12 (a) Find the probability of A = {s1, s3}. (b) Find the probability of B = {s2, s4, s5, s6}. (c) Find the probability of C = S.
After each step, give the value of the updated semaphore and the content of the updated...
After each step, give the value of the updated semaphore and the content of the updated semaphore queue. Counting Semaphores: S1, S2, S3 Binary Semaphores: S4, S5, S6 Semaphores initial values: S1 = 1,   S2 = 0,   S3 = 2,   S4 = 0,   S5 = 1,   S6 = 1 1) P1: P(S3) 2) P2: P(S5) 3) P3: P(S5) 4) P5: P(S2) 5) P2: V(S2) 6) P10: V(S6) 7) P2: P(S4) 8) P6: P(S5) 9) P4: V(S4) 10)P4: P(S2)
Suppose a MIPS processor uses the simple 5-stage pipeline described in the text, where the stages...
Suppose a MIPS processor uses the simple 5-stage pipeline described in the text, where the stages are instruction fetch, instruction decode and operand fetch, execute and calculate address, memory access, and register write. Suppose further that • There is a single memory for both instruction and data, which can only support one read or write each cycle. • There is no “forwarding” in the pipeline. Thus, if an instruction B relies on a value written into a register by an...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x - y[0] + y[1]; In memory x, y are stored beginning at 0x010000cc. Use registers $s1 for x,  and $s2 for the base address of y. Make sure your code includes all necessary declarations such that it could run in SPIM.
Consider the following C statement:           a = (b + d) + (b – c) +...
Consider the following C statement:           a = (b + d) + (b – c) + (c + d) Which of the following assembly instructions can be used to replicate all or part of this statement in MIPS, without changing or reducing the equation. Assume variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively. sub $t0, $s2, $s3 sub $t0, $s0, $s3 sub $t1, $s1, $s2 add $t2, $s1, $s3 add $t2, $s0,...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction and write the decimal values of each instruction field. addi $v0, $zero, 0 loop: lw $v1, 0($a0) sw $v1, 0($a1) sll $a0, $a0, 2 add $a1, $a1, $a0 beq $v1, $zero, loop 1b. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022 ori $t0, $t0, 2048 srl $t1, $t0, 18 sw $t0, 101($t1) slti $t2, $t1, 5 beq $t2, $0, label3 label2:... ... label3:... a) The code modifies a word in memory at the following address (circle one): (i) 1022 (ii) 101 (iii) 5 (iv) 10220000 (v) Other (provide your own answer): _________________ b) The following value is stored in memory (circle one): (i) 0x17 (ii)...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT