LEC 1 - Introduction
LEC 1 - Introduction
2021 - 2022
Outline
• 8086 registers.
References
4. Mazidi, 80X86 IBM PC and Compatible Computers Assembly Language, Design, and
Interfacing, chapter 1.
1
1 Computers
1. Hardware: refers to all physical and mechanical components that forming the com-
puter, such as CPU, memory, display, etc.
2. Software: A computer program is a collection of instructions that performs a specific
task when executed by a computer. There are two type of software: system software
and application software.
The basic architecture of a digital computer is based on Von Neumann model. It Consists of four
parts:
2
• Microprocessor is integrated circuit device that can be programmed with a series of in-
structions to perform specified functions on data.
• Input/Output devices: input devices are used to transfer data between the user and
the computer, such as keyboard and mouse. Output device converts data of the computer
into a form that the human can understand or use. For example, screen and printer.
• System bus: is a common group of wires that interconnect components to transfer infor-
mation between them. There are three type of buses:
1. Address bus: is uni-directional and used to carry address from the CPU to different
parts of computer system.
2. Data bus: is bi-directional bus, carries data between different parts.
3. Control bus: special type type of bus which coordinate the operation of computer
components.
2 Processor-Memory Interface
• Each processor has n bit address bus, it can access 2n memory locations.
3
• The number of address bus defines the maximum memory size that can be connected to
the processor.
n Memory size
8 256 byte A0 − A7
16 64 K byte A0 − A15
32 4 G byte A0 − A31
• The number of data lines defines how much data can be transferred in each memory access.
m Data size
8 one byte D0 − D7
16 two byte (word) D0 − D15
32 four byte (double word) D0 − A31
64 eight byte (quad word) D0 − A63
• The size of registers inside processor is equal to the size of data bus (m)
3 Microprocessors
• A Microprocessor is a multipurpose programmable logic device which reads the binary in-
structions from memory. Also, it accepts binary data as input and process data according
to the instructions and gives the results as output.
• The 8086 microprocessor represents the foundation upon which all the 80x86 family of
processors have been built.
• It has 20 bit address bus (1 M byte memory) and 16 bit data bus (can transfer 2 byte in
each memory access).
4
3.1 8086 Internal Architecture
• Bus Interface Unit: Interfaces the microprocessor to external memory and I/O devices.
• It has three functions: reads (fetches) instructions, reads operands, and writes results.
• BIU consists of instruction queue, instruction pointer, segment registers, special adder, and
control unit.
• The instruction queue uses 6 bytes FIFO (first-in-first-out) memory. It is used to speed up
program execution.
• The control unit generates all control signals necessary for read/write operations, such as
MRDC, MWTC, IORC, and IOWC.
1. BIU generates the required address and send it to the memory through address bus.
5
2. BIU generate the required control signals
Read (MRDC) ==> the processor reads data from memory location that indexed by
the address.
Write (MWTC) ==> the processor send data to the memory to be stored in specified
location indexed by the address.
• EU consists of: Arithmetic Logic Unit (ALU) and many registers with different functionality.
• ALU is a digital circuit which performs arithmetic and logic operations on two m-bit digital
numbers. The value of m can be 4, 8, 16, 32, or 64 bits (16 bit in 8086).
• The size of the ALU defines the size of the computer. For example, a 32-bit computer
contains a 32-bit ALU.
• In 8085, the EU and BIU are combined in single unit, and the execution cycle is performed
in sequence.
• 8086 architecture employs parallel processing i.e., both the units (BIU and EU) work at the
same time.
• This type of design is called a pipeline. It speeds up program execution up to three times
when compared with non-pipeline architecture.
Nonpipelined 8085
fetch1 exe1 fetch2 exe2 fetch3 exe3 ....
Pipelined 8086
fetch1 fetch2 fetch3 fetch4 fetch5 fetch6 ....
wait exe1 exe2 exe3 exe4 exe5 ....
4 8086 Registers
• Data registers
• Index registers
• Base registers
• Instruction pointer
• Segment registers
• Flag register
6
Data Registers
• Each register is 16 bit and can be separated into two 8 bit register (for example AH and
AL).
• These registers are used for arithmetic, logic, and transfer operations.
• Data segment (DS) is the default register used to generate physical address with SI and
DI. Sometimes ES is used instead.
• Stack segment (SS) is the default register used to generate physical address with Sp and
Bp.
• Each time instruction is fetch from memory, IP content will be added so that it always refer
to the next instruction.
• If branch instruction is exuted, the IP content will be loaded with new value which is the
branch address.
Flag Register
Flag register is 16 bit register and contains 9 active flags. They are divided into two groups:
1. Status flags ==> six flags are updated after executing the instruction
2. Control flags ==> are set by the processor or programmer for different purposes.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
O D I T S Z A P C
7
• Status flags
Carry flag (C): hold carry out from the most significant bit in any arithmetic operation
(addition or subtraction).
Auxiliary flag (A): holds carry out from b3 to b4 in any arithmetic operation.
Zero flag (Z): is set to one when any arithmetic or logic operation yields zero result.
Sign flag (S): acquire the value of most significant bit of the result in any arithmetic or
logic operation.
Overflow flag (O): it set if the size of the result exceeds the capacity of the destination
location. is set to ’1’ when the carry in and carry out from the most significant bit are
different.
Parity flag (P): is set to ’1’ when the number of 1s in lower byte of the result is even.
Example Determine the content of flag register after adding BA10 + 9F58
• Memory segmentation divides the main memory (1 MB) into 16 segments of 64 KB each.
• Each memory location can be accessed through two addresses: base address (segment)
and offset address (SEG:OFFSET).
• The offset address (also called effective address) refers to the displacement from the be-
ginning of the segment.
• There are four segments can be active at any given time (CS, DS, ES, SS).
• The segmentation is useful in time shared system when several users share a microproces-
sor.
8
6 Logical Versus Physical Address
• Physical Address is 20 Bits address that is actually put on the address bus of 8086/8088.
The range of the physical address is 00000H to FFFFFH
• The BIU has four 16-bit segment registers: CS, DS, SS, and ES.
• Since the segment register is 16 bit, it can only access first 64 KB of memory. Therefore it
is multiplied by 16 to access entire 1 MB memory.
• Offset address is a location within a 64 KB segment range. It has a range 0000H to FFFFH
• Logical address consists of a segment starting address and offset value CS:IP, SS:BP, SS:
SP, DS: BX, DS:DI and DS:SI
9
7 Instruction Cycle
• Fetch cycle:
• Decode cycle:
• Execution cycle:
10