Let t0 0xFEDC4321 t1 0x9876ABCD and t2 AAAAAAAA Suppose t
Let $t0 = 0xFEDC_4321, $t1 = 0x9876_ABCD, and $t2 = AAAA_AAAA. Suppose the following sequence of instructions (below) is performed exactly four times, i.e., we execute instructions 1-4, we repeat executing instructions 1-4, we repeat executing instructions 1-4, we repeat executing instructions 1-4, and then we stop. Show the contents of $t0, $t1, $t2, and $t3, after we stop. Write your answers in hex.
[01] sll $t0, $t0, 1
[02] srl $t1, $t1, 1
[03] xor $t3, $t0, $t1
[04] nor $t3, $t2, $t3
[05] go back to line 1
Solution
The main purpose of a CPU is to execute instructions
The CPU executes the binary representation of the instructions, i.e., machine code.
Since programs can be very large, and since CPUs have limited memory, programs are stored in memory (RAM). However, CPUs do its processing on the CPU. So, the CPU must copy the instruction from memory to the CPU, and once it\'s in the CPU, it can execute it.
The PC is used to determine which instruction is executed, and based on this execution, the PC is updated accordingly to the next instruction to be run.
Essentially, a CPU repeatedly fetches instructions and executes them.
The following is a summary of the six steps used to execute a single instruction.
To fetch an instruction involves the following steps:
Step 2: Decode instruction and Fetch Operands
In the second step, the bits used for the opcode (and function, for R-type instructions) are used to determine how the instruction should be executed. This is what is meant by \"decoding\" the instruction.
Recall that operands are arguments to the assembly instruction.However, since R-type and I-type instructions both use registers, and those registers are in specific locations of the instruction, we can begin to fetch the values within the registers at the same time we are decoding.
In particular, we\'re going to do the following:
Step 3: Perform ALU operation
Step 4: Access memory
There are only two kind of instructions that access memory: load and store. load copies a value from memory to a register. store copies a register value to memory.
Any other instruction skips this step.
Step 5: Write back result to register file
At this point, the output of the ALU is written back to the register file. For example, if the instruction was: add $r2, $r3, $r4 then the result of adding the contents of $r3 to the contents of $r4would be stored back into $r2.The result could also be due to a load from memory.Some instructions don\'t have results to store.
Step 6: Update the PC
Finally, we need to update the program counter. Typically, we perform the following update:
PC <- PC + 4
Recall that PC holds the current address of the instruction to be executed. To update it means to set the value of this register to the next instruction to be executed.Unless the instruction is a branch or jump, the next instruction to execute is the next instruction in memory. Since each instruction takes up 4 bytes of memory, then the next address in memory isPC + 4, which is the address of the current instruction plus 4.The PC might change to some other address if there is a branch or jump


