程序代写代做 computer architecture C assembler assembly CS 3340 Computer Architecture – Exam 1 Review

CS 3340 Computer Architecture – Exam 1 Review

Exam overview:
• eLearning timed on-line test during class time (Monday 6/15 12:30 to 1:45)
• Time allowed is 75 minutes, test automatically closes at the end of time
• Multiple attempts are not allowed
• Questions are randomly drawn from pools
• Questions are presented one at a time
• Backtracking is prohibited
• Hit the Save Answer button each time (just to be sure)
• If you click anything in the left pane on eLearning it will prompt you if you want to leave; don’t leave!!!

Exam details:
• Reference sheets (last 2 pages on this review) should be used
• Exam has 28 questions:
• 5 8-point short coding questions
• convert a c expression or short function to MIPS
• convert machine code (hex) to a MIPS instruction
• convert a MIPS instruction into machine code (binary and hex)
• convert two small integers to binary and add (one will be negative)
• 2 3-point very short coding questions
• write MIPS integer mul, mult, and div instructions
• 6 3-point MC questions where you answer questions about a program
• what the program does
• purpose of individual instructions in the program
• how registers are used
• 6 3-point MC questions about MIPS coding
• destination and source registers by instruction type (R, I, J)
• understanding short code segments
• instructions v. pseudo instructions v. assembler directives
• 9 2-point MC and TF questions about MIPS coding
• addressing modes
• push and pop
• using ori and andi to set bits to 0 or 1
• how ja and jr $ra work
• some terminology from section 1.1 – 1.5

Academic integrity issues:
• You will be taking the test online in your own space with the assumption that you are not violating academic integrity
• Cheating hurts everyone because employers need to know when they hire a UTD grad that the degree means something
• If you are aware of anyone cheating or posting questions/answers on GroupMe or elsewhere, you can take a screen shot and sent it to my email; I will respect your anonymity

Here are some practice questions.

1. Write the following C code in MIPS assembler:

x = x + y + z – q;

Assume that x, y, z, q are stored in registers $s1-$s4.

2. Write the following C code in MIPS assembler using $t1-$t3 for a, b, c:

if (a < b) c = b else c = a // assume values already in registers 3. Convert the C function below to a MIPS assembly language subroutine. Then write code that calls the subroutine (assuming that n is already in $a0) and stores the return value $v0 in memory location 'result'. int func(int n) { if (n == 0) return 0; else return n - 1; } 4. Write instructions to push $so on to the stack. 5. Write instructions to pop $s0 off the stack. • Convert -67 and 42 into binary, using two’s decimal representation for the negative number. Add the numbers. Convert the result back to decimal. Show all your work. 7. (a) Fill in the immediate field in the ORI instruction below to force bits 5 and 7 of $t0 to be 1, while leaving all other bits unchanged. ORI $t0, $t0, 0x_________________ (b) Fill in the immediate field in the ORI instruction below to force bits 5 and 3 of $t0 to be 0, while leaving all other bits unchanged. ANDI $t0, $t0, 0x________________ 8. What does the following code do? Rewrite the code using sll instead of add. add $t0, $t0, $t0 9. Write MIPS code to implement the following loop: for (i=0; i<3;i++) array[i] += 3; // assume address of array is in $s6, and $s3 = i which is initialized to zero 10. For each addressing mode, write a sample instruction using that mode. 11. (a) What is this MIPS statement: 0x012b8022 (b) Convert the following MIPS statement to machine/hex code: or $s0, $t2, $t5 12. Implement C expressions with mult/div integer instructions. c = 10*a – (b * c) Also: • Review your homework and make sure you understand the code • Review terminology from the textbook readings (1.1-1.5) 
 Reference: