MOD2
MOD2
Organization
MODULE -2
Introduction of Computer Organization and Architecture. Basic organization
of computer and block level description of the functional units. Evolution of
Computers, Von Neumann model. Performance measure of Computer
Architecture, Amdahl’s Law Architecture of 8086 Family, Instruction Set,
Addressing Modes, Assembler Directives, Mixed Language Programming,
Stack, Procedure, Macro.
Computer Architecture & Organization
• Computer architecture refers to those attributes of a system visible
to a programmer or, put another way, those attributes that have a
direct impact on the logical execution of a program.
• Computer organization refers to the operational units and their
interconnections that realize the architectural specifications.
Examples of architectural attributes include the instruction set, the
number of bits used to represent various data types (e.g., numbers,
characters), I/O mechanisms, and techniques for addressing memory.
Organizational attributes include those hardware details transparent
to the programmer, such as control signals; interfaces between the
computer and peripherals; and the memory technology used.
Introduction
• A computer is a complex system; contemporary computers contain millions
of elementary electronic components. How, then, can one clearly describe
them?
• The key is to recognize the hierarchical nature. A hierarchical system is a
set of interrelated subsystems.
• The hierarchical nature of complex systems is essential to both their design
and their description. At each level, the designer is concerned with
structure and function
• Structure: The way in which the components are interrelated.
• Function: The operation of each individual component as part of the
structure.
Function
• We begin with the major
components of a
computer, describing their
structure and function, and
proceed to successively
lower layers of the
hierarchy
Types of Functions
• The computer, of course, must be able to process data. The data may take a wide
variety of forms, and the range of processing requirements is broad.
• It is also essential that a computer store data. Even if the computer is processing
data on the fly (i.e., data come in and get processed, and the results go out
immediately), the computer must temporarily store at least those pieces of data
that are being worked on at any given moment. Thus, there is at least a
short-term data storage function. Equally important, the computer performs a
long-term data storage function .
Types of Functions
• The computer must be able to move data between itself and the
outside world. The computer’s operating environment consists of
devices that serve as either sources or destinations of data.
• When data are received from or delivered to a device that is directly
connected to the computer, the process is known as input– output
(I/O), and the device is referred to as a peripheral.
• When data are moved over longer distances, to or from a remote
device, the process is known as data communications.
• Finally, there must be control of these three functions. Ultimately,
this control is exercised by the individual(s) who provides the
computer with instructions.
Operations with examples
Operations with examples
However, for our purposes, the
most interesting and in some
ways the most complex
component is the CPU. Its major
structural components are as
follows:
• Control unit: Controls the
operation of the CPU and hence
the computer.
• Arithmetic and logic unit (ALU):
Performs the computer’s data
processing
functions.
• Registers: Provides storage
internal to the CPU.
• CPU interconnection: Some
mechanism that provides for
communication
among the control unit, ALU, and
registers.
ENIAC – a vacuum tube computer running on
decimal arithmetic
• Electronic Numerical Integrator And Computer
• Eckert and Mauchly
• University of Pennsylvania
• Trajectory tables for weapons
• Started 1943
• Finished 1946
• Too late for war effort
• Used until 1955
John von Neumann/AllanTuring
• Stored Program concept
• Main memory storing programs and data
• ALU operating on binary data
• Control unit interpreting instructions from memory and executing
• Input and output equipment operated by control unit
• Princeton Institute for Advanced Studies
• IAS
• Completed 1952
What is Von Neumann Architecture?
8086 does not have a RAM or ROM inside it. However, it has internal registers for storing
intermediate results and interfaces with memory located outside it through the System Bus.
In the case of 8086, it is a 16-bit Integer processor in a 40-pin, Dual Inline Packaged IC.
8086 provides the programmer with 14 internal registers, each of 16 bits or 2 bytes wide. The main
advantage of the 8086 microprocessor is that it supports Pipelining.
Data bus - carries the data between the processor and other components
The opcode is the instruction that is executed by the CPU and the operand is the data or memory
location used to execute that instruction.
8086
Microprocessor
• 8085 Microprocessor • 8086 Microprocessor
• 8085 Microprocessor is a predecessor of • 8086 Microprocessor is an advanced
version 8086 Microprocessor, designed by version of the 8085 Microprocessor,
Intel in 1976 with the help of NMOS designed by Intel in 1976.
technology.
• The number 8086 denotes the IC number
• It includes a data bus of 8 bits, and 16 bits of this microprocessor.
of the address bus, having a +5V voltage
supply, and operates at 3.2 MHz single • It is a 16-bit microprocessor.
segment CLK. • It has 16 bits of the data bus, which is why
• It has an internal clock generator and it can read or write either 16 bits or 8 bits of
functions on a clock cycle having a duty data at a time.
cycle of 50%. • It has 20 bits of address lines that can
• 246 total operational codes and 80 access 220 address locations.
instructions are present in the 8085 • It works in 2 modes-
Microprocessor.
• Maximum mode and minimum mode
8085 microprocessor 8086 microprocessor
The memory capacity is 64 KB. Also, 8085 Can Perform Operation Up to 2 8 i.e. 16
The memory capacity is 1 MB. Also, 8086 Can Perform operations up to 2 i.e.
256 numbers. A number greater than this is to be taken multiple times in an 8-bit
65,536 numbers.
data bus.
The input/output port addresses are 8 bits. The input/output port addresses are 16 bits.
The operating frequency is 3.2 MHz. The operating frequency is 5 MHz, 8 MHz, and 10 MHz.
It does not have multiplication and division instructions. It has multiplication and division instructions.
It supports pipe-lining as it has two independent units Execution Unit (EU) and
It does not support pipelining.
Bus Interface Unit (BIU).
It consists of 5 flags(Sign Flag, Zero Flag, Auxiliary Carry Flag, Parity Flag, and It consists of 9 flags(Overflow Flag, Direction Flag, Interrupt Flag, Trap Flag, Sign
Carry Flag). Flag, Zero Flag, Auxiliary Carry Flag, Parity Flag, and Carry Flag).
Bus
• Function of bus : to transfer data and instructions between the microprocessor
and other components in a computer system.
• There are 3 types of Bus
• 1.Address Bus: The address bus is used to send the memory address of the
instruction or data being read or written. The address bus is 16 bits wide,
allowing the 8086 to address up to 64 kilobytes of memory.
• 2.Data Bus: The data bus is used to transfer data between the microprocessor
and memory. The data bus is 16 bits wide, allowing the 8086 to transfer 16-bit
data words at a time.
• 3.Control Bus: The control bus is used to transfer control signals between the
microprocessor and other components in the computer system. The control bus
is used to send signals such as read, write, and interrupt requests, and to transfer
status information between the microprocessor and other components.
Architecture of 8086
The internal architecture of Intel 8086 is divided into 2 units: The Bus Interface Unit (BIU), and The
Execution Unit (EU). These are explained as following below.
1. The Bus Interface Unit (BIU):
It provides the interface of 8086 to external memory and I/O devices via the System Bus. It performs
various machine cycles such as memory read, I/O read, etc. to transfer data between memory and
I/O devices.
• CS = 4321H IP = 1000H
• then CS x 10H = 43210H + offset = 44210H
• Here Offset = Instruction Pointer(IP)
• This is the address of the next instruction.
• Code Segment register: (16 Bit register): CS holds the base
address for the Code Segment. All programs are stored in the
Code Segment and accessed via the IP.
• Data Segment register: (16 Bit register): DS holds the base
address for the Data Segment.
• Stack Segment register: (16 Bit register): SS holds the base
address for the Stack Segment.
• Extra Segment register: (16 Bit register): ES holds the base
address for the Extra Segment.
The Execution Unit (EU):
• The main components of the EU are General purpose registers, the ALU,
Special purpose registers, the Instruction Register and Instruction Decoder,
and the Flag/Status Register.
These flags are not implicitly set by program execution but explicitly
set by the
programmer as per requirement.
1.Trap flag: Used for debugging. Setting this flag enables single step
trap for debugging purpose.
2.Interrupt flag: The processor services interrupts only if this flag is set.
One could call this as Interrupt Enable.
3.Direction flag: This is significant in case of string operations. If
directional flag is set, the access of the string data happens from
higher memory location towards lower memory location and vice versa
when flag is cleared, i.e. made zero.
Decode unit
• The Decode Unit in the 8086 microprocessor is a component that decodes the
instructions that have been fetched from memory. The decode unit takes the
machine code instructions and translates them into micro-operations that can be
executed by the microprocessor’s execution unit.
• The Decode Unit is responsible for decoding instructions, performing
register-to-register operations, and performing memory-to-register operations. It
also decodes conditional jumps, calls, and returns, and performs data transfers
between memory and registers.
• The Decode Unit helps to improve the performance of the 8086 microprocessor
by allowing it to execute instructions quickly and accurately. This improved
performance helps to ensure that the 8086 remains competitive in its
performance and capabilities, even as technology continues to advance.
Control unit
• The Control Unit in the 8086 microprocessor is a component that manages
the overall operation of the microprocessor. The control unit is responsible
for controlling the flow of instructions through the microprocessor and
coordinating the activities of the other components, including the Decode
Unit, Execution Unit, and Prefetch Unit.
• The Control Unit acts as the central coordinator for the microprocessor,
directing the flow of data and instructions and ensuring that the
microprocessor operates correctly. It also monitors the state of the
microprocessor, ensuring that the correct sequence of operations is
followed.
• The Control Unit is responsible for fetching instructions from memory,
decoding them, executing them, and updating the microprocessor’s state.
It also handles interrupt requests and performs system management tasks,
such as power management and error handling.
8086 in diagram
Details
• Intel 8086 is a 16-bit HMOS microprocessor.
• It is available in 40 pin DIP chip. It uses a 5V DC supply for its operation.
• The 8086 uses a 20-line address bus.
• It has a 16-line data bus.
• The 20 lines of the address bus operate in multiplexed mode.
• The 16-low order address bus lines have been multiplexed with data and 4
high-order address bus lines have been multiplexed with status signals.
• AD0-AD15: Address/Data bus.
• These are low order address bus. They are multiplexed with data. When AD
lines are used to transmit memory address the symbol A is used instead of
AD, for example A0-A15. When data are transmitted over AD lines the
symbol D is used in place of AD, for example D0-D7, D8-D15 or D0-D15.
• A16-A19: High order address bus. These are multiplexed with status
signals.
• RD’: This is used for read operation. It is an output signal. It is active
when low.
• READY : This is the acknowledgement from the memory or slow
device that they have completed the data transfer.
• INTR : Interrupt Request. This is triggered input. This is sampled
during the last clock cycles of each instruction for determining the
availability of the request. If any interrupt request is found pending,
the processor enters the interrupt acknowledge cycle.
• NMI : Non maskable interrupt. This is an edge triggered input which
results in a type II interrupt. NMI is non-maskable internally by
software. A transition made from low(0) to high(1) initiates the
interrupt at the end of the current instruction.
• MN/MX’ : Minimum/Maximum. This pin signal indicates what mode
the processor will operate in.
S2 S1 S0 Characteristics
0 0 0 Interrupt acknowledge
0 1 1 Halt
1 0 0 Code access
1 0 1 Read memory
1 1 0 Write memory
1 1 1 Passive state
• LOCK’ : Its an active low pin. It indicates that other system bus
masters have not been allowed to gain control of the system bus
while LOCK’ is active low(0). The LOCK signal will be active until the
completion of the next instruction.
• TEST’ : This examined by a ‘WAIT’ instruction. If the TEST pin goes
low(0), execution will continue, else the processor remains in an idle
state. The input is internally synchronized during each of the clock
cycle on leading edge of the clock.
• CLK : Clock Input. The clock input provides the basic timing for
processing operation and bus control activity. Its an asymmetric
square wave with a 33% duty cycle.
• RESET : This pin requires the microprocessor to terminate its present
activity immediately. The signal must be active high(1) for at least
four clock cycles.
Queue Status
• QS1,QS0 : These signals indicate the status of the internal 8086
instruction queue according to the table shown below:
• DEN: Data enable. This pin is provided as an output enable for the
8286/8287 in a minimum system which uses transceiver. DEN is active
low(0) during each memory and input-output access and for INTA cycles.
• POP − Used to get a word from the top of the stack to the provided location.
• OUT − Used to send out a byte or word from the accumulator to the
provided port.
• LDS − Used to load DS register and other provided register from the
memory
• LES − Used to load ES register and other provided register from the
memory.
• Instructions to transfer flag registers
• LAHF − Used to load AH with the low byte of the flag register.
• PUSHF − Used to copy the flag register at the top of the stack.
• POPF − Used to copy a word at the top of the stack to the flag
register.
Arithmetic Instructions
• These instructions are used to perform arithmetic operations like addition, subtraction, multiplication,
division, etc.
• Following is the list of instructions under this group −Instructions to perform addition
• ADD − Used to add the provided byte to byte/word to word.
• IDIV − Used to divide the signed word by byte or signed double word by word.
• CBW − Used to fill the upper byte of the word with the copies of sign bit of the lower byte.
• CWD − Used to fill the upper word of the double word with the sign bit of the lower word.
• Instructions to perform logical operation
• NOT − Used to invert each bit of a byte or word.
• AND − Used for adding each bit in a byte/word with the corresponding bit
in another byte/word.
• SHR − Used to shift bits of a byte/word towards the right and put
zero(S) in MSBs.
• SAR − Used to shift bits of a byte/word towards the right and copy
the old MSB into the new MSB.
• Instructions to perform rotate operations
• ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to
LSB and to Carry Flag [CF].
• ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to
MSB and to Carry Flag [CF].
• RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to
CF and CF to MSB.
• RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to
CF and CF to LSB.
• Interrupt Instructions
• These instructions are used to call the interrupt during program
execution.
• CALL − Used to call a procedure and save their return address to the stack.
• Example
• MOV CX, 4929 H, ADD AX, 2387 H, MOV AL, FFH
Addressing Modes(contd)
2.Register addressing mode
• It means that the register is the source of an operand for an
instruction.
• Example
• MOV CX, AX ; copies the contents of the 16-bit AX register into
• ; the 16-bit CX register),
• ADD BX, AX
Addressing Modes(contd)
3.Direct addressing mode
• The addressing mode in which the effective address of the memory
location is written directly in the instruction.
• Example
• MOV AX, [1592H], MOV AL, [0300H]
Addressing Modes(contd)
4.Register indirect addressing mode
• This addressing mode allows data to be addressed at any memory
location through an offset address held in any of the following
registers: BP, BX, DI & SI.
• Example
• MOV AX, [BX] ; Suppose the register BX contains 4895H, then the
contents
; 4895H are moved to AX
• ADD CX, {BX}
Addressing Modes(contd)
5.Based addressing mode
• In this addressing mode, the offset address of the operand is given by
the sum of contents of the BX/BP registers and 8-bit/16-bit
displacement.
• Example
• MOV DX, [BX+04], ADD CL, [BX+08]
Addressing Modes(contd)
6.Indexed addressing mode
• In this addressing mode, the operand's offset address is found by
adding the contents of SI or DI register and 8-bit/16-bit
displacements.
• Example
• MOV BX, [SI+16], ADD AL, [DI+16]
Addressing Modes(contd)
• Based-index addressing mode
• In this addressing mode, the offset address of the operand is
computed by summing the base register to the contents of an Index
register.
• Example
• ADD CX, [AX+SI], MOV AX, [AX+DI]
Addressing Modes(contd)
• Based indexed with displacement mode
• In this addressing mode, the operands offset is computed by adding
the base register contents. An Index registers contents and 8 or 16-bit
displacement.
• Example
• MOV AX, [BX+DI+08], ADD CX, [BX+SI+16]
Assembler Directives
• Assembler directives are the commands to the assembler that direct the
assembly process.
• They indicate how an operand is treated by the assembler and how
assembler handles the program.
• They also direct the assembler how program and data should arrange in
the memory.
• ALP’s are composed of two type of statements.
• (i) The instructions which are translated to machine codes by assembler.
• (ii) The directives that direct the assembler during assembly process, for
which no machine code is generated.
Assembler Directives (contd)
• 1. ASSUME: Assume logical segment name.
• The ASSUME directive is used to inform the assembler the names of
the logical segments to be assumed for different segments used in
the program .In the ALP each segment is given name.
Accessed by CALL and RET mechanism during Accessed by name given to macro when defined
program execution during assembly
Machine code for instructions only put in memory Machine code generated for instructions each
once time called
Parameters are passed in registers, memory Parameters passed as part of statement which
locations or stack calls macro
Procedures takes huge memory for CALL (3 bytes Length of code is very huge if macro’s are called
each time CALL is used) instruction for more number of times