21css201t Coa Unit 2 Notes
21css201t Coa Unit 2 Notes
ORGANIZATION AND
ARCHITECTURE
UNIT – 2
Functional Units of a Computer
Computer:
It is defined as a fast electronic calculating
machine that accepts digitized input
information , processed it according to
internally stored instructions , and produces
the resulting output information.
The list of instructions is called program.
The internal storage is called as memory.
Types of Computer: - usage
1.Personal computer – homes, schools, business
2.Desktop computer – homes and office desk
3.Notebook computer – all components packed into
briefcase - compact size – schools , offices
4.Workstations – engineering applications ,
interactive design work
5.Mainframes – supercomputers - used in
enterprises
FUNCTIONAL UNITS OF COMPUTER
• Input Unit
• Output Unit
• ALU
• Control Units
• Memory
The Big Picture
Processor
Input
Control
Memory
ALU
Output
OUTPUT UNIT:
T1 Enable R1
T2 Enable R2
T4
•Control unit works with a
reference signal called
T1
processor clock
R1 R2
•Each basic step is
executed in one clock
cycle
R2
MEMORY
•Two types are RAM or R/W memory and ROM read only memory
•ROM is used to store data and program which is not going to change.
0 0 0 0th Location
0 0 1 1st Location
0 1 0
W/R
CS RD 0 1 1
A0 PROCESSOR
A1 1 0 0
A2
1 0 1
ADDRESS BUS
1 1 0
D7 D0
D0 D7
1 1 1
DATA BUS
Cont:-
last word
• 8000 54
• 8001 96
• 8002 78
• 8003
46
• 8004
|
Big Endian
• Big Endian (e.g., in IBM, Motorolla, Sun, HP)
» high order byte stored at lowest address
» byte3 byte2 byte1 byte0
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
• R2 [LOCN]
• R4 [R3] +[R2]
ASSEMBLY LANGUAGE NOTATION (ALN)
}
Begin execution here i Move A,R0
i+4 Add B,R0
3-instruction program
i+8 Move R0,C
. segment
.
.
A
.
.
.
C
• PC – Program counter: hold the address of the next
instruction to be executed
• Straight line sequencing: If fetching and executing of
instructions is carried out one by one from successive
addresses of memory, it is called straight line sequencing.
• Major two phase of instruction execution
• Instruction fetch phase: Instruction is fetched form
memory and is placed in instruction register IR
• Instruction execute phase: Contents of IR is decoded and
processor carries out the operation either by reading
data from memory or registers.
BRANCHING
B: 0 0 0 1 0 1 0 0 11011101
C=1 Z=0
V=0
Overflow occurs when the magnitude of a
number exceeds the range allowed by the size of
the bit field
Status Bits
Cn-1
A B
Cn ALU
F
V Z S C
Fn-1
Zero Check
Figure Format and different instruction types
Processing the instructions
Simple computer, like most computers, uses machine cycles.
During the execute phase, the instruction is executed and the results are
placed in the appropriate memory location or the register.
Once the third phase is completed, the control unit starts the cycle again,
but now the PC is pointing to the next instruction.
The process continues until the CPU reaches a HALT instruction.
Types of Addressing Modes
The different ways in which the location of the operand is specified in an
instruction are referred to as addressing modes
• Immediate Addressing
• Direct Addressing
• Indirect Addressing
• Register Addressing
• Register Indirect Addressing
• Displacement addressing
1.Relative Addressing
2.Indexed Addressing
3.Base Register addressing
• Stack addressing mode
1.Auto increment
2.Auto decrement
NOTATIONS USED IN ADDRESSING
MODES
A- contents of an address field in an instruction.
R- contents of an address field in an instruction
that refers to a register.
EA-Actual effective address of the location
containing the referenced operand.
(X)- contents of the memory location X or
register X
Immediate Addressing
• Operand is given explicitly in the instruction
• Operand = Value
• e.g. ADD 5
– Add 5 to contents of accumulator
– 5 is operand
• No memory reference to fetch data
• Fast
• Limited range of size of the operand.
Instruction
opcode
operand
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
Indirect Addressing
• Memory cell pointed to by address field
contains the address of (pointer to) the
operand
• EA = [A]
– Look in A, find address (A) and look there for
operand
• e.g. ADD (A)
– Add contents of cell pointed to by contents of A to
accumulator
Indirect Addressing
• Large address space
• 2n where n = word length
• May be nested, multilevel, cascaded
– e.g. EA = (((A)))
• Draw the diagram yourself
• Multiple memory accesses to find operand
• Hence slower
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Register Addressing
• Similar to direct addressing mode
• Operand is held in register named in address
field
• EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
Register Addressing
• No memory access
Operand
Register Indirect Addressing
• Similar to indirect addressing
• EA = [R]
• Operand is in memory cell pointed to by
contents of register R
• Large address space (2n)
• One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram
Instruction
Opcode Register Address R
Memory
Registers
Registers
1
Microprocessor Fifth Generation Pentium
Fourth Generation
During 1980s
Low power version of HMOS technology
(HCMOS)
Third Generation 32 bit processors
During 1978 Physical memory space 224 bytes = 16 Mb
HMOS technology Faster speed, Higher Virtual memory space 240 bytes = 1 Tb
packing density Floating point hardware
16 bit processors 40/ 48/ 64 pins Supports increased number of addressing
Easier to program modes
Dynamically relatable programs
Processor has multiply/ divide arithmetic Intel 80386
hardware
More powerful interrupt handling
capabilities Second Generation
Flexible I/O port addressing During 1973
NMOS technology Faster speed, Higher
Intel 8086 (16 bit processor) density, Compatible with TTL
4 / 8/ 16 bit processors 40 pins
First Generation Ability to address large memory spaces
Between 1971 – 1973 and I/O ports
PMOS technology, non compatible with TTL Greater number of levels of subroutine
4 bit processors 16 pins nesting
8 and 16 bit processors 40 pins Better interrupt handling capabilities
2
Due to limitations of pins, signals are
multiplexed Intel 8085 (8 bit processor)
Functional blocks
Various conditions of the
Computational Unit;
results are stored as
performs arithmetic and Internal storage of data
status bits called flags in
logic operations
flag register
20-bit address to access memory can address up to 220 = 1 megabytes of memory space.
Addressable memory space is organized in to two banks of 512 kb each; Even (or lower) bank
and Odd (or higher) bank. Address line A0 is used to select even bank and control signal BHE is
used to access odd bank
Uses a separate 16 bit address for I/O mapped devices can generate 216 = 64 k addresses.
Operates in two modes: minimum mode and maximum mode, decided by the signal at MN and
MX pins. 4
Pins and signals
8086 Microprocessor
Common signals
AD0-AD15 (Bidirectional)
Pins and Signals
Address/Data bus
MN/ MX
MINIMUM / MAXIMUM
TEST
Pins and Signals
𝐓𝐄𝐒𝐓 input is tested by the ‘WAIT’
instruction.
READY
RESET (Input)
Pins and Signals
Causes the processor to immediately
terminate its present activity.
CLK
10
8086 Microprocessor: Architecture
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Tarp Flag
Over flow Flag If this flag is set, the processor
This flag is set, if an overflow occurs, i.e, if the result of a signed enters the single step execution
operation is large enough to accommodate in a destination
mode by generating internal
register. The result is of more than 7-bits in size in case of 8-bit
signed operation and more than 15-bits in size in case of 16-bit interrupts after the execution of
sign operations, then the overflow will be set. each instruction
Direction Flag Interrupt Flag
This is used by string manipulation instructions. If this flag bit
is ‘0’, the string is processed beginning from the lowest Causes the 8086 to recognize
address to the highest address, i.e., auto incrementing mode. external mask interrupts; clearing IF
Otherwise, the string is processed from the highest address 12
disables these interrupts.
towards the lowest address, i.e., auto incrementing mode.
8086 Microprocessor: Architecture Registers
8086 registers
categorized 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
into 4 groups OF DF IF TF SF ZF AF PF CF
AX 16-bit Accumulator Stores the 16-bit results of arithmetic and logic operations
AL 8-bit Accumulator Stores the 8-bit results of arithmetic and logic operations
BX Base register Used to hold base value in base addressing mode to access
memory data
CX Count Register Used to hold the count value in SHIFT, ROTATE and LOOP
instructions
DX Data Register Used to hold data for multiplication and division operations
SP Stack Pointer Used to hold the offset address of top stack memory
BP Base Pointer Used to hold the base value in base addressing using SS
register to access data from stack memory
SI Source Index Used to hold index value of source operand (data) for string
instructions
DI Data Index Used to hold the index value of destination operand (data)
14
for string operations
INSTRUCTION SET
8086 Microprocessor
Instruction Set
8086 supports 6 types of instructions.
Arithmetic Instructions
Logical Instructions
MOV MOV reg2/ mem, reg1/ mem e.g. MOV reg2, reg1
MOV reg/ mem, data e.g. MOV reg, data
Data Transfer
Instructions POP POP reg16/ mem e.g. POP reg16
19
ARITHMATIC INSTRUCTIONS:
Used to perform arithmetic
operations.
Type of Instruction Mnemonics Syntax
Return RET
Compare
CMP
(Subtract) 10110001
Test (AND) TST
00001000
Mask
00000000
ADDRESSING MODES IN 8086:
The different ways in which
address of the operand is
specified in an instruction is
called as addressing modes.
1.Immediate addressing mode
2.Direct addressing mode
3.Indirect addressing mode
4.Register addressing mode
5.Register indirect addressing
mode
6.Index addressing mode
7.Relative addressing mode
8.Autoincrement addressing
mode
ADDRESSING MODES IN 8086
Mode Assembly Register Transfer
Direct address LD ADR AC ← M[ADR]
Indirect address LD @ADR AC ← M[M[ADR]]
Relative address LD $ADR AC ← M[PC+ADR]
Immediate operand LD #NBR AC ← NBR
Index addressing LD ADR(X) AC ← M[ADR+XR]
Register LD R1 AC ← R1
Register indirect LD (R1) AC ← M[R1]
Autoincrement LD (R1)+ AC ← M[R1], R1 ← R1+1
Basic Input/Output
Operations
Basic Input/Output Operations
⚫ We have seen instructions to:
⚫ Transfer information between the processor and the memory.
2
Basic Input/Output operations
(contd..)
⚫ Let us consider a simple task of reading a
character from a keyboard and displaying
that character on a display screen.
⚫ A simple way of performing the task is called
program-controlled I/O.
⚫ There are two separate blocks of instructions
in the I/O program that perform this task:
⚫ One block of instructions transfers the character into the processor.
⚫ Another block of instructions causes the character to be displayed.
3
Basic Input/Output operations (contd..)
Bus
Processor
D ATAIN DATAOUT
SIN SOUT
K eyboard 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.
4
Basic Input/Output operations (contd..)
Bus
Processor
D ATAIN DATAOUT
SIN SOUT
K eyboard 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.
5
Basic Input/Output operations
(contd..)
⚫ Buffer registers DATAIN and DATAOUT, and status flags SIN and SOUT
are part of a circuitry known as device interface.
⚫ Instructions have similar format to the instructions used for moving data
between the processor and the memory.
⚫ ASSEMBLER:
⚫ Assembler translates the mneumonic into the
binary opcode that the computer
understands.
⚫ Ex:Add #5,(R2)
ASSEMBLER DIRECTIVES
ASSEMBLER DIRECTIVES ARE USED BY
THE ASSEMBLER TO TRANSLATE SOURCE
PROGRAM TO OBJECT PROGRAM.
ASSEMBLER DIRECTIVES
1.EQU – informs the assembler about the value
of the variable.
2.ORIGIN – tells the assembler program where
in the memory to place the data block that
follows.
3.DATAWORD – used to inform the assembler
of the data requirement
ASSEMBLER DIRECTIVES
4.RESERVE – used to reserve the memory
block
5.RETURN – identifies the point at which
execution of the program should be terminated
6.START – specifies the address of the location
at which the execution of the program to begin.
7.LOOP – indicates the beginning of the branch
instruction.
ASSEMBLY LANGUAGE
STATEMENT FORMAT
Label operation operand comment
Where
Label- name associated with memory address
where machine language instruction produced
from the statement will be loaded.
Operation-specified desired operation
Operand-specified operand