Documente Academic
Documente Profesional
Documente Cultură
TSR programs must be compiled with .com in extension .com doesnt exceed 64kB size. TSR programs should be run by making its com file and exit the compiler, then run it. Save the program using with .c extension.
Another Example
#include<BIOS.H> #include<DOS.H> char st[80] ={"Hello World$"}; char st1[80] ={"Hello Students!$"}; void interrupt (*oldint65)( ); void interrupt newint65( ); void main() { oldint65 = getvect(0x65); setvect(0x65, newint65); keep(0, 1000);\\made program resident }
3
Continued
void interrupt newint65( ) { if (( _AH ) = = 0) { _AH = 0x09; _DX = (unsigned int) st; geninterrupt (0x21); } else { if (( _AH ) = = 1) { _AH = 0x09; _DX = (unsigned int) st1; geninterrupt (0x21); } } 4 }
2nd Program
#include<BIOS.H> #include<DOS.H> void main() {
_AH = 1;
Different ISR provides different services. Each interrupt invoked points to a number of services for example Interrupt 21h has many services, numbered 0, 1, 2, 3 Sw interrupts have number of services. Service number is stored in AH register For example, Int 21h,
A case statement, checks the service number and exectues the corresponding service
6
Original Routine
Interrupt Interception
New Routine
10
void Interrupt newint(); void Interrupt (*old)(); \\ declare an interrupt pointer void main() { old=getvect(0x08); \\ saving the original ISR address Setvect(0x08,newint);\\ setting the vector Keep(0,100);\\ make program resident in memory } void interrupt newint () { . . . . . . . . . . . . . . \\ perform your operations (*old)();\\ call the original ISR }
*You can also call the (*old)() in the start of newint().
11
12
TIMER interrupt
Hardware Interrupt Invoked by means of hardware Occurs 18.2 times per second(one 18th of a second) Generated by Programmable Interrupt Timer (PIT)
13
etc, while BIOS routines are processed. Segment 40 and offset 0. there are various variables placed here. On this starting address, a variable is placed that shows us the status of the keyboard. Lets c.
14
Insert key Caps Lock Key Num Lock key Scroll lock key
15
Program
#include <dos.h> void Interrupt (*old)(); void Interrupt new(); Char far *scr=(char far* ) 0x00400017; \\ Far Pointer initialized with a double word Void main() { old=getvect(0x08); Setvect(0x08,new); Keep(0,1000); }
16
Void interrupt new (){ *scr=64; (*old)(); } Call original interrupt (*old)() at the end. Can call it in the beginning only in software interrupts.
New Routine
Original Routine
Interrupt Interception
17
18
Isolated I/O
IN
M P I/O ports
OUT
The device or controller uses certain ports to
communicate with processor Control bus signals Signal M means to read/write from memory..(Isolated I/O) Signal I/O means to read/write from I/O .
20
M P
I/O Ports
MOV
21
Memory map
Some portion of memory is reserved, so place decreased
In isolated we used ports instead
number of signals. Complicated hardware design. Simple hardware memory map design instead As number of control increases
Monitor uses memory mapped I/O MonitorVGAMemory
22
23
In text mode
80 columns, 25 rows (characters)80*25 characters
25
26
X X X X X X X X
Back Color Bold Color
Program
unsigned int far *scr=0xb8000000; void main() { (*scr)=0x0756; (*(scr+1))=0x7055; } This example will generate the output VU
28
//56 = B //55 = U
Explaination
The far pointer scr is assigned
0xb800H in the high word (segment address) 0x0000H in the low word (offset address).
The word at this address is loaded with the value 0x0756H next word is loaded by the value 0x7055H,
0x07 is the attribute byte meaning black back color and white fore color and the byte 0x70h means white back color and black fore color. ).