Question

In: Computer Science

What are these C Codes in MIPS? A[R[j]] = -645 -j /4 A[32] = R[9j] -...

What are these C Codes in MIPS?

A[R[j]] = -645 -j /4

A[32] = R[9j] - 4j


A base address -> s0
R base address -> s1
j -> t1

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.


A)

#A base address -> s0
#R base address -> s1
#j -> t1
div $t0,$t1,4 #get j/4
li $t2,-645
sub $t2,$t2,$t0 # get j/4 - 645

mul $t0,$t1,4 #get address of j
add $t0,$t0,$s1#get address of R[j]
lw $t0,($t0) #get value of R[j]

mul $t0,$t0,4 #get address of R[j]
add $t0,$t0,$s1#get address of A[R[j]]
sw $t2($t0) #get value of R[j]

B)

#A base address -> s0
#R base address -> s1
#j -> t1
mul $t0,$t1,9 #get 9j
mul $t0,$t0,4 #get address of 9j

add $t0,$t0,$s1 #get address of R[9j]
lw $t0,($t0)#get value of R[9j]
mul $t2,$t1,4 #get 4j
sub $t0,$t0,$t2 #get R[9j]-4j
sw $t0,128($s0) #store value at address A[32]


Related Solutions

Compile the following C code to MIPS assembly. a. Assume that i and j are stored...
Compile the following C code to MIPS assembly. a. Assume that i and j are stored in register $s1 and $s2, respectively. i = i – 2 + j; b. Assume base address of Array B and the variable i are stored in registers $s3 and $s1, respectively. B[1] = (B[0] x 4) - I; Explain each step in detail! my professor has the following answer: 1) addi $t0, $s1, -2 add $s1, $$t0, $s2 2) lw $t0, 0 ($s3)...
For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J-...
For the following MIPS instructions, (1) show its format or type (I-format, R- format, or J- format); (2) translate them into binary using the follow procedure (Note: $s0-$s7 are the 16-23th registers, $t0-$t7 are the 8-15th registers). For example, addi    $s0, $s1, 2               # the op code of addi is 0010002 Format (?): lw       $s1, 4($s1)               # the op code of lw is 1000112 Format (?): bne     $s1, $t1, loop           # the value of loop here is...
what is bahadur's 1961 representation r codes?
what is bahadur's 1961 representation r codes?
Convert these machine codes to MIPS instructions: Ox29210003, and Ox8e460002
Convert these machine codes to MIPS instructions: Ox29210003, and Ox8e460002
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4....
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4. T→¬B, T→¬D ∴ T→¬(B∨D) 5. ¬(M∨¬S), S→(R→M) ∴A → (¬R∨T) 6. (F&G) → I, (I∨J) → K ∴F→(G→K) 7. ¬U, O→G, ¬(O∨G) →U ∴G Prove that the arguments are valid by constructing a dedication using the rules MP, MT, DN, Conj, Simp, CS, Disj, DS, DM, CP, HS, BE, and DL. Use CP if needed.
what is the summary of On Fairy Stories, J. R. R. Tolkien?
what is the summary of On Fairy Stories, J. R. R. Tolkien?
g[8]=4[A[3j] + B[i+6j] I and j are variables. When doing MIPS instructions for above statement what...
g[8]=4[A[3j] + B[i+6j] I and j are variables. When doing MIPS instructions for above statement what needs to be done to 4[A[3j]? Choose your own temporary and store registers. Explain show step by step
Stet by step in R and attach R file and R codes too - Thanks Use...
Stet by step in R and attach R file and R codes too - Thanks Use one of the real-world example data sets from R (not previously used in the R practice assignment) or a dataset you have found, and at least two of the tests and R functions covered in the practice assignment to conduct a hypothesis test then report your findings and give proper conclusion(s). Use the following supporting materials for R syntax, data sets and tools, along...
4.Translate the following C code to MIPS assembly code. Assume that the value of i is...
4.Translate the following C code to MIPS assembly code. Assume that the value of i is in register $t0, and $s0 holds the base address of the integer MemArray if (i > 10) MemArray[i] = 0; else MemArray[i] = -MemArray[i]; 6.Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also, assume that register $s2 holds...
Write the MIPS assembly codes to implement the following function: copy a block of words from...
Write the MIPS assembly codes to implement the following function: copy a block of words from one address to another. Assume that the starting address of the source block be in register $t1 and that the destination address be in $t2. The instruction also requires that the number of words to copy in $t3 (which is >0, that means how many words are needed to copy). Furthermore, assume that the values of these registers as well as register $t4 can...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT