MRIT
Page 1
MICROPROCESSOR
MRIT
Page 2
MICROPROCESSOR
DOS AND BIOS INTERRUPTS:
Interrupt Types
Description
BIOS Interrupts
0h-1Fh
DOS Interrupts
20h-3Fh
Reserved
40h-7Fh
ROM BASIC
80h-F0h
not used
F1h-FFh
Interrupt Vector
The CPU does not generate the interrupt routine's address directly from the interrupt
number
o Doing so would mean that a particular interrupt routine must be placed in exactly the same location
in every computer
o Instead, the CPU uses the interrupt number to calculate the address of a
memory location that contains the actual address of the interrupt routine
INT 10h / AH = 0 - set video mode.
input:
AL = desired video mode.
these video modes are supported:
00h - text mode. 40x25. 16 colors. 8 pages.
03h - text mode. 80x25. 16 colors. 8 pages.
13h - graphical mode. 40x25. 256 colors. 320x200 pixels. 1 page.
example:
mov al, 13h
mov ah, 0
int 10h
INT 10h / AH = 01h - set text-mode cursor shape.
input:
CH = cursor start line (bits 0-4) and options (bits 5-7).
CL = bottom cursor line (bits 0-4).
when bit 5 of CH is set to 0, the cursor is visible. when bit 5 is 1, the
cursor is not visible.
; hide blinking text cursor:
mov ch, 32
mov ah, 1
int 10h
; show standard blinking text cursor:
mov ch, 6
mov cl, 7
mov ah, 1
int 10h
; show box-shaped blinking text cursor:
mov ch, 0
mov cl, 7
mov ah, 1
MRIT
Page 3
MICROPROCESSOR
int 10h
INT 10h / AH = 2 - set cursor position.
input:
DH = row.
DL = column.
BH = page number (0..7).
example:
mov dh, 10
mov dl, 20
mov bh, 0
mov ah, 2
int 10h
INT 10h / AH = 03h - get cursor position and size.
input:
BH = page number.
return:
DH = row.
DL = column.
CH = cursor start line.
CL = cursor bottom line.
INT 10h / AH = 05h - select active video page.
input:
AL = new page number (0..7).
the activated page is displayed.
INT 10h / AH = 06h - scroll up window.
INT 10h / AH = 07h - scroll down window.
input:
AL = number of lines by which to scroll (00h = clear entire window).
BH = attribute used to write blank lines at bottom of window.
CH, CL = row, column of window's upper left corner.
DH, DL = row, column of window's lower right corner.
INT 10h / AH = 08h - read character and attribute at cursor position.
input:
BH = page number.
return:
AH = attribute.
AL = character.
INT 10h / AH = 09h - write character and attribute at cursor position.
input:
AL = character to display.
BH = page number.
BL = attribute.
MRIT
Page 4
MICROPROCESSOR
CX = number of times to write character.
INT 10h / AH = 0Ah - write character only at cursor position.
input:
AL = character to display.
BH = page number.
CX = number of times to write character.
INT 10h / AH = 0Ch - change color for a single pixel.
input:
AL = pixel color
CX = column.
DX = row.
mov al, 13h
mov ah, 0
int 10h ; set graphics video mode.
mov al, 1100b
mov cx, 10
mov dx, 20
mov ah, 0ch
int 10h ; set pixel.
INT 10h / AH = 0Dh - get color of a single pixel.
input:
CX = column.
DX = row.
output:
AL = pixel color
INT 10h / AH = 0Eh - teletype output.
input:
AL = character to write.
this functions displays a character on the screen, advancing the cursor and
scrolling the screen as necessary. the printing is always done to current active
page.
example:
mov al, 'a'
mov ah, 0eh
int 10h
INT 10h / AH = 13h - write string.
input:
AL = write mode:
bit 0: update cursor after writing;
bit 1: string contains attributes.
BH = page number.
BL = attribute if string contains only characters (bit 1 of AL is zero).
CX = number of characters in string (attributes are not counted).
MRIT
Page 5
MICROPROCESSOR
DL,DH = column, row at which to start writing.
ES:BP points to string to be printed.
example:
mov al, 1
mov bh, 0
mov bl, 0011_1011b
mov cx, msg1end - offset msg1 ; calculate message size.
mov dl, 10
mov dh, 7
push cs
pop es
mov bp, offset msg1
mov ah, 13h
int 10h
jmp msg1end
msg1 db " hello, world! "
msg1end:
INT 10h / AX = 1003h - toggle intensity/blinking.
input:
BL = write mode:
0: enable intensive colors.
1: enable blinking (not supported by the emulator and windows
command prompt).
BH = 0 (to avoid problems on some adapters).
mov ax, 1003h
mov bx, 0
int 10h
INT 21h / AH=1 - read character from standard input, with echo, result is
stored in AL.
if there is no character in the keyboard buffer, the function waits until any key is
pressed.
example:
mov ah, 1
int 21h
INT 21h / AH=2 - write character to standard output.
entry: DL = character to write, after execution AL = DL.
example:
mov ah, 2
mov dl, 'a'
int 21h
MRIT
Page 6
MICROPROCESSOR
8259 (PROGRAMMABLE INTERRUPT CONTROLLER)
The 8259A is a device specifically designed for usein real time, interrupt driven microcomputer
systems. It manages eight levels or requests and has built-in features for expandability to other 8259A's
(up to 64 levels). It is programmed by the system's software as an I/O peripheral. A selection of priority
modes is available to the programmer so that the manner in which the requests are processed by the 8259A
can be configured to match his system requirements. The priority modes can be changed or reconfigured
dynamically at any time during the main program. This means that the complete interrupt structure canbe
defined as required, based on the total system environment.
MRIT
Page 7
MICROPROCESSOR
INT (Interrupt)
This output goes directly to the CPU interrupt input. The VOH level on this line is designed to be
fully compatible with the 8080A, 8085A and 8086 input levels.
INTA (Interrupt Acknowledge)
INTA pulses will cause the 8259A to release vectoring information onto the data bus. The format
of this data depends on the system mode of the 8259A.
Data Bus Buffer
This 3-state, bidirectional 8-bit buffer is used to interface the 8259A to the system Data Bus.
Control words and status information are transferred through the Data Bus Buffer.
Read/Write Control Logic
The function of this block is to accept OUTput commands from the CPU. It contains the
Initialization Command Word (ICW) registers and Operation Command Word (OCW) registers which
store the various control formats for device operation. This function block also allows the status of the
8259A to be transferred onto the Data Bus.
CS (Chip Select)
A LOW on this input enables the 8259A. No reading or writing of the chip will occur unless the
device is selected.
WR (Write)
A LOW on this input enables the CPU to write control words (ICWs and OCWs) to the 8259A.
RD (READ) A LOW on this input enables the 8259A to send the status of the Interrupt Request Register
(IRR), In Service Register (ISR), the Interrupt Mask Register (IMR), or the Interrupt level onto the Data
Bus.
A0
This input signal is used in conjunction with WR and RD signals to write commands into the
various command registers, as well as reading the various status registers of the chip. This line can be tied
directly to one of the address lines.
The Cascade Buffer/Comparator
This function block stores and compares the IDs of all 8259A's used in the system. The associated
three I/O pins (CAS0-2) are outputs when the 8259A is used as a master and are inputs when the 8259A is
used as a slave. As a master, the 8259A sends the ID of the interrupting slave device onto the CAS02
lines. The slave thus selected will send its preprogrammed subroutine address onto the Data Bus during
the next one or two consecutive INTA pulses. (See section ``Cascading the 8259A''.)
MRIT
Page 8
MICROPROCESSOR
CASCADING THE 8259
The 8259A can be easily interconnected in a system of one master with up to eight slaves to handle
up to 64 priority levels.
The master controls the slaves through the 3 line cascade bus (CAS2 - 0). The cascade bus acts like
chip selects to the slaves during the INTA sequence.
In a cascade configuration, the slave interrupt outputs (INT) are connected to the master interrupt request
inputs. When a slave request line is activated and afterwards acknowledged, the master will enable the
corresponding slave to release the device routine address during bytes 2 and 3 of INTA. (Byte 2 only for
80C86/88/286).
When the slave receives an interrupt signal on one of its IR inputs, it checks mask condition and
priority of the interrupt request. If the interrupt is unmasked and its priority is higher than any other
interrupt level being serviced in slave, then the slave will send an INT signal to the IR input of a master. If
that IR input of the master is unmasked and if that input is a higher priority than any other IR inputs
currently being serviced, then the master will send an INT signal to the 8086 INTR input .if the INTR
interrupt is enabled, the 8086will go through its INTR interrupt procedure and sends out two INTA BAR
pulses to both the master and the slave. The slave ignores the first
Interrupt acknowledge pulse but the master outputs a 3 bit slave id number on the CAS0-CAS2
lines. Sending the 3 bit ID no enables the slave. When the slave receives the second INTA BAR pulse
from the 8086, the slave will send the desired type number to the 8086 on eight data lines.
If an interrupt signal is applied directly to one of the IR inputs of the master, the master. The
master will send the desired interrupt type to the 8086 when it receives the second INTA BAR pulse from
the 8086.
MRIT
Page 9
MICROPROCESSOR
8259 PROGRAMMING
The 8259A accepts two types of command words generated by the CPU:
1. Initialization Command Words (ICWs): Before normal operation can begin, each 8259A in the system
must be brought to a starting point by a sequence of 2 to 4 bytes timed by WR pulses.
2. Operation Command Words (OCWs): These are the command words which command the 8259A to
operate in various interrupt modes. These modes are:
a. Fully nested mode
b. Rotating priority mode
c. Special mask mode
d. Polled mode
The OCWs can be written into the 8259A anytime after initialization.
MRIT
Page 10
MICROPROCESSOR
INITIALIZATION COMMAND WORDS (ICWS)
Whenever a command is issued with A0 e 0 and D4 e 1, this is interpreted as Initialization Command
Word 1 (ICW1). ICW1 starts the initialization sequence during which the following automatically occur.
a. The edge sense circuit is reset, which means that following initialization, an interrupt request (IR) input
must make a low-to-high transition to generate an interrupt.
b. The Interrupt Mask Register is cleared.
c. IR7 input is assigned priority 7.
d. The slave mode address is set to 7.
e. Special Mask Mode is cleared and Status Read is set to IRR.
f. If IC4 e 0, then all functions selected in ICW4 are set to zero. (Non-Buffered mode*, no AutoEOI, MCS-80, 85 system).
*NOTE: Master/Slave in ICW4 is only used in the buffered mode.
Initialization Command Words 1 and 2 (ICW1, ICW2)
In an MCS 80/85 system, the 8 request levels will generate CALLs to 8 locations equally spaced in
memory. These can be programmed to be spaced at intervals of 4 or 8 memory locations, thus the 8
routines will occupy a page of 32 or 64 bytes, respectively. The address format is 2 bytes long (A0A15).
When the routine interval is 4, A0A4 are automatically inserted by the 8259A, while A5A15 are
programmed externally. When the routine interval is 8, A0A5 are automatically inserted by the 8259A,
while A6A15 are programmed externally.
The 8-byte interval will maintain compatibility with current software, while the 4-byte interval is best for
a compact jump table.
In an 8086 system A15A11 are inserted in the five most significant bits of the vectoring byte and the
8259A sets the three least significant bits according to the interrupt level. A10A5 are ignored and ADI
(Address interval) has no effect.
LTIM: If LTIM e 1, then the 8259A will operate in the level interrupt mode. Edge detect logic
on the interrupt inputs will be disabled. ADI: CALL address interval. ADI e 1 then interval e 4; ADI e 0
then interval e 8. SNGL: Single. means that this is the only 8259A in the system. If SNGL e 1 no ICW3
will be issued.
IC4: If this bit is setICW4 has to be read. If ICW4 is not needed, set IC4 e 0.
MRIT
Page 11
MICROPROCESSOR
Page 12
MICROPROCESSOR
MRIT
Page 13
MICROPROCESSOR
MRIT
Page 14
MICROPROCESSOR
MRIT
Page 15
MICROPROCESSOR
Page 16
MICROPROCESSOR
Specific EOI command is issued the 8259A will automaticallyreset the highest IS bit of those that are set,
since in the fully nested mode the highest IS level was necessarily the last level acknowledged and
serviced. A non-specific EOI can be issued with OCW2 (EOI e 1, SL e 0, R e 0). When a mode is used
which may disturb the fully nested structure, the 8259A may no longer be able to determine the last level
acknowledged. In this case a Specific End of Interrupt must be issued which includes as part of the
command the IS level to be reset. A specific EOI can be issued with OCW2 (EOI e 1, SL e 1, R e 0, and
L0L2 is the binary level of the IS bit to be reset). It should be noted that an IS bit that is masked by an
IMR bit will not be cleared by a non-specific EOI ifthe 8259A is in the Special Mask Mode.
Automatic End of Interrupt (AEOI) Mode
If AEOI e 1 in ICW4, then the 8259A will operate in AEOI mode continuously until
reprogrammed by ICW4. in this mode the 8259A will automatically perform a non-specific EOI operation
at the trailing edge of the last interrupt acknowledge pulse (third pulse in MCS-80/85, second in 8086).
Note that from a system standpoint, this mode should be used only when a nested multilevel interrupt
structure is not required within a single 8259A. The AEOI mode can only be used in a master 8259A and
not a slave. 8259As with a copyright date of 1985 or later will operate in the AEOI mode as a master or a
slave.
Automatic Rotation (Equal Priority Devices)
In some applications there are a number of interrupting devices of equal priority. In this mode a
device, after being serviced, receives the lowest priority, so a device requesting an interrupt will have to
wait, in the worst case until each of 7 other devices are serviced at most once . For example, if the priority
and ``in service'' status is:
Before Rotate (IR4 the highest prioirity requiring service)
MRIT
Page 17
MICROPROCESSOR
There are two ways to accomplish Automatic Rotation using OCW2, the Rotation on Non-Specific EOI
Command (R e 1, SL e 0, EOI e 1) and the Rotate in Automatic EOI Mode which is set by (R e 1, SL e 0,
EOI e 0) and cleared by (R e 0, SL e 0, EOI e 0).
Specific Rotation(Specific Priority)
The programmer can change priorities by programming the bottom priority and thus fixing all
other priorities; i.e., if IR5 is programmed as the bottom priority device, then IR6 will have the highest
one. The Set Priority command is issued in OCW2 where:
R e 1, SL e 1, L0L2 is the binary priority level code of the bottom priority device. Observe that in this
mode internal status is updated by software control during OCW2. However, it is independent of the End
of Interrupt (EOI) command (also executed by OCW2). Priority changes can be executed during an EOI
command by using the Rotate on Specific EOI command in OCW2 (R e 1, SL e 1, EOI e 1 and LOL2 e
IR level to receive bottom priority).
Interrupt Masks Each Interrupt Request input can bem masked individually by the Interrupt Mask Register
(IMR) programmed through OCW1. Each bit in the IMR masks one interrupt channel if it is set (1). Bit 0
masks IR0, Bit 1 masks IR1 and so forth. Masking an IR channel
does not affect the other channels operation.
Special Mask Mode
Some applications may require an interrupt service routine to dynamically alter the system priority
structure during its execution under software control. For example, the routine may wish to inhibit lower
priority requests for a portion of its execution but enable some of them for another portion. The difficulty
here is that if an Interrupt Request is acknowledged and an End of Interrupt command did not reset its IS
bit (i.e., while executing a service routine), the 8259A would have inhibited all lower priority requests
with no easy way for the routine to
enable them. That is where the Special Mask Mode comes in. In the special Mask Mode, when a mask bit
is set in OCW1, it inhibits further interrupts at that level and enables interrupts fromall other levels (lower
as well as higher) that are not masked. Thus, any interrupts may be selectively enabled by loading the
mask register. The special Mask Mode is set by OWC3 where:
SSMM e 1, SMM e 1, and cleared where SSMM e 1, SMM e 0.
MRIT
Page 18
MICROPROCESSOR
Poll Command
In Poll mode the INT output functions as it normally does. The microprocessor should ignore this
output. This can be accomplished either by not connecting the INT output or by masking interrupts within
the microprocessor, thereby disabling its interrupt input. Service to devices is achieved by software using
a Poll command. The Poll command is issued by setting P e `1'' in OCW3. The 8259A treats the next RD
pulse to the 8259A (i.e., RD e 0, CS e 0) as an interrupt acknowledge, sets the appropriate IS bit if there is
a request, and reads the priority level. Interrupt is frozen from WR to RD.
This mode is useful if there is a routine command common to several levels so that the INTA sequence is
not needed (saves ROM space). Another application is to use the poll mode to expand the number of
priority levels to more than 64.
EXERCISE
1. What is the difference between Hardware and software Interrupt?
2. Explain about nested interrupt?
3. What are the interrupt Vector addresses of the following interrupts in the 8086.
I.
INTO
II.
NMI
III.
INT 20H
IV.
INT 55H
4. How do you set or clear the Interrupt flag IF? What is its importance in the
Interrupt structure of 8086?
5. Explain the Interrupt response sequence of 8086.
6. What is interrupt vector table of 8086? Explain its structure.
7. Draw and discuss interrupt structure of 8086 in detail.
8. Explain the block diagram of 8259.
9. Explain the different types of DOS and BIOS interrupts.
10. Explain the Interrupt priority resolver unit.
Multiple-choice questions
MRIT
D. INT 15H
Page 19
MICROPROCESSOR
2. The total number of software interrupts in 8086 are______.
A. 255
B. 256
C. 254
D. 257
B. DF
C. IF
D. INTA
B. Single step
C. INTO
D. Divide by zero
B. Single step
C. INTO
D. Divide by zero
B. Single step
C. INTO
D. Divide by zero
B. Single step
C. INTO
D. Divide by zero
D. 4
MRIT
D. All
Page 20
MICROPROCESSOR
10. When do the 8259 return the interrupt type number?
A. After the arrival of INTA
B. When the LOCK pin goes low
C. While the CPU is transferring lower byte
D. While the CPU is transferring higher byte
11. Which interrupt controller works with 8 and 16-bit processor?
A. 8259
B. 8259A
C. 8259B
D. All
12. Which of the following block accepts input from IRQ lines?
A. Priority Resolver
B. IR2
C. IR1
D. IR7
D. Nil
16. Which block handles the release of Interrupt vector address on to the data bus?
A. Priority Resolver
B. 16
C. 32
D. 14
MRIT
Page 21
MICROPROCESSOR
A. Cascade mode
B. interfacing 8 slaves
C. Both
D. Not used
B. 00
C. 11
D. 10
B. 00
C. 11
D. 10
21. Which of the following command word contains the control bits for type of
Triggering?
A. ICW1
B. ICW3
C. ICW2
D. ICW4
22. The command word that stores details of vector addresses is________.
A. ICW1
B. ICW3
C. ICW2
D. ICW4
23. Which of the two command words are compulsory in initialization sequence of
8259A?
A. ICW1 & ICW2
B. ICW2 &ICW3
24. The use of cascaded signals (CAS0-CAS2) is indicated in ______ command word.
A. ICW1
B. ICW3
C. ICW2
D. ICW4
Page 22
MICROPROCESSOR
C. In cascaded mode
D. None
26. Which bit of ICW1 Specifies the use of ICW4?
A. 1
B. 2
C. 3
D. 4
D. None
D. For addressing
29. How many operation command words are used for accepting interrupts?
A. 1
B. 2
C. 3
D. 4
C. Mode selection
31. In OCW2 the three bits R, SL, EOI are used to_______.
A. Enable/disable interrupts
B. mask unwanted requests
C. Mode selection
D. ICW4
33. The pin that differentiates between master and slave mode is ________.
A. INT
B. PS/EN
C. CAS0-CAS2
D. CS
D. INTR
35. What is the value that is to be loaded into AH to perform HALT operation?
MRIT
Page 23
MICROPROCESSOR
A. 01H
B. 4CH
C. 03H
D. 4DH
D. All
B. Single step
C. INTO
D. Divide by zero
38. What are the contents of IP and CS while execution of INT 20H?
A. IP = 0040H, CS=0042H
B. IP = 0042H, CS=0040H
C. IP = 0040H, CS=0038H
D. IP = 0040H, CS=0038H
39. How many memory locations are needed to store all software interrupts?
A. 2048
B. 4096
C. 1024
D. None
B. DF
C. IF
D. None
Answers:
1. C
2. B
3. C
4. D
5. A
6. B
7. A
8. B
9. D
10. A
MRIT
Page 24
MICROPROCESSOR
11. B
12. C
13. D
14. A
15. B
16. D
17. A
18. C
19. A
20. D
21. A
22. C
23. A
24. B
25. C
26. D
27. C
28. C
29. C
30. B
31. C
32. B
33. B
34. D
35. B
36. A
37. A
38. A
39. C
40. A
MRIT
Page 25
MICROPROCESSOR
Interrupt Response:
Main Program
Push flags
Clear IF
Clear TF
Push CS
Push IP
Fetch ISR Address
POP IP
POP CS
POP Flags
MRIT
PUSH Registers
POP Registers
IRET
Page 26
MICROPROCESSOR
Interrupt Vector (Pointer) Table:
003FF
003FE
003FD
003FC
.
.
.
00083
00082
00081
00080
0007F
0007E
0007D
0007C
.
.
.
00017
00016
00015
00014
MRIT
CSH
CSL
IPH
IPL
.
.
.
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
.
.
.
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
CSH
CSL
IPH
IPL
Type 255Vector
Type 255Vector
Type 255Vector
Type 255Vector
.
.
.
Type 32 Vector
Type 32 Vector
Type 32 Vector
Type 32 Vector
Type 31 Vector
Type 31 Vector
Type 31 Vector
Type 31 Vector
.
.
.
Type 5 Vector
Type 5 Vector
Type 5 Vector
Type 5 Vector
Type 4 Vector
Type 4 Vector
Type 4 Vector
Type 4 Vector
Type 3 Vector
Type 3 Vector
Type 3 Vector
Type 3 Vector
Type 2 Vector
Type 2 Vector
Type 2 Vector
Type 2 Vector
Type 1 Vector
Type 1 Vector
Type 1 Vector
Type 1 Vector
Type 5 Vector
Type 5 Vector
Type 5 Vector
Type 5 Vector
Page 27
MICROPROCESSOR
MRIT
Page 28
MICROPROCESSOR
MRIT
Page 29