- Interrupt Vector Table(1k bytes, 00000-003FF)
- BIOS and DOS data
- Software BIOS
- MS-DOS Kernel
- Resident Command processor
- Transient programs
- Video graphics and text
- Reserved( Device Controllers)
- ROM BIOS(F0000 to FFFFF)
Interrupt
>If you call your friend and his/her mom says he/she is not home, what do you do?
>Do something else, and get interrupted when he/she is back and returns your call.
>When you are interrupted by a phone ring, you must somehow know who is interrupting you and what he/she wants.
>Based on the type of interrupts, you then do the required operations.
>After serving the interrupt, you return to the operations before interrupt.
>You may be interrupted by external events, e.g. phone ring, or internal events, e.g. fetch a soda while studying.
>Analog in processor:
>>Interrupts may be triggered by hardware, e.g. I/O devices, which is outside of your program.
>>Interrupts may also be trigger by software, e.g. program faults or system service calls, which is generated by your program itself.
>Software interrupt:
>>A call to an OS procedure (interrupt handler), mainly for I/O
Hardware Device Initialization
>At startup, a hardware device is assigned:
>>An IRQ by which it can signal the CPU that it needs attention
>>Some I/O addresses by which the CPU and the device can communicate
>>Some memory addresses that indicate where the program to manage the device can be stored
>>Perhaps a DMA channel to speed up sending its data to memory
INT Instruction
>Executes a software interrupt to request MS-DOS services
>>The code that handles the interrupt is called an interrupt handler (or interrupt service routine (ISR))
>Syntax: INT number (number =0..FFh)
>>The Interrupt Vector Table (IVT) maps an interrupt number to a 32-bit segment-offset address for each interrupt handler.
INT Vectors
>In Interrupt Vector Table in 00000h-003FFh (1KB)
>For the execution of INT 00-FF
>Each INT uses a 4-byte vector (CS:IP):
>>2 bytes for IP
>>2 bytes for CS
>Actual code (Service Routine) is in CS:IP
>IRET at the end of INT Service Routine
Interrupt Vectoring Process
Step 1:
>The operand of INT is multiplied by 4 to locate the matching interrupt vector table entry
Step 2:
>CPU pushes flags and a 32-bit return address on stack, disables hardware interrupts, and calls using the address stored at location (10h * 4) in the interrupt vector table (F000:F065)
Step 3:
>Interrupt handler executes until IRET is reached
Step 4:
>Pop the stack and return to application program
Common Interrupts
Software interrupts will call interrupt service routines (ISRs) either in BIOS or DOS
>INT 10h Video Services
>INT 16h Keyboard Services
>INT 17h Printer Services
>INT 1Ah Time of Day
>INT 1Ch User Timer Interrupt
>INT 21h MS-DOS Services
Example: Hello World
.model small
.stack 100h
.386
.data
message BYTE "Hello, world!",0dh,0ah
.code
main PROC
mov ax,@data ; initialize DS
mov ds,ax
mov ah,40h ; write to file/device
mov bx,1 ; output handle
mov cx,SIZEOF message ; number of bytes
mov dx,OFFSET message ; addr of buffer
int 21h
.exit
main ENDP
END main

No comments:
Post a Comment