Question: Sample 1: Logical Operations. Check the examples done in class during the lecture. ? How you isolate a specific field ? How you set fields
Sample 1: Logical Operations. Check the examples done in class during the lecture. ? How you isolate a specific field ? How you set fields to 0 ? How you mask fields ? How you complement fields ..
Sample 2: Given a high-level code you should be able to write the corresponding MIPS assembly code. Simple loop in C; A[ ] is an array of ints do { g = g + A[i]; i = i + j; while (i != h) } Rewrite this as: Loop: g = g + A[i]; i = i + j; if (i != h) goto Loop; Using the mapping: g: $s1, h: $s2, i: $s3, j: $s4, base of A: $s5; write the corresponding assembly instructions.
Sample 2B (SP16) Considering the following MIPS code: begin: addi $t0, $zero, 22 move $t1, $zero li $a0, 0 loop: beq $t0, $t1, finish add $t1, $t1, $a0 addi $t0, $t0, -4 addi $a0, $a0, 1 j loop finish: a. Explain the meaning of each instruction by inserting (inline) comments b. Give a possible high-level pseudo-code for the above MIPS code. c. What is the value of $t0 when the program reaches finish? d. What is the value of $a0 when the program reaches finish?
Sample 3: Suppose that register $t0 contains 0x00001000. What is the value of $t2 after: slt $t2, $t0, $t0 bne $t2, $zero, ELSE j DONE ELSE: addi $t2, $t2, 2 DONE:
Sample 4: add $t0, $zero, $zero addi $a0, $zero, 21 loop: beq $a0, $zero, end add $t0, $t0, $a0 addi $a0, $a0, -3 j loop end: For beq $a0, $zero, end give the binary value of the offset field. Briefly explain.
Sample 5: Given the assembly instruction: bne $s0, $s1, DONE The address of the instruction is 500bytes. If the offset field contains the following value: 11111111111101002, what is the target address? Explain your answer.
Sample 6: Consider you have a function FUN that calls TOYS. TOYS takes 2 parameters in (A and B) and returns 1 parameter to FUN (C). Write the necessary code for handling the stack and keeping track of the parameters (the prologue and the epilogue). Explain your answer by commenting it. Follow the Jack and Jill example.
Sample 7: Write a MIPS program (runnable) that will do the following: Prompt the user to enter a first integer Prompt the user to enter a second integer Compute the sum of the two mentioned integers Print the value of the result Sample 8: you might be asked to write a basic recursive function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Name Register Number Usage Preserve on call? $zero 0 constant 0 (hardware) n.a. $at 1 reserved for assembler n.a. $v0 - $v1 2-3 returned values No $a0 - $a3 4-7 arguments Yes $t0 - $t7 8-15 temporaries No $s0 - $s7 16-23 saved values Yes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
