Class Notes (1,100,000)
CA (630,000)
UTSG (50,000)
CSC (1,000)
Lecture

CSC258H1 Lecture Notes - Arithmetic Shift, Bitwise Operation, Machine Code


Department
Computer Science
Course Code
CSC258H1
Professor
Steve Engels

This preview shows half of the first page. to view the full 1 pages of the document.
Week 10 review
o Q1 What signals would the control unit turn on and off in order to
load a memory value into $t0
PCWrite = 0, PCWriteCond = 0
IorD = 1
MemRead = 1, MemWrite = 0
MemtoReg = 1
IRWrite = 0
PCSource = x
ALUOp = 001 (add)
ALUSrcA = 0, ALUSrcB = 2
RegWrite = 1, RegDst = 0
o Q2 What are the following assembly language instructions doing?
sub $t7, $t0, $t1
Subtract register $t1 from $t0
place the result into $t7
andi $t7, $t0, 15
Bitwise AND between register $t0 and 15 (11112)
place the result into $t7
sra $t2, $t1, 2
2 bits arithmetic shift of register $t1 to the right
place the result into $t2
o Q3 How do you translate the assembly language instruction
add $t7, $t0, $t1 into machine code?
#1. Identify instruction type: r-type instruction
<opcode> <rs> <rt> <rd> <shamt> <funct>
#2. The opcode
For R-type, the opcode = 000000
#3. The function code (R-type only)
add = 100000
#4. The Register values translate register variables into values
Source registers: $t0 = register 8 = 01000
$t1 = register 9 = 01001
Destination register: $t7 = register 15 = 01111
add $t7, $t0, $t1 in machine code is:
000000 01000 01001 01111 XXXXX 100000
o Q4 same as mar25ce review question
You're Reading a Preview

Unlock to view full version