INST. OPERANDS FUNCTION
immediate
byte
Interrupt numbered by
immediate byte (0..255).
INT
Algorithm:
Push to stack:
flags register, CS , IP
IF = 0
Transfer control to interrupt procedure
Example:
MOV AH, 0Eh ; teletype.
MOV AL, 'A'
INT 10h ; BIOS interrupt. RET
Just
alter the
Ivn in the
IVT
3/26/2009
By M.H.Aziz
7
How to assign an ISR to a specific INT or
IRQ ?
INT n
CS high
CS low
IP high
IP low
IV2
NMI 2*4
2*4+1
2*4+2
2*4+3 CS high
CS low
IP high
IP low
IVn
n*4
n*4+1
n*4+2
n*4+3
my ISR CS
my ISR IP
CALL INT
1
Can Jump to any
location with in 1MB
address range
Goes to fixed memory
location in the interrupt
vector table to get
address of ISR
2
Used by the
programmer in the
sequence of
instructions in the
program
Externally activated
hardware interrupt can
come at any time
CALL INT
1
Cannot be masked
(disabled)
INTR can be masked
2
Automatically saves
CS: IP of next
instruction
In addition to CS:IP,
Flags can be saved
3
RET is the last
instruction
IRET to pops of F,
CS:IP
INT 00 (divide error)
INT00 is invoked by the microprocessor whenever
there is an attempt to divide a number by zero
ISR is responsible for displaying the message
“Divide Error” on the screen
For single stepping the trap flag must be 1
After execution of each instruction, 8086
automatically jumps to 00004H to fetch 4 bytes for
CS: IP of the ISR
The job of ISR is to dump the registers on to the
screen
x x x x OF DF IF TF SF ZF x AF x PF x CF
0
CF Carry Flag Arithmetic Carry/Borrow
PF Parity Flag Even Number of “1” bits
AF Auxiliary Carry Used with BCD Arithmetic
OF Overflow Flag Arithmetic Overflow
SF Sign Flag Negative Result; Non-Equal Compare
ZF Zero Flag Zero Result; Equal Compare
TF Trap Flag Single Step
DF Direction Flag Causes String Instruction To Decrement
IF Interrupt Flag Interrupt
7
8
15
IP (INT 0) = 1060 CS (INT 0) = F000
IP (INT 4) = 0008 CS (INT 4) = 0070
First method:
PUSHF
POP AX
AND AX, 1111 1110 1111 1111 B
PUSH AX
POP F
Second method:
PUSHF
MOV BP,SP
AND [BP], OFEFFH
POP F
Use OR instruction in place of AND instruction.
PUSHF
POP AX
OR AX, 0000 0001 0000 0000 B
PUSH AX
POPF
INST. OPERANDS FUNCTION
Clear Carry Flag
Set Carry Flag
Complement Carry Flag
CLC
STC
CMC
CLD
STD
Clear Direction Flag
Set Direction Flag
CLI
STI
Clear Interrupt Flag
Set Interrupt Flag
NO
OPERAND
code segment
assume cs:code,ds:code
START: MOV AX,CODE
MOV DS,AX
CONT: LEA SI,CHAR_DISP
MOV DX,3F00H
MOV CX,16
NXT_CH:MOV AX,[SI]
OUT DX,AX
ROR WORD PTR [SI],1
INC DX
INC SI
INC SI
LOOP NXT_CH
CALL DLY
JMP CONT
HLT
DLY: PUSH CX
MOV CX,0
LOOP$
POP CX
RET
CHAR_DISP DW 16 DUP(5555H)
code ends
end start
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
SERVICE
NUMBER
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.
SERVICE
NUMBER
INT 10h / AH = 08h - read character and attribute
at cursor position.
input:
BH = page number.
return:
AH = attribute.
AL = character.
SERVICE
NUMBER
INT 10h / AH = 09h - write character and attribute
at cursor position.
input:
AL = character to display.
BH = page number.
BL = attribute.
CX = number of times to write character.
SERVICE
NUMBER
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 21h / AH=4Ch - return control to the operating
system (stop program).
input:
AL = 0
SERVICE
NUMBER