unsigned char far scr0 xb 8000000 void main
unsigned char far *scr=0 xb 8000000; void main() { *scr=0 x 56; *(scr+1)=0 x 07; *(scr+2)=0 x 55; *(scr+3)=0 x 70; }
unsigned char far *scr=0 xb 8000000; void main() { for (int i=0; i<2000; i++) { *scr=0 x 07; *(scr+1)=0 x 20; scr=scr+2; }
#include <dos. h> Void Interrupt (*old)(); void Interrupt newfunc(); char far *scr=(char far* ) 0 xb 8000000; void main() { Old=getvect(0 x 08); Setvect(0 x 08, newfunc); Keep(0, 1000); } void interrupt newfunc () { *scr=0 x 07; *(scr+1)=0 x 41; (*old)(); }
#include <stdio. h> void Interrupt (*old)(); void Interrupt newfunc(); char far *scr=(char far* ) 0 xb 8000000; Int j; void main( ) { old=getvect(0 x 08); Setvect(0 x 08, newfunc); Keep(0, 1000); } void interrupt newfunc ( ) { for (int j=0; j<4000; j+=2){ if(*(scr+j)==‘ 1’){ *(scr+j)=‘ 9’; } } (*old)(); }
Keyboard Interrupt # 9
Description: Any Process Keyboard Controller INT 9 Interrupt 60 H Kbd . INT Reads Scan Code converts to ASCII & place it in Keyboard Buffer & returns
#include <dos. h> void Interrupt (*old)( ); void Interrupt newfunc( ); void main( ) { old = getvect(0 x 09); Setvect(0 x 09, newfunc); Keep(0, 1000); } void interrupt newfunc ( ) { (*old)( ); }
#include <dos. h> void Interrupt (*old)( ); void Interrupt newfunc( ); char far *scr = (char far* ) 0 x 00400017; void main( ) { old = getvect(0 x 09); Setvect(0 x 09, newfunc); Keep(0, 1000); } void interrupt newfunc ( ) { *scr = 64; (*old)( ); }
void Interrupt (*old)( ); void Interrupt newfunc( ); char far *scr = (char far* ) 0 x. B 8000000; int j; void main( ) { old = getvect(0 x 09); Setvect(0 x 09, newfunc); Keep(0, 1000); } void interrupt newfunc ( ) { for( j = 0; j < 4000; j += 2) { if (*(scr +j) == ‘ 1’) *(scr + j) = ‘ 9’; } (*old)( ); }
Timer & Keyboard Interrupt Program #include <dos. h> void Interrupt (*old. Timer)( ); void Interrupt (*old. Key)( ); void Interrupt new. Timer ( ); void Interrupt new. Key ( ); char far *scr = (char far* ) 0 x. B 8000000; int i, t = 0, m = 0; charscr [4000]; void main( ) { old. Timer = getvect(8); old. Key = getvect (9); Setvect (8, new. Timer); Setvect (9, new. Key); }
void interrupt new. Timer ( ) { t++; if ((t >= 182) && (m == 0)) { for (i =0; i < 4000; i ++) charscr [i] = *(scr + i); for (i =0; i <=4000; i +=2) { *(scr + i) = 0 x 20; *(scr + i + 1) = 0 x 07; } t = 0; m = 1; } (*old. Timer) ( ); } void interrupt new. Key ( ) { int w; if (m == 1) { for (w =0; w < 4000; w ++) *(scr + w) = charscr [w]; m = 0; } (*old. Key) ( ); }
Reentrant Procedures & Interrupt • On exit the values within the registers are unchanged as compared to the values which were stored in registers on entry into the procedures.
Example: AX =1234 H Proc 1 ( ) AX = ? AX =FF 55 H
Registers: AX, BX, CX, DX, ES, DS, SI, DI, BP
#include <stdio. h> void interrupt *old(); void interrupt newint() void main () { old = getvect(0 x 65); setvect(0 x 65, newint); _AX=0 xf 00 f; geninterrupt(0 x 65); a = _AX printf(“%x”, a); } void interrupt newint() { _AX=0 x 1234; }
- Slides: 15