Microprocessor Notes Pruvanchal University
Microprocessor Notes Pruvanchal University
Second
CSC162 SEMESTER
Notes Prepared By
Raju Poudel
MCA, Purbanchal University
Prepared by: Raju Poudel [MCA] 1
Unit -1 Introduction to Microprocessors [4 Hrs.]
Microprocessor and its Application
Features of a Microprocessor
• Cost-effective − The microprocessor chips are available at low prices and results its
low cost.
• Size − The microprocessor is of small size chip, hence is portable.
• Low Power Consumption − Microprocessors are manufactured by using metaloxide
semiconductor technology, which has low power consumption.
• Versatility − The microprocessors are versatile as we can use the same chip in a
number of applications by configuring the software program.
• Reliability − The failure rate of microprocessors is very low; hence it is reliable.
Components of Microprocessor
Microprocessor Vs Microcontroller
Evolution of Microprocessor
• The first microprocessor was introduced in the year 1971. It was introduced by Intel
and was named Intel 4004.
• Intel 4004 is a 4-bit microprocessor and it was not a powerful microprocessor. It can
perform addition and subtraction operation on 4 bits at a time.
• However, it was Intel’s 8080 was the first microprocessor to make it to Home
computers. It was introduced during the year 1974 and it can perform 8 bit
operations.
• Then during the year 1976, Intel introduced 8085 processors which is nothing but an
update of 8080 processors.
Computer Architecture
• Computer architecture is a specification detailing how a set of software and
hardware technology standards interact to form a computer system or platform. In
short, computer architecture refers to how a computer system is designed and what
technologies it is compatible with.
• A very good example of computer architecture is von Neumann architecture, which
is still used by most types of computers today.
• This was proposed by the mathematician John von Neumann in 1945. It describes
the design of an electronic computer with its CPU, which includes the arithmetic
logic unit, control unit, registers, memory for data and instructions, an input/output
interface and external storage functions.
Harvard Architecture
• The Harvard architecture is a computer architecture with physically separate storage
and signal pathways for instructions and data. The term originated from the Harvard
Mark I, which stored instructions on punched tape and data in electro-mechanical
counters.
• These early machines had data storage entirely contained within the central
processing unit, and provided no access to the instruction storage as data. It
required two memories for their instruction and data. Harvard architecture requires
separate bus for instruction and data.
4) Program counter
It is a 16-bit register used to store the memory address location of the next instruction to be
executed. Microprocessor increments the program whenever an instruction is being
executed, so that the program counter points to the memory address of the next instruction
that is going to be executed.
5) Stack pointer
It is also a 16-bit register works like stack, which is always incremented/decremented push
& pop operations.
6) Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
7) Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon
the result stored in the accumulator.
These are the set of 5 flip-flops –
- Sign (S)
- Zero (Z)
- Auxiliary Carry (AC)
- Parity (P)
- Carry (C)
a) Sign Flag (S) – After any operation if result is negative sign flag becomes set, i.e. If
result is positive sign flag becomes reset i.e. 0.
Example:
– MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
b) Zero Flag (Z) – After any arithmetical or logical operation if the result is 0 (00)H, the zero
flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
Example:
MVI A 10 (load 10H in register A)
SUB A (A = A – A)
These set of instructions will set the zero flag to 1 as 10H – 10H is 00H
c) Auxiliary Carry Flag (AC) – If intermediate carry is generated this flag is set to 1, otherwise
it is reset to 0.
Example:
MOV A 2B (load 2BH in register A)
MOV B 39 (load 39H in register B)
ADD B (A = A + B)
These set of instructions will set the auxiliary carry flag to 1, as on adding 2B and 39,
addition of lower order nibbles B and 9 will generate a carry.
d) Parity Flag (P) – If after any arithmetic or logical operation the result has even parity, an
even number of 1 bits, the parity register becomes set i.e. 1, otherwise it becomes reset.
1-accumulator has even number of 1 bits
0-accumulator has odd parity
e) Carry Flag (CY) – Carry is generated when performing n bit operations and the result is
more than n bits, then this flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
During subtraction (A-B), if A>B it becomes reset and if (A<B) it becomes set.
Carry flag is also called borrow flag.
Priority of Interrupts
When microprocessor receives multiple interrupt requests simultaneously, it will execute
the interrupt service request (ISR) according to the priority of the interrupts.
2) Data bus
AD7-AD0, it carries the least significant 8-bit address and data bus.
4) Power supply
There are 2 power supply signals − VCC & VSS. VCC indicates +5v power supply and VSS
indicates ground signal.
5) Clock signals
There are 3 clock signals, i.e. X1, X2, CLK OUT.
The method by which the address of source of data or the address of destination of result is
given in the instruction is called Addressing Modes. The term addressing mode refers to the
way in which the operand of the instruction is specified.
b) Arithmetic Instructions
These instructions perform the operations like addition, subtraction, increment and
decrement.
Example: ADD, SUB, INR, DCR
c) Logical Instructions
These instructions perform logical operations on data stored in registers and memory. The
logical operations are: AND, OR, XOR, Rotate, Compare and Complement.
Example: ANA, ORA, RAR, RAL, CMP, CMA
d) Branching Instructions
Branching instructions refer to the act of switching execution to a different instruction
sequence as a result of executing a branch instruction. The three types of branching
instructions are: Jump, Call and Return.
e) Control Instructions
The control instructions control the operation of microprocessor. Examples: HLT, NOP, EI
(Enable Interrupt), DI (Disable Interrupt).
MOV A, C 79 Register 1
MOV A, D 7A Register 1
MOV A, E 7B Register 1
MOV A, H 7C Register 1
MOV A, L 7D Register 1
MOV B, A 47 Register 1
MOV B, B 40 Register 1
MOV B, C 41 Register 1
MOV B, D 42 Register 1
MOV B, E 43 Register 1
MOV B, H 44 Register 1
MOV B, L 45 Register 1
MOV C, A 4F Register 1
MOV C, B 48 Register 1
MOV C, C 49 Register 1
MOV C, D 4A Register 1
MOV C, E 4B Register 1
MOV C, H 4C Register 1
MOV C, L 4D Register 1
MOV D, A 57 Register 1
MOV D, B 50 Register 1
MOV D, C 51 Register 1
MOV D, D 52 Register 1
MOV D, H 54 Register 1
MOV D, L 55 Register 1
MOV E, A 5F Register 1
MOV E, B 58 Register 1
MOV E, C 59 Register 1
MOV E, D 5A Register 1
MOV E, E 5B Register 1
MOV E, H 5C Register 1
MOV E, L 5D Register 1
MOV H, A 67 Register 1
MOV H, B 60 Register 1
MOV H, C 61 Register 1
MOV H, D 62 Register 1
MOV H, E 63 Register 1
MOV H, H 64 Register 1
MOV H, L 65 Register 1
MOV L, A 6F Register 1
MOV L, B 68 Register 1
MOV L, C 69 Register 1
MOV L, D 6A Register 1
MOV L, E 6B Register 1
MOV L, H 6C Register 1
MOV L, L 6D Register 1
Total = 84
ADD B 80 Register 1
ADD C 81 Register 1
ADD D 82 Register 1
ADD E 83 Register 1
ADD H 84 Register 1
ADD L 85 Register 1
ADI data C6 Immediate 2 It immediately adds the given data with the
accumulator and the answer will be stored in
Accumulator.
ADC C 88 Register 1
ADC D 89 Register 1
ADC E 8B Register 1
ADC H 8C Register 1
ADC L 8D Register 1
SUB C 91 Register 1
SUB D 92 Register 1
SUB E 93 Register 1
SUB H 94 Register 1
SUB L 95 Register 1
SBB C 99 Register 1
SBB D 9A Register 1
SBB E 9B Register 1
SBB H 9C Register 1
SBB L 9D Register 1
INR C 0C Register 1
INR E 1C Register 1
INR H 24 Register 1
INR L 2C Register 1
DCR B 05 Register 1
DCR C 0D Register 1
DCR D 15 Register 1
DCR E 1D Register 1
DCR H 25 Register 1
DCR L 2D Register 1
Total=65
ANA C A1 Register 1
ANA D A2 Register 1
ANA E A3 Register 1
ANA H A4 Register 1
ANA L A5 Register 1
ANA M A6 Register 1
Indirect
ANI data E6 Immediate 2 A=A AND data
ORA C B1 Register 1
ORA D B2 Register 1
ORA E B3 Register 1
ORA H B4 Register 1
ORA L B5 Register 1
ORA M B6 Register 1
Indirect
ORI data F6 Immediate 2
XRA C A9 Register 1
XRA D AA Register 1
XRA H AC Register 1
XRA L AD Register 1
XRA M AE Register 1
Indirect
XRI data EE Immediate 2
CMP C B9 Register 1
CMP D BA Register 1
CMP E BB Register 1
CMP H BC Register 1
CMP L BD Register 1
CMP M BE Register 1
Indirect
CPI data FE Immediate 2 A=A-data (Acc. Remain unchanged)
Total=39
PUSH D D5 Register 1
Indirect
PUSH H E5 Register 1
Indirect
POP B C1 Register 1 POP data from data from stack on the basis of
Indirect address pointed by BC pair.
POP D D1 Register 1
Indirect
POP H E1 Register 1
Indirect
NOP 00 Implied/Implicit 1 No operation is performed
DI F3 Implied/Implicit 1
EI 7B Implied/Implicit 1
11 In 8085, only one processor is used. In 8086, more than one processor is used.
Additional external processor can also be
employed.
12 It contains less number of transistors It contains more number of transistors
compare to 8086 microprocessor. It compare to 8085 microprocessor. It contains
contains about 6500 transistor. about 29000 in size.
13 The cost of 8085 is low. The cost of 8086 is high.
8086 contains two independent functional units: a Bus Interface Unit (BIU) and an
Execution Unit (EU).
Instruction Pointer (IP): The instruction pointer in the 8086 microprocessor acts as a
program counter. It indicates to the address of the next instruction to be executed.
Memory Segmentation
To increase execution speed and fetching speed, 8086 segments the memory.
It’s 20 bit address bus can address 1MB of memory, it segments it into 4 64kB
segments.
8086 works only with four 64KB segments within the whole 1MB memory.
It consists of following:
• General Purpose Registers: There are four 16-bit general purpose registers: AX
(Accumulator Register), BX (Base Register), CX (Counter) and DX.
• Index Register: The following four registers are in the group of pointer and index
registers: Stack Pointer (SP), Base Pointer (BP), Source Index (SI), Destination Index
(DI).
• ALU: It handles all arithmetic and logical operations. Such as addition, subtraction,
multiplication, division, AND, OR, NOT operations.
• Flag Register: It is a 16 bit register which exactly behaves like a flip-flop, means it
changes states according to the result stored in the accumulator. It has 9 flags and
they are divided into 2 groups i.e. conditional and control flags.
Conditional Flags: This flag represents the result of the last arithmetic or logical
instruction executed. Conditional flags are:
- Carry Flag
- Auxiliary Flag
- Parity Flag
- Zero Flag
- Sign Flag
- Overflow Flag
Control Flags: It controls the operations of the execution unit. Control flags are:
- Trap Flag
- Interrupt Flag
- Direction Flag
• AD0-AD15 (Address Data Bus): Bidirectional address/data lines. These are low order
address bus. When these lines are used to transmit memory address the symbol A is
used instead of AD for example A0- A15.
• A16 - A19 (Output): High order address lines. These are multiplexed with status
signals.
• A16/S3, A17/S4: A16 and A17 are multiplexed with segment identifier signals S3 and
S4.
• A18/S5: A18 is multiplexed with interrupt status S5.
• A19/S6: A19 is multiplexed with status signal S6.
• BHE/S7 (Output): Bus High Enable/Status. During T1, it is low. It enables the data
onto the most significant half of data bus, D8-D15. 8-bit device connected to upper
half of the data bus use BHE signal. It is multiplexed with status signal S7. S7 signal is
available during T3 and T4.
• RD (Read): For read operation. It is an output signal. It is active when LOW.
• Ready (Input): The addressed memory or I/O sends acknowledgement through this
pin. When HIGH it denotes that the peripheral is ready to transfer data.
Prepared by: Raju Poudel [MCA] 30
• RESET (Input): System reset.
• CLK (input): Clock 5, 8 or 10 MHz.
• INTR: Interrupt Request.
• NMI (Input): Non-maskable interrupt request.
• TEST (Input): Wait for test control. When LOW the microprocessor continues
execution otherwise waits.
• VCC: Power supply +5V dc. GND: Ground.
f) Based Indexed Mode - In this the effective address is sum of base register and index
register. Example,
Base register: BX, BP
Index register: SI, DI
The physical memory address is calculated according to the base register.
MOV AL, [BP+SI]
MOV AX, [BX+DI]
g) Indexed mode – In this type of addressing mode the effective address is sum of
index register and displacement. Example,
MOV AX, [SI+2000]
MOV AL, [DI+3000]
h) Based mode – In this the effective address is the sum of base register and
displacement. Example,
MOV AL, [BP+ 0100]
i) Based indexed displacement mode – In this type of addressing mode the effective
address is the sum of index register, base register and displacement.
MOV AL, [SI+BP+2000]
j) Input/Output mode – This addressing mode is related with input output operations.
MUL Instruction
Used to multiply unsigned byte by byte/word by word.
It is always performed with accumulator.
Only overflow and carry flag are affected.
Format – MUL reg / MUL mem
Example:
MUL BX (AX=AX*BX)
IMUL Instruction
Used to multiply signed byte by byte/word by word.
It is always performed with accumulator.
Format – IMUL reg / IMUL mem
Example:
IMUL BX (AX=AX*BX)
DIV Instruction
Used to divide unsigned byte by byte/word by word.
It is always performed with accumulator.
Format – DIV reg / DIV mem
Example:
DIV BX (AX=AX/BX)
LOOP Instruction
Used to loop a group of instructions until the condition satisfies, i.e., CX = 0
This intruction decremets CX by 1 and transfers control to the target location if CX is
not 0; otherwise, the instruction following LOOP is executed.
Format – LOOP label
AAA Instruction
Used to adjust ASCII after addition.
DAA Instruction
Used to adjust the decimal after the addition/subtraction operation.
Unlike procedures, macros should be defined above the code that uses it, for example:
Assembler Directives
An assembler directive is a message to the assembler that tells the assembler something it
needs to know in order to carry out the assembly process; for example, an assemble
directive tells the assembler where a program is to be located in memory.
Following are 8086 assembler directives:
4. STRUCT and ENDS directives to define a structure template for grouping data items.
5. The EQU directive - is used to give name to some value or symbol. Each time the
assembler finds the given names in the program, it will replace the name with the
value or a symbol. The value can be in the range 0 through 65535.
6. Extern - It is used to tell the assembler that the name or label following the directive
are some other assembly module.
7. GLOBAL - The GLOBAL directive can be used in place of PUBLIC directive .for a name
defined in the current assembly module; the GLOBAL directive is used to make the
symbol available to the other modules.
8. SEGMENT - It is used to indicate the start of a logical segment. It is the name given to
the segment. Example: the code segment is used to indicate to the assembler the
start of logical segment.
10. NAME - It is used to give a specific name to each assembly module when program
consists of several modules.
11. INCLUDE - It is used to tell the assembler to insert a block of source code from the
named file into the current source module. This shortens the source module.
12. OFFSET - It is an operator which tells the assembler to determine the offset or
displacement of a named data item from the start of the segment which contains it.
It is used to load the offset of a variable into a register so that variable can be
accessed with one of the addressed modes.
13. GROUP - It can be used to tell the assembler to group the logical segments named
after the directive into one logical group. This allows the contents of all he segments
to be accessed from the same group.
Upon the completion of step 4, the control goes back to step 1 to fetch, decode, and
execute the next instruction. This process continues indefinitely unless a HALT instruction is
encountered.
Fetch cycle takes four t-states and execution cycle takes three t-states. It is shown below:
Memory Interfacing
As we know that any system which process digital data needs the facility for storing the
data. Interfacing is a technique to be used for connecting the Microprocessor to Memory.
Now a days Semiconductor memories are used for storing purpose. There are some of the
advantages of the semiconductor memory.
Small size
High speed
Better reliability
Low cost
Memory Size: - The number of location and number of bits per word will vary from memory
to memory. For example, if a particular memory chip is capable of storing M words with
each word having N-bits. Then the size of the memory will be M× N.
In this system A0 to A11 lines of Microprocessor will be connected to the address lines of
the memory. and D0 to D7 of the 8085 microprocessor will be connected to the data bus of
the memory.
As we know that the it is EPROM, so only RD pin is connected to the microprocessor. There
is not the facility for writing data.
In case if you are using RAM then you have to connect one more pin for writing operation.
As we can see that there is a pin named CS. Generally, this pin is used for Selection for the
chip in case of two or more than memory chip.
Latch has been used to separate the data and address bus.
I/O Operations
CPU uses two methods to perform input/output operations between the CPU and
peripheral devices in the computer. These two methods are called memory mapped IO and
IO mapped IO.
Memory-mapped IO uses the same address space to address both memory and I/O
devices.
On the other hand, IO mapped IO uses separate address spaces to address memory
and IO devices.
Hybrid I/O
• Combination of both previous I/O.
• Uses same address in some cases and two address space in some cases.
Conclusion
• Memory mapped IO and IO mapped IO are two methods to perform input/output
operations between the CPU and peripheral devices in the computer.
• The basic difference between memory mapped IO and IO mapped IO is that memory
mapped IO uses the same address space for both memory and IO device while IO
mapped IO uses two separate address spaces for memory and IO device.
Application of DMA
• DMA has been a built-in feature of PC architecture since the introduction of the
original IBM PC.
• PC-based DMA was used for floppy disk I/O in the original PC and for hard disk I/O in
later versions.
• PC-based DMA technology, along with high speed bus technology, is driven by data
storage, communications, and graphics needs-all of which require the highest rates
of data transfer between system memory and I/O devices.
• Applications areas are: cinemas, theatres, hotels, railway stations, shopping
centres, trade shows, museums & many more.
Interrupt
• 8085 Interrupt pins & priority. (Discussed already)
• Maskable and Non-maskable interrupt (Discussed already)
• RST Instructions –
Vector Interrupt
• In a computer, a vectored interrupt is an I/O interrupt that tells the part of the
computer that handles I/O interrupts at the hardware level that a request for
attention from an I/O device has been received and also identifies the device that
sent the request.
• Vectored Interrupts are those which have fixed vector address (starting address of
sub-routine) and after executing these, program control is transferred to that
address.
• Vector Addresses are calculated by the formula 8 * TYPE
RST 5.5 2C H
RST 6.5 34 H
RST 7.5 3C H
Polled Interrupt
• A polled interrupt is a certain kind of input/output (I/O) interrupt that sends a
message to the part of the computer that houses the I/O interface.
• The message states that a device is ready to be accessed without an identifying
device.
• In a computer, a polled interrupt is a specific type of I/O interrupt that notifies the
part of the computer containing the I/O interface that a device is ready to be read or
otherwise handled but does not indicate which device.
• The interrupt controller must poll (send a signal out to) each device to determine
which one made the request.
The Block Diagram consists of 8 blocks which are – Data Bus Buffer, Read/Write Logic,
Cascade Buffer Comparator, Control Logic, Priority Resolver and 3 registers- ISR, IRR, IMR.
1) Data bus buffer –
• This Block is used as a mediator between 8259 and 8085/8086 microprocessor by
acting as a buffer. The data bus buffer consists of 8 bits represented as D0-D7 in the
block diagram. Thus, shows that a maximum of 8 bits data can be transferred at a
time.
2) Read/Write logic –
• This block is responsible for the flow of data depending upon the inputs of RD and
WR. These two pins are active low pins used for read and write operations.
3) Control logic –
• It is the centre of the microprocessor and controls the functioning of every block. It
has pin INTR which is connected with other microprocessor for taking interrupt
request and pin INT for giving the output.
4) Interrupt request register (IRR) –
• It stores all the interrupt level which are requesting for Interrupt services.
5) Interrupt service register (ISR) –
• It stores the interrupt level which are currently being executed.
6) Interrupt mask register (IMR) –
• It stores the interrupt level which have to be masked by storing the masking bits of
the interrupt level.
7) Priority resolver –
• It examines all the three registers and set the priority of interrupts and according to
the priority of the interrupts, interrupt with highest priority is set in ISR register.
Also, it reset the interrupt level which is already been serviced in IRR.
8) Cascade buffer –
• To increase the Interrupt handling capability, we can further cascade more number
of pins by using cascade buffer. So, during increment of interrupt capability, CSA
lines are used to control multiple interrupt structure.
Parallel Communication
• In data transmission, parallel communication is a method of conveying multiple
binary digits (bits) simultaneously. It contrasts with serial communication, which
conveys only a single bit at a time.
• In Parallel Transmission, many bits are flow together simultaneously from one
computer to another computer.
• Parallel Transmission is faster than serial transmission to transmit the bits. Parallel
transmission is used for long distance.
Serial Communication
• Serial communication is the process of sending data one bit at a time, sequentially,
over a communication channel or computer bus.
• In Serial Transmission, data-bit flows from one computer to another computer in bi-
direction. In this transmission one bit flows at one clock pulse.
• In Serial Transmission, 8 bits are transferred at a time having a start and stop bit.
3. Transmit Buffer
• This block is used for parallel to serial converter that receives a parallel byte for
conversion into serial signal and further transmission onto the common channel.
– TXD: It is an output signal, if its value is one, means transmitter will transmit
the data.
4. Transmit control
• This block is used to control the data transmission with the help of following pins:
– TXRDY: It means transmitter is ready to transmit data character.
– TXEMPTY: An output signal which indicates that TXEMPTY pin has
transmitted all the data characters and transmitter is empty now.
5. Receive buffer
• This block acts as a buffer for the received data.
– RXD: An input signal which receives the data.
6. Receive control
• This block controls the receiving data.
– RXRDY: An input signal indicates that it is ready to receive the data.
– RXC: An active-low output signal which controls the data transmission rate of
received data.
– SYNDET/BD: An input or output terminal.
2) Strobe I/O
• In many applications, valid data is present on an external device only at a certain
time, so it must be read in at that time.
• E.g. the ASCII-encoded keyboard. When a key is pressed, circuitry on the keyboard
sends out the ASCII code for the pressed key on eight parallel data lines, and then
sends out a strobe signal on another line to indicate that valid data is present on the
eight data lines.
2) Input/output Mode
There are three types of the input/output mode. They are as follows:
Mode 0
• In this mode all the three ports (port A, B, C) can work as simple input function or
simple output function. In this mode there is no interrupt handling capacity.
Mode 1
• In this mode either port A or port B can work as simple input port or simple output
port, and port C bits are used for handshake signals before actual data transmission.
It has interrupt handling capacity.
• Example: A CPU wants to transfer data to a printer. In this case since speed of
processor is very fast as compared to relatively slow printer, so before actual data
transfer it will send handshake signals to the printer for synchronization of the speed
of the CPU and the peripherals.
Mode 2
• Bi-directional data bus mode. In this mode only port A works, and port B can work
either in mode 0 or mode 1. 6 bits port C are used as handshake signals. It also has
interrupt handling capacity.
In simple terms RS232 defines the voltage for the path used for data exchange
between the devices. It specifies common voltage and signal level, common pin wire
configuration and minimum, amount of control signals.
Fig: RS-232
DTE - A DTE stands for data terminal equipment is an end instrument that convert
user information into signals or reconverts the receive signal. A male connector is
used in DTE and has pin out configuration.
DCE - A DCE stands for data communication equipment's. It sits between the DTE
and data transmission circuit for example modem. A DCE device uses a female
connector which has holes on the surface to hold male connector.
Application of RS-232
• RS232 serial communication is used in old generation PCs for connecting the
peripheral devices like mouse, printers, modem etc.
• Nowadays, RS232 is replaced by advanced USB.
• It is still used by some microcontroller boards, receipt printers, point of sale system
(PoS), etc.
80286 Microprocessor
• The Intel 80286 is a high-performance 16-bit microprocessor introduced in 1982.
• It has been specially designed for multiuser and multitasking systems.
• 80286 is upwardly compatible with 8086 in terms of instruction set. (That is the
8086,8088,80186,80286 CPU family all contain the same instruction set)
• It has 24 address lines and 16 data lines.
• There are two operating modes for 80286
- The real address mode
- The protected virtual memory address mode
• In real address mode the processor can address upto 1 MB of physical memory.
• The virtual address mode is for multiuser/multitasking system. In this mode the
processor can address upto 1 GB of virtual memory.
The 80286 CPU contains almost the same set of registers, as in 8086.
a) Eight 16-bit general purpose registers.
b) Four 16-bit segment registers.
c) Status and control register
d) Instruction Register.
• The flag register bits are modified according to the result of the execution of logical
and arithmetical instructions. These are called status flag bits.
• The Address Unit (AU) is responsible for calculating the physical address of
instructions and data that CPU wants to access.
• The physical address computed by the address unit is handed over to the BUS Unit
(BU) of the CPU.
• One of the major function of the bus unit is to fetch instruction bytes from the
memory.
• The Instruction Unit (IU) accepts instructions from the prefetch queue and an
instruction decoder decodes them one by one.
• The Execution Unit (EU) is responsible for instructions received from the decoded
instruction queue, which sends the data part of the instruction over the data bus. It
is responsible for the execution of the decoded instruction.
Interrupt in 80286
Interrupts of 80286 may be divided into three categories,
a) External or Hardware interrupts
b) INT instruction or software interrupts
c) Interrupts generated internally by exceptions (TRAP)
(Give same example as 8086, because all registers are same & it uses same instruction
set).
Descriptor Cache
• It is 8-byte quantity. Each segment has a descriptor. There are two main types of
descriptor -
- Segment Descriptor
- System control Descriptor
• Descriptors are contained in a descriptor table. There are two categories of
descriptor table - global and local.
• A system has only one global descriptor table or GDT.
• A local descriptor table or LDT is set up in the system for each task or closely related
group of tasks. Each task can have its own descriptor table and memory area defined
by the descriptors in it.
Accessing Segments
• The 80286 microprocessor keeps the base address and limits for the descriptor
tables currently in use in internal registers.
• These registers are load descriptor table register (LDTR) and global descriptor table
register (GDTR).
• Descriptor in memory is addressed by adding segment selector to these registers.
• The descriptors contain the base address of segments, which when added with the
offset in the virtual address points to the required memory location.
80386 Microprocessor
• 80386 is a 32bit processor that supports, 8bit/32bit data operands.
• The 80386 instruction set is upward compatible with all its predecessors.
• The 80386 can run 8086 applications under protected mode in its virtual 8086 mode
of operation.
• With the 32 bit address bus, the 80386 can address upto 4Gbytes of physical
memory. The physical memory is organised in terms of segments of 4Gbytes at
maximum.
• The 80386 CPU supports 16K number of segments and thus the total virtual space of
4Gbytes * 16K = 64 Terrabytes.
• The memory management section of 80386 supports the virtual memory, paging and
four levels of protection, maintaining full compatibility with 80286.
• The 80386 offers a set of 8 debug registers DR 0-DR 7 for hardware debugging and
control.
• The concept of paging is introduced in 80386 that enables it to organise the available
physical memory in terms of pages of size 4Kbytes each, under the segmented
memory.
• The Memory management unit consists of a Segmentation unit and a Paging unit.
• Segmentation unit allows the use of two address components, viz. segment and
offset for relocability and sharing of code and data.
• Segmentation unit allows segments of size 4Gbytes at max.
• The Paging unit organizes the physical memory in terms of pages of 4kbytes size
each.
• Paging unit works under the control of the segmentation unit, i.e. each segment is
further divided into pages. The virtual memory is also organizes in terms of segments
and pages by the memory management unit.
• The Bus control unit has a prioritizer to resolve the priority of the various bus
requests. This controls the access of the bus. The address driver drives the bus
enable and address signal A0 – A31.
• The 80386 has eight 32 - bit general purpose registers which may be used as either 8
bit or 16 bit registers.
• A 32 - bit register known as an extended register, is represented by the register
name with prefix E.
• Example: A 32-bit register corresponding to AX is EAX, similarly BX is EBX etc.
• The 16 bit registers BP, SP, SI and DI in 8086 are now available with their extended
size of 32 bit and are names as EBP, ESP, ESI and EDI.
• AX represents the lower 16 bit of the 32-bit register EAX.
• BP, SP, SI, DI represents the lower 16 bit of their 32 bit counterparts, and can be
used as independent 16 bit registers.
• The six segment registers available in 80386 are CS, SS, DS, ES, FS and GS.
• The CS and SS are the code and the stack segment registers respectively, while DS,
ES, FS, GS are 4 data segment registers.
• A 16-bit instruction pointer IP is available along with 32-bit counterpart EIP.
• The Flag register of 80386 is a 32-bit register.
• Control Registers: The 80386 has three 32-bit control registers CR), CR 2 and CR 3 to
hold global machine status independent of the executed task. Load and store
instructions are available to access these registers.
• Debug and Test Registers: Intel has provided a set of 8 debug registers for hardware
debugging.
Paging in 80386
• Paging is one of the memory management techniques used for virtual memory
multitasking operating system.
• The segmentation scheme may divide the physical memory into a variable size
segments but the paging divides the memory into a fixed size pages.
• The pages are just fixed size portions of the program module or data.
• The advantage of paging scheme is that the complete segment of a task need not be
in the physical memory at any time.
• The paging unit is a memory management unit enabled only in protected mode. The
paging mechanism allows handling of large segments of memory in terms of pages of
4Kbyte size.
• Only a few pages of the segments, which are required currently for the execution
need to be available in the physical memory. Thus the memory requirement of the
task is substantially reduced, relinquishing the available memory for other tasks.
• Whenever the other pages of task are required for execution, they may be fetched
from the secondary storage.
• The previous page which are executed, need not be available in the memory, and
hence the space occupied by them may be relinquished for other tasks.
• Thus paging mechanism provides an effective technique to manage the physical
memory for multitasking systems.
Input:
Memory Location Data
2050H 45H
2051H 53H
Output:
Memory Location Data
2055H 98H
Input:
Memory Location Data
2050H 65H
2051H 53H
Output:
Memory Location Data
2055H 12H
Input:
Memory Location Data
2013H 12H
Output:
Memory Location Data
2052H EDH
Input:
Memory Location Data
2013H 12H
Output:
Memory Location Data
2052H EEH
Input:
Register Pair Data
HL 1124H
DE 2253H
Output:
Memory Location Data
2055H 77H
2056H 33H
Input:
Memory Location Data
2050H 33H
2051H 45H
2052H 24H
2053H 34H
Output:
Memory Location Data
2055H 57H
2056H 79H
Input:
Register Pair Data
HL 4897H
DE 1234H
Output:
Memory Location Data
2055H 63H
2056H 36H
Input:
Memory Location Data
2050H 78H
2051H 45H
2052H 24H
2053H 34H
Output:
Memory Location Data
2055H 54H
2056H 11H
MVI A,00H
MVI B,06H
MIV C,03H
X: ADD B
DCR C
JNZ X
STA 2055H
HLT
Y: MOV A,M
INX H
CMP M
JC Z
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
Z: DCR D
JNZ Y
DCR C
JNZ X
HLT
29. Sort numbers in descending order in array. Length of array is in memory location
2050H.
LDA 2050H
MVI C,A
DCR C
X: MOV D,C
LXI H,2051H
Y: MOV A,M
INX H
CMP M
JNC Z
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
Z: DCR D
JNZ Y
DCR C
JNZ X
HLT
LXI H,0000H
MVI D,00H
MVI E,43H
MVI C,07H
X: DAD D
DCR C
JNZ X
SHLD 2050H
HLT
31. Multiply two 8 bit numbers stored at address 2050 and 2051. Result is stored at
address 3050 and 3051.
LDA 2050H
MOV E,A
LDA 2051H
MOV C,A
MVI D,00H
LXI H,0000H
X: DAD D
DCR C
JNZ X
SHLD 3050H
HLT
14. Program to find factorial of given number. (Number is in memory location 2050H).
MOV CX,2050H
MOV AX,00H
X: MUL CX
LOOP X
MOV 2055H,AH
MOV 2056H,AL
HLT
.CODE
START:
MOV AX,DATA
MOV DS,AX
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
END START
.DATA
MESSAGE DB "I love my country$"
.CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,MESSAGE
MOV CL,11H
L1:MOV DX,[SI]
MOV AH,02H
INT 21H
INC SI
LOOP L1
MOV AH,4CH
INT 21H
END START
.DATA
MESSAGE DB "BSC CSIT$"
.CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,MESSAGE
MOV CL,08H
L1:MOV BX,[SI]
PUSH BX
INC SI
LOOP L1
MOV CL,05H
L2:POP DX
MOV AH,02H
INT 21H
LOOP L2
MOV AH,4CH
INT 21H
END START
(This program can be used for example program for stact PUSH and POP operation)