0% found this document useful (0 votes)
32 views16 pages

Chap7-Interrupts (Compatibility Mode)

Hardware interrupts are generated by devices to request attention from the CPU. When an interrupt occurs, the CPU suspends its current activities and executes interrupt handler code. Software interrupts mimic hardware interrupts but are triggered by calling interrupt service routines. Common software interrupts include INT 21h for DOS services and INT 10h for BIOS video and disk services. The interrupt vector table stores the addresses of interrupt handler routines.

Uploaded by

Mhd Bazzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views16 pages

Chap7-Interrupts (Compatibility Mode)

Hardware interrupts are generated by devices to request attention from the CPU. When an interrupt occurs, the CPU suspends its current activities and executes interrupt handler code. Software interrupts mimic hardware interrupts but are triggered by calling interrupt service routines. Common software interrupts include INT 21h for DOS services and INT 10h for BIOS video and disk services. The interrupt vector table stores the addresses of interrupt handler routines.

Uploaded by

Mhd Bazzi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Interrupts

2/4/2015 Ali Saleh - Assembly Language Programming 1


Hardware interrupts

• Generated when some attached device (peripheral) needs attention


from the CPU.
• Example: user presses a key on keyboard.
• This causes CPU to suspend its activities and invoke some special
code which will store the keyboard character into a small 16-byte
buffer.

2/4/2015 Ali Saleh - Assembly Language Programming 2


Hardware interrupts

• Example: serial port receives signal from attached device, e.g.


mouse.
• Processing is similar to keyboard interrupt.
• Interrupts may be vectored or prioritized, so that important ones can
“jump the queue”.
• Interrupts may be interrupted.

2/4/2015 Ali Saleh - Assembly Language Programming 3


Software interrupt

• This is not really an interrupt at all, but a call to a standard routine to


handle some basic I/O function.
• It is so named because the actions triggered by it mimic many of
those of a hardware interrupt.
• The most important one for us is int 21h.

2/4/2015 Ali Saleh - Assembly Language Programming 4


The PC BIOS

• BIOS - Basic Input/Output System


• Code is embedded in ROM on PC motherboard
• Supplied by hardware manufacturer such as IBM, or specialist BIOS
company such as Phoenix, Award, AMI.
• Services provided are low-level I/O to disk, video, serial comms,
printer, keyboard.

2/4/2015 Ali Saleh - Assembly Language Programming 5


Common SW Interrupts

• Services are requested via software interrupt; examples later.


• 13h ; diskette services
• 10h ; video services
• 14h ; serial port services
• 16h ; keyboard services
• 17h ; printer controller services

2/4/2015 Ali Saleh - Assembly Language Programming 6


Int 21h

• Example: INT 21H calls DOS for various operating system services,
e.g. open a file.
• Example: INT 10H calls up video services from the system BIOS, for
example write character to screen.
• Addresses of these routines are stored in the interrupt vector table.

2/4/2015 Ali Saleh - Assembly Language Programming 7


Recall Memory Org.

00000 Interrupt Vectors


00400
• 8086 - 1 megabyte of BIOS and DOS Data
memory (220 bytes) DOS

• 00000 – 003ffh Application


Program Area
• Interrupt vector
A0000

B0000 Video
C0000

D0000
Reserved
E0000

F0000 BIOS

2/4/2015 Ali Saleh - Assembly Language Programming 8


Interrupt vectors
CS
Type 255
03ffh IP
CS Type 254
03fch IP

CS

084h IP Type 33 (INT 21H)


CS
080h Type 32
IP

CS
Type 4 (over flow)
010h IP
CS Type 3
00ch IP
CS
008h IP
Type 2 (NMI)
CS
004h IP Type 1 (single-step)
CS
000h IP
Type 0 (divide error)

2/4/2015 Ali Saleh - Assembly Language Programming 9


Example of interrupt vectors adrress

• INT 21h : the address of the DOS function dispatcher is at address


4*21H = 84H

2/4/2015 Ali Saleh - Assembly Language Programming 10


DOS INT 21/Service 01

•DOS INT 21h/ Service 01


•Read single character from keyboard with echo
•AH:01
•Call with INT 21h
•Char is returned in AL

2/4/2015 Ali Saleh - Assembly Language Programming 11


DOS INT 21h/Service 01

• Mov ah,01
• Int 21h
• The above codes will expect the user to enter a character thru the
key board. The entered character will be stored in AL register

2/4/2015 Ali Saleh - Assembly Language Programming 12


DOS INT 21/Service 09

•DOS INT 21h/ Service 09


•Display character string to the screen
•AH:09
•DX: offset of string to be printed; string must be terminated with a ‘$’
character
•Call with INT 21h

2/4/2015 Ali Saleh - Assembly Language Programming 13


DOS INT 21h/Service 09
Example
• .data
• Message db ‘good morning’,’$’
• .code
• ….
• Mov ah,09
• Mov dx,offset message
• Int 21h
• The above codes will print the message ‘good
morning’ to the screen.

2/4/2015 Ali Saleh - Assembly Language Programming 14


BIOS INT 10H/Service 2

• Position screen cursor


• AH:02
• BH:0 (page number)
• DH: row(0-24d)
• DL:column(0-79d)
• Call with interrupt 10

2/4/2015 Ali Saleh - Assembly Language Programming 15


BIOS INT 10H/Service 2
• Mov ah,2
• Mov bh,0 ; video page 0
• Mov dh,20 ; x = 20
• Mov dl,25 ; y = 25
• int 10H ; call BIOS

• Mov ah,09
• Mov dx,offset message
• Int 21h

2/4/2015 Ali Saleh - Assembly Language Programming 16

You might also like