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

29 views1 pages
Published on 20 Apr 2013
School
UTSG
Department
Computer Science
Course
CSC258H1
Professor
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
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)
#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
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.