Documente Academic
Documente Profesional
Documente Cultură
07rrbb6
Basic Structure of Computers
2
Performance
Processor Clock
Basic Performance Equation
Clock Rate
Performance Measurement
Basic Operational Concepts
3
Arithmetic
Input and
logic
Memory
Output Control
I/O Processor
Instruction Execution
5
MAR MDR
Control
PC R0
ALU
Rn - 1
n general purpose
registers
Processor
Registers
8
In addition to the lines that carry the data, the bus must
have lines for address and control purposes.
Single-bus
Figure 1.3. Single-bus structure.
12
There are 2 types of Bus structures:
13
Bus control lines are used to arbitrate multiple requests for use of
the bus.
Advantages:
1) Low cost
1. Processor Clock
2. Basic Performance Equation
3. Clock Rate
4. Performance Measurement
The most important measure of a computer is how quickly it can
execute programs. Three factors affect performance:
Hardware design
Instruction set
Compiler
18
Main Cache
memory memory Processor
Bus
R = Clock rate.
R=1/P
T=(NXS)/R
is referred to as the basic performance equation.
24
n bits
Memory consists of first word
many millions of second word
storage cells, each
of which can store 1
•
bit. •
•
Data is usually
accessed in n-bit i th word
groups. n is called
word length. •
•
•
last word
33
b31 b30 b1 b0
•
•
•
Sign bit: b31= 0 for positive numbers
b31= 1 for negative numbers
1K(kilo)=210
1T(tera)=240
Memory-locations & Addresses
35
1. Byte addressability
3. Word Alignment
Word
address Byte address Byte address
0 0 1 2 3 0 3 2 1 0
4 4 5 6 7 4 7 6 5 4
• •
• •
• •
k k k k k k k k k k
2 -4 2 -4 2 -3 2- 2 2 - 1 2 - 4 2- 1 2 - 2 2 -3 2 -4
Byte contents in hex, starting at location 1000, will be 4A, 6F, 68,
6E, 73,6F,6E. The two words at 1000 and 1004 will be
6E686F4A and XX6E6F73.
3. Word alignment
41
4. I/O transfers
Instructions and Instruction Sequencing
46
Three-Address Instructions
ADD R2, R3,R1 R1 ← R2 + R3
Operation Source1, Source 2, Destination
Two-Address Instructions
ADD R2, R1 R1 ← R1 + R2
Operation Source, Destination
One-Address Instructions
ADD A AC ← AC + [A]
A processor register Accumulator is used for this purpose.
Problem
50
C[A]+[B]
51
1. Three address
Add A,B,C
2. Two address
Move B,C
Add A,C
3. One address
Load A
Add B
Store C
1.
Problem
Give a short sequence of machine instructions for the task: “Add
the contents of memory location A to those of location B and place
the answer in location C”.
a) Only Load LOC, Ri , Store Ri, LOC and Add are available
52
Solution
53
Shorter instructions
Address Contents
i
Assumptions:
Begin execution here Move A,R0
3-instruction - One memory operand
i+4 Add B,R0 program
segment per instruction
i+8 Move R0,C
- 32-bit word length
- Memory is byte
addressable
A - Full memory address
can be directly specified
in a single-word instruction
B Data for
the program
Two-phase procedure
- Instruction fetch
- Instruction execute
C
•
•
•
SUM
NUM1
NUM2
•
•
•
NUMn
•
•
•
SUM
N n
NUM1
NUM2
•
•
•
NUMn
Consider the task of adding a list of ‘n’ numbers.
63
4. Relative addressing
5. Additional modes
1. Implementation of variables and constants
70
Move #200,R0
A=B+6
Move B,R1
Add #6,R1
Move R1,A
2. Indirection and Pointers
73
Add (R1),R0
Add (A),R0
75
B Operand
R1 B Register
Program :-Sum of N numbers using Indirect addressing
76
77
Add 20(R1),R2
1000 1000 R1
20=offset
1020 Operand
Indexed Addressing: Offset is in the index register
82
Add 1000(R1),R2
1000 20 R1
20=offset
1020 Operand
Example:-
83
.
.
.
Program:-
85
Variations of Index Mode
86
Branch>0 LOOP
Move N,R1
Clear R0
Decrement R1
Branch>0 LOOP
Move R0,SUM
92
A complete set of such symbolic names and rules for their use
constitute a programming language, referred to as an assembly
language.
94
1. Assembler Directives
3. Number Notation
1. Assembler Directives
97
Ex: SUM EQU 200; informs assembler that the name SUM
should be replaced by the value 200.
98
END directive tells the assembler that this is the end of the
source-program text.
Add #93,R1
(Ex:- 1010 - A)
Basic Input/output Operations
108
111
Processor
DATAIN DATAOUT
SIN SOUT
keyboard Display
Input:
•When a key is struck on the keyboard, an 8-bit character code is stored in the buffer
register DATAIN.
•A status control flag SIN is set to 1 to indicate that a valid character is in DATAIN.
•A program monitors SIN, and when SIN is set to 1, it reads the contents of DATAIN.
•When the character is transferred to the processor, SIN is automatically cleared.
•Initial state of SIN is 0.
Bus
112
Processor
DATAIN DATAOUT
SIN SOUT
keyboard Display
Output:
•When SOUT is equal to 1, the display is ready to receive a character.
•A program monitors SOUT, and when SOUT is set to 1, the processor transfers a
character code to the buffer DATAOUT.
•Transfer of a character code to DATAOUT clears SOUT to 0.
•Initial state of SOUT is 1.
113
MoveByte DATAIN,R1
116
Testbit #3,INSTATUS
117
Stacks
118
Subtract #4, SP
Add #4, SP
121
Suppose that a stack runs from location 2000 (BOTTOM) down no
further than location 1500.
122
Suppose that a stack runs from location 2000 (BOTTOM) down no
further than location 1500.
123
Queue
124
1) One end of the stack is fixed while the other end rises and
falls as data are pushed and popped.
2. Parameter Passing
3. Stack Frame
1. Subroutine Nesting And The Processor Stack
132
The return-address needed for this first return is the last one
generated in the nested call sequence. That is, return-addresses
are generated and used in a LIFO order.
The work-space is
Move FP,-(SP)
Move SP,FP
The local variables may now be pushed onto the stack. Space
for local variables is allocated by executing the instruction
Subtract #12,SP
142
Add #12, SP
And subroutine pops saved old value of FP back into FP. At this
point, SP points to return-address, so the Return instruction can
be executed, transferring control back to the calling-program.
Additional Instructions
143
1. Logic Instructions
Logical Shifts
Arithmetic Shifts
Rotate Operation
(a) Logical Shift left LShiftL #2,R0 (b)Logical Shift right LShiftR #2,R0
Arithmetic Shifts
147
Rotate Operation
148
#2,R0 #2,R0
#2,R0 #2,R0
3. Multiplication and Division
149
Multiply Ri, Rj
Rj ← [Ri] х [Rj]
Divide Ri, Rj
Rj ← [Ri] / [Rj]
Encoding of Machine Instructions
150
The instruction
Add R1, R2
The instruction
Move 24(R0), R5