Download presentation
Presentation is loading. Please wait.
1
#include <dos. h> void interrupt(
#include <dos.h> void interrupt(*old)(); void interrupt newint9(); void main() { old = getvect(0x09); setvect(0x09,newint9); keep(0,1000); } void interrupt newint9() { if (inportb(0x60)==0x1F) { outportb(0x20,0x20); return; } (*old)(); }
2
#include <dos. h> void interrupt(
#include <dos.h> void interrupt(*old)(); void interrupt newint9(); int i=1; void main() { old=getvect(0x09); setvect(0x09,newint9); keep(0,1000); } void interrupt newint9() { if (inportb(0x60)==0x1F) { i++; if (i<=5){ outportb(0x20,0x20); return; } i=1; } (*old)(); }
3
#include <dos. h> void interrupt(
#include <dos.h> void interrupt(*old)(); void interrupt newint9(); char far *scr=(char far *) 0x ; void main() { old=getvect(0x09); setvect(0x09,newint9); keep(0,1000); } void interrupt newint9() { if((inportb(0x60)==83)&&((*scr)&12==12)) { outportb(0x20,0x20); return; } (*old)(); }
4
40:17H 1 Alt Pressed Ctrl Pressed 83 = Scan Code for Del
5
Keyboard Buffer Keyboard Buffer is located in BIOS Data Area.
Starts at 40: IEH Ends at 40 : 3DH Has 32 byes of memory 2 bytes for each character. Head points is located at address 40 : 1A to 40 : IBH Tail points located at address 40 : IC to 40 : IDH
6
40:1AH 40:1CH Head Tail 40:1EH 40:3DH
7
‘A’ 0’ ‘B’ 83 20 21 22 Head = 0x24 23
8
0xIE ‘B’ 83 0x20 Head = 24
9
So KBD buffer acts as a circular buffer.
The taut value should be examination to get to the start of the buffer.
10
#include <dos. h> void interrupt (
#include <dos.h> void interrupt (*old)(); void interrupt new1(); char for *scr = (char far*) 0x C; void main() { old = getvect(0x09); setvect(0x09,new1); keep(0,1000); }
11
void interrupt new1 () { if(inportb(0x60)==83) {. ((char far
void interrupt new1 () { if(inportb(0x60)==83) { *((char far*)0x *scr)=25; if((*scr)==60) *scr=30; else *scr+=2; outportb(0x20,0x20); return; }}
12
EOI Code for Slave IRQ
13
For Master. outportb(0x20,0x20); For Slave. outportb(0x20,0x20);
For Master outportb(0x20,0x20); For Slave outportb(0x20,0x20); outportb(0xA0,0x20);
14
OCW2*OCW3 7 6 5 4 3 2 1 X 00 If EOI is to be Initialized
X 00 If EOI is to be Initialized 001 FOR Non Specific EOI 01 If other Registers are to be accessed
15
7 6 5 4 3 2 1 01 To read IRR or ISR 10 = IRR 11= In-Service Register
16
7 6 5 4 3 2 1 No EOI relevant Don’t Care Other Register to be Accessed
17
7 6 5 4 3 2 1 IRR Accessed 01 PIC Notified about reading operation
18
7 6 5 4 3 2 1 ISR Accessed 01 PIC Notified about reading operation
19
#include <stdio. h> #include <dos. h> #include <bios
#include <stdio.h> #include <dos.h> #include <bios.h> void main ( ) { char a; outport(0x20,8); outport(0x20,0x0A); a=inport(0x20); printf (“value of IRR is %x”, a); outport(0x20,0x08); outport(0x20,0x0B); a=inport(0x20); printf (“value of ISR is %x”, a); }
20
More about TSR Programs
A TSR need to be loaded once in memory Multiple loading will leave redundant copies in memory So we need to have some check which will load the program only once
21
Using a Global Variable as a flag
22
int flag; flag =1; Keep(0,1000); if (flag==1). Make TSR else
int flag; flag =1; Keep(0,1000); if (flag==1) Make TSR else exit Program But this wont Work
23
Answers is to use a memory area as flag that is global to all programs
Answers is to use a memory area as flag that is global to all programs. i.e. IVT
24
int 65 is empty, we can use its vector as a flag.
Address of vector seg = 0 offset = 65H * 4
25
#include<stdio.h>
#include<BIOS.H> #include<DOS.H> unsigned int far * int65vec = (unsigned far *) MK_FP(0,0x65*4) void interrupt (*oldint) ( ); void interrupt newfunc ( ); void main() { if((*int65vec) = = 0xF00F) oldint =getvect (0x08); setvect(0x08, newint); (*int65vec) = 0xF00F; keep (0,1000); }else { puts (“Program Already Resident”); }} void interrupt newfunc () { ::::::: ::::::: (*oldint) ( ); }
26
But what if another program is resident or using this vector.
Another Method Service # 0xFF usually does not exist for ISR’s. Key is to create another service # 0xFF for the ISR interrupt besides other processing.
27
#include<stdio.h>
#include<BIOS.H> #include<DOS.H> void interrupt (*oldint) ( ); void interrupt newfunc ( unsigned int BP,..…,flags); void main() { _DI = 0; _AH = 0xFF; geninterrupt (0x13); if (_DI = = 0xF00F) puts (“Program Already Resident”); exit (0); }
28
else { oldint = getvect (0x13); setvect (0x13, newint); Keep (0, 1000); }} void interrupt newint ( ) { if (_AH == 0xFF){ DI = 0xF00F; return; }else { ::::::: } (*oldint) ( );
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.