Professional Documents
Culture Documents
Computer Architecture
• Instruction Set
• Control architecture
• Instruction processing
– Register access
– Memory access (Direct, Indirect)
– I/O access
– Interrupts
• Timing sequences of microoperations
Considering the next problem in design
15 14 12 11 0
IR
I OpCode Address / OpCode extension bits
Instruction Hierarchy
• Mano’s instruction set consists of 25 instructions:
Instruction
• Comments
– Begin with a slash ‘/’ character !
– All characters after the slash are part of the comment
– Comments are terminated by the new line character(s) !
– May be preceded by white spaces.
– Suggestions:
• SUB :: Subtraction
• MUL :: Multiplication
• DIV :: Integer division
• MOD :: Modular division (remainder)
• LAD :: Load specified address location to AC
• LDT :: Load Temporary Register (TR) from AC
• CPS :: Copy string from address in TR to specified address location,
number of words to move in AC. Both AR and TR are incremented by one
for each word copied.
• CMP :: Compare AC with value at specified address, need to create status
flags – Z (zero), P (positive), N (negative)
• SHR :: Shift AC right arithmetically
• SHL :: Shift AC left arithmetically
• Assembler requirements:
– Location Counter (LC)
– Symbol Table
– Recognition of OpCodes
– Recognition of Pseudo-Instructions
– Recognition of Comments
– Detection and Definition of User-Defined Symbolic
Addresses
– Detection and Resolution of User-Defined Symbolic
Address References
– Multiple passes through program source code
– Production of Object Code (ie. machine code)
Assembler Flowchart – Pass 1
First pass
LC = 0
yes no
…
LABELn LCn
Store symbol in
Symbol Table
together with END
value of LC no
yes
Must be a machine,
LC = LC + 1 DEC or HEX
instruction
Go to second pass
Assembler Flowchart – Pass 2
Second pass
LC = 0
yes yes
yes no
Pseudo ORG END
no no DEC/HEX
LC = LC + 1
no no Convert operand to
MRI nonMRI binary and store at
location LC
yes yes
Translate
instruction Store binary
components, translation of
compile to binary instruction at
and store at location LC Error in
location LC code
Assembler Flowchart – Pass 2
Second pass
LC = 0
yes yes
yes no
Pseudo ORG END
no no
LC = LC + 1
no no Convert operand to
MRI nonMRI binary and store at
location LC
yes yes
Translate
instruction Store binary
components, translation of
compile to binary instruction at
and store at location LC Error in
location LC code
Assembler Flowchart – Pass 2 (MRI)
Translate Parse
instruction OpMnemonic and
components, convert to binary,
compile to binary set bits 12-14
and store at
location LC
Parse operand
symbol, search
Symbol Table and
convert LC value
to bits 0-11
yes I no
• Decision no yes
no
C C
yes
– If-then SF ST
S
– If-then-else
• Repetition (loops)
no
– While-do C S
(For-until-do) yes
S C
yes
– Do-while
no
Program Example 1A: Decision
SF ST
Program Example 1B: Decision
yes
C
no
Program
ORG 0 Example 1C: Loops
LDA N /PREPARE COUNT VARIABLE
CMA
• INC
A simple counting
STA N
loop to find the sum of a list of N
integers. SPA /TEST IF N>0
BUN CON / OTHERWISE, BYPASS LOOP
LOP, LDA SUM /BEGIN LOOP S
ADD VP I /Note use of indirect mode
STA SUM C
ISZ VP /Increment V-pointer yes
ISZ N /N=N+1, EXIT LOOP IF N=0
BUN LOP /BRANCH TO LOOP BEGIN no
CON, HLT /CONTINUE PROGRAM
N, DEC 5
SUM DEC 0
VP, HEX 20 /ADDRESS OF V
ORG 20
V, DEC 5 /VECTOR OF INTEGERS
DEC 15
DEC 10
DEC 8
DEC 17
END
ASSEMBLER – PASS 2
Program Example 1C: Loops
ASSEMBLER – PASS
ORG 10
LC OBJ SYM INSTR
--- ---- --- ----
LC SYM INSTR
--- --- ---- LDA N /PREPARE COUNT VARIABLE ORG 0
ORG CMA
0 000 200D LDA N
• A simple counting loop to find the sum of a list of N
000 LDA INC
N 001 7200 CMA
001 CMA STA N 002 7020 INC
integers.
002 INC SPA /TEST
SYMBOL IF
LCN>0 003 300D STA N
003 STA BUN
N CON /
CON OTHERWISE,
00C 004 7010
BYPASS LOOP SPA
004 SPA LDA SUM
LOP, /BEGIN
LOP LOOP
006 005 400C BUN CONS
005 BUN ADD
CON VP I /Note
N 006 200E LOP, LDA SUM
00D of indirect
use 007 mode
9009 ADD VP I
006 LOP, LDA SUM V 020
007 STA
ADD VP I SUM 008 300E STA SUMC
VP 00F yes VP
008 STA ISZ
SUM VP /Increment V-pointer
009 600F ISZ
009 ISZ ISZ
OBJECT VP N (LD /N=N+1,
FILE: PT 000) EXIT LOOP
LENGTH 37 IF 600D
N=0
00AWORDS (HEX 25)ISZ N
00A ISZ BUN
N LOP /BRANCH TO LOOP 00B
BEGIN 4006 BUN LOP no
00B CON,
BUN HLT
LOC HEX CODE /CONTINUE PROGRAM
LOP 00C 7001 CON, HLT
00C CON,
N, HLT DEC
--- 5
-------- 00D 0005 N, DEC 5
00D N, SUMDEC DEC
000 5
200D0 7200 7020 300D 7010 000C00E200E
0000
9009 SUM DEC 0
00E SUM HEX
008 DEC200
300E 600F 600D 4006 7001 00F 0020 VP, HEX 20
VP, /ADDRESS OF V 0005 0000 0020 ORG 20
00F VP, 010
HEX 20
0000200000 0000 0000 0000 0000 0000 0000
ORG 0200000
0005
ORG 20
018 0000 0000 0000 0000 0000 0000 0000V, DEC 5
020 V, V, DEC DEC
020 5 5 /VECTOR OF INTEGERS
0005 000F 000A 0008 0011 021 000F DEC 15
021 DEC DEC
15 15 022 000A DEC 10
022 DEC DEC
10 10 023 0008 DEC 8
023 DEC DEC
8 8 024 0011 DEC 17
024 DEC DEC
17 17 025 END
END END
LENGTH=37 WORDS
Program Example 2: Multiplication (0)
• We consider a typical problem of multiplying two integer values.
• Must also take into account the very real possibility that the product will
overflow the accumulator register
• An alternative approach
– Use simple properties of radix-2 (binary) multiplication
– More efficient (fixed time complexity)
P = 1+2+4+8+128=143 as expected.
Program Example 2: Multiplication (5)
ORG 0
BUN MUL
C, DEC -4 /COUNTER
M, DEC 13 /MULTIPLICAND
N, DEC 11 /MULTIPLIER
P, DEC 0
T, DEC 0 This can be further
MUL, LDA M /INITIALIZE SHIFTER T extended for use as a
STA T subroutine,
CHN, LDA N /TEST LOW ORDER BIT OF N reinitializing the
CLE counter and passing
CIR new values M and N
SZE /IF BIT IS ZERO DO NOTHING
BUN AD / OTHERWISE, ADD SHIFTER
each time.
BUN BY Also, sign checking
AD, LDA P /ADD SHIFTER TO PRODUCT
ADD T
can be incorporated.
STA P /STORE PRODUCT
BY, LDA T /SHIFT SHIFTER LEFT
CLE
CIL
STA T /STORE SHIFTER UDPATE
ISZ C /INCREMENT COUNTER, IF ZERO STOP
BUN CHN / OTHERWISE, REPEAT LOOP AT CHN
HLT
END
Example 3: Double-Precision Addition (0)
0001 0110
0000 0001
0001 0001
0000 0000 0110
Example 3: Double-Precision Addition (1d)
0000 0001
Use Masks to retain and clear bits. Shift high order part right four times.
Example 3: Double-Precision Addition (1e)
0000 0001
0000 0001
0001 0110
COMPLEMENT
0000 0001 COMPLEMENT 1111 1001 0000 0110
1110 1001 1110 1111 0001 0000
AND
0001 0110
CARRY 0000 0001
Example 3: Double-Precision Addition (2)
0001 0110
CARRY 0000 0001
Example 3: Double-Precision Addition (2a)
0001 0110
Example 3: Double-Precision Addition (2b)
0000 1110
Example 3: Double-Precision Addition (2c)
0000 0000
1110 1110 0000 1110
1111 0001
0000 1110 0000 1110
1001 0001
1001 1111
0110 0000 0000 0110
And Complement again
Complement and AND
Example 3: Double-Precision Addition (3)
– Must design a strategy for passing data to and from the subroutine,
regardless of which instruction invokes it.
• Copy two integers
• Return one integer
– Must be able to access the passed data from within the subroutine.
• Use pointer technique
Note that AC is
ONLY modified SL4, HEX 0 /RETURN ADDRESS
in bits 0-7 (low CIL
Requires that
order) by INP. CIL
AC is NOT
CIL
modified by the
CIL
call to SL4.
AND ML4
BUN SL4 I /RETURN
ML4, HEX FFF0
Example 5: Input/Output (4)
• The Hardware:
R
T0’
T1’
T2’
IR
AC(H) AC(L)
PC TR
IEN
AR
INPR FGI CPU
Control
OUTR FGO Unit ION IOF
(IEN=1/0)
INP OUT
Device Device
Data Control SKI SKO
Interface Interface
Example 6: Interrupt Handling (3)
• Assembly language
• Assembler
– One-pass
– Two-pass
• Language extensions
• Example assembly language programs
• Towards conclusion
– A glimpse at future topics to study and consider in Digital Design
and Computer Architecture
End of Formal Lectures
• Future topics in
– Digital Design
• Minimization of logic circuit complexity (Quine-McCluskey-
Petrick)
– Computer Architecture
• Expanding memory address space
• Expanding CPU register set
• Extending the instruction set, number of operands, addressing
modes
• Multiprocessors
– Multi-core processing (inline channel parallelism)
– SMP – Symmetric Multi-Processing
– Multiple CPUs, Memories
– Complex bus architectures
• Extending Input and Output capabilities
Summary of Goals
• Course: 60-265 Digital Design & Computer Architecture
• Concepts
– Design, Integration, Boolean Algebra/Calculus, Optimization, Hardware constraints,
Control, Machine language
• Skills
– Technical : Circuit design, circuit optimization, comprehension of machine specifications
– Analytical : Boolean Algebra, intricacies of circuits
• Understanding
– Computer and Information Scientists should understand the precise nature and
limitations of the machines used to run software and be guided in this knowledge
– The concepts and techniques of Boolean Logic used in this context also apply in every
aspect of information processing.
• Application
– Group Project invested significant time and skill in developing a complete computer
design architecture for a challenging, complete machine specification.
• Professional Development
– Individual & Team qualities were challenged and improved through interaction that
emphasized consensus building, decision making, discipline, project and team
management, and deliverables.
Postscript
• I hope
– You have enjoyed the lectures
– What you have learned will provide a stronger foundation
for deeper understanding.