---
# System prepended metadata

title: NTUST_1102_計算機組織小考

---

# NTUST_1102_計算機組織小考
## Quiz 1
- Assume for arithmetie, load/store, and branch instructions, a processor has CPIs of 2, 8, and 4, respectively. Also assume that a program requires the execution of 2.4E9 arithmetic instructions, 600 million load/store instructions, and 200 million branch instructions, Assume that the processor has a 4 GHz clock frequency.
    - a. Find the total execution time for this program.
    - b. Find the average CPI for the program.
    - c. By how much (%) is the total time reduced if the time for arithmetic instructions is reduced by 20%?
    - d. By how much (%) is the time for load/store instructions reduced if the total time is reduced by 30%? Note that the time for other instructions are not changed.
    - e. Can the total time be reduced by 20% by reducing only the time for branch instructions?
## Quiz 2
- For the following C statement, what is the corresponding MIPS assembly code?Assume that the variable f is assigned to register $s0. Assume that the baseaddresses of the arrays A and B are in registers $s3 and $s4, respectively. B[12]=f+A[8]-3
- Provide the type, assembly language instruction, and hexadecimal representation of instruction described by the following MIPS fields:
    - (a) op = 0, rs = 9, rt =17, rd = 8, shamt = 0, funct = 34
    - (b) op = 0x23, rs = 19, rt = 18, const = 20
## Quiz 3
- assume that registers $s0 and $s1 hold the sales 0X64000100 and 0xA0100840, respectively. Please answer the following questions in hexadecimal.
    - (a) (25%) What is the value of $t0 for the following assembly code?
      and $t0, $s0, $s1
    - (b) (25%) What is the value of $t0 for the following assembly code?
      srl $t0, $s0, 3
- (50%) Translate the following C code to MIPS assembly code. Assume that the values of a, and i are in registers $s0 and $s1, respectively. Also, assume that register $s2 holds the base address of the array D.
  ![](https://i.imgur.com/CWoEgkG.png)

## Quiz 4
- Assume that this segment of MIPS instructions starts at memory location 80000![](https://i.imgur.com/6RwvsbG.png)
    - (1) (30%) For instructions (a) • (b), show the value (or n.a.) of each field in the following table. (In decimal). (Opcode : bne = 5, jump = 2)
        - a. bne $t0, $zero, Exit
        - b. j Loop
    - (2) (20%) For instructions (a) • (b), translate them into binary machine codes.
        - a. bne $t0, $zero, Exit
        - b. j Loop
- (50%)Implement the following C code in MIPS assembly.
    - ![](https://i.imgur.com/3qw2y4q.png)
