Example 21 H42 H handle openc abc txt
Example 21 H/42 H: handle = open("c: \abc. txt", O_RDONLY); regs. x. bx = handle; regs. h. ah = 0 x 42; regs. h. al = 0 x 01; regs. x. cx = 0; regs. x. dx = 0; unsigned int handle; int 86(0 x 21, ®s); void main() *((int*)(&size)) = regs. x. ax; { *(((int*)(&size))+1) =regs. x. dx; REGS regs; unsigned long int size; Printf ("Size is %d“ , size); } #include<stdio. h> #include<fcntl. h> #include<io. h> #include<BIOS. H> #include<DOS. H>
Example: BIOS Services Int # 10 H Entry Service # 01 H AH = 01 CH = Beginning Scan Line CL = Ending Scan Line On Exit Unchanged
Example: void main() { char st[80]; union REGS regs; regs. h. ah = 0 x 01; regs. h. cl = 0 x 00; int 86(0 x 21, ®s); gets(st); }
Use of ISR’s for Library Function Writing ISR’s INT 65 H
Getting Interrupt Vector: INT # Offset Segment far Intproc
Integer Pointer: int j; int *p; j = 25; p = 2000; *p = 50;
Function Pointer: void myfunc() { } void (*funcptr) ( ) funcptr = myfunc; (*funcptr) ( ); myfunc();
Interrupt Pointer: void interrupt (*intptr) ( ) intptr = getvect (0 x 08); (*intptr) ( );
Setting Interrupt Vector: INT # Offset Segment far Intproc
Interrupt Pointer: void interrupt newint ( ) { } setvect(0 x 08, newint);
. C Program: void interrupt *oldint 65( ); char st[80] = {“Hello World$”}; void interrupt newint 65(void); void interrupt newint 65( ) void main() { { _AH = 0 x 09; oldint 65 = getvect(0 x 65); _DX=(unsigned int)st; setvect(0 x 65, newint 65); geninterrupt (0 x 21); geninterrupt (0 x 65); } geninterrupt (0 x 65); setvect(0 x 65, oldint 65); }
Keep: Keep (0, 100); Keep (return code, no. of parse);
TSR Programs: #include<BIOS. H> #include<DOS. H> char st[80] ={"Hello World$"}; void interrupt (*oldint 65)( ); void interrupt newint 65( ); void main() void interrupt newint 65( ) { { oldint 65 = getvect(0 x 65); _AH = 0 x 09; setvect(0 x 65, newint 65); _DX=(unsigned int)st; keep(0, 1000); geninterrupt (0 x 21); } }
TSR Programs: #include<BIOS. H> #include<DOS. H> void main() { geninterrupt (0 x 65); }
- Slides: 14