CS代考 – cscodehelp代写

R-Type Instructions
By Christopher Mar

Announcements
Module 2 now available
Project 2 Pre Quiz due 9/12
Project 2 Program and Post Quiz due 9/19

Project 2 Demo

Load word copies value from memory to a register
lw \$t3, 0(\$t4)
Destination

Lecture Question
A load word instruction can be used to…
Read a value from an I/O device
Write a value to an I/O device
Not enough information is given to answer this question

I/O Device: Switches

I/O Device: Switches
Each switch corresponds to a specific bit of a single value
Value located at the address, 0xf0100000

I/O Device: Switches
Each switch controls a bit position that is a representation of a power of 2
Switch 0 represents 20 (= 1)
Switch 1 represents 21 (= 2)
Switch 2 represents 22 (= 4)
Continues to switch 7 (27 = 128)

I/O Device: Switches
For example, what will the value at the switch address be if switches 0, 3, and 5 are set?
20 + 23 + 25 =
1 + 8 + 32 =

Lecture Question
Suppose switches 1, 2, and 6 are set. What will be the value at the switch address?

Lecture Question
If \$t5 contains 0xf0100000, which instruction would copy the current value of the switches into \$t6 (which currently contains zero)?
sw \$t5, 0(\$t6)
sw \$t6, 0(\$t5)
lw \$t5, 0(\$t6)
lw \$t6, 0(\$t5)

I-Type vs. R-Type Instructions
I-Type Instructions
Output destination:
1 register
1 immediate value
R-Type Instructions
Output destination:
2 register
Exception:
Shift instructions use one register and a shift amount (shamt)

Equivalent to the assignment statement:
\$t3 = \$t2 + 29