Example 21H/42H:: O - Rdonly
Example 21H/42H:: O - Rdonly
#include<stdio.h>
21H/42H:
handle =
open("c:\\abc.txt",O_RDONLY);
#include<fcntl.h>
regs.x.bx = handle;
#include<io.h>
regs.h.ah = 0x42;
#include<BIOS.H>
regs.h.al = 0x01;
#include<DOS.H>
regs.x.cx = 0;
regs.x.dx = 0;
unsigned int handle;
int86(0x21,®s,®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);
}
Example:
BIOS Services
Int # 10H
Service # 01H
Entry
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 = 0x01;
regs.h.ch = 0x01;
regs.h.cl = 0x00;
int86(0x21,®s,®s);
gets(st);
}
Writing ISRs
INT 65H
Offset
Offset
Segment
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:
Offset
Offset
Segment
Segment
far
Intproc
Interrupt
Pointer:
.C
Program:
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 (*oldint65)( );
void interrupt newint65( );
void main()
void interrupt newint65( )
{
{
oldint65 = getvect(0x65);
_AH = 0x09;
setvect(0x65, newint65);
_DX=(unsigned int)st;
keep(0, 1000);
geninterrupt (0x21);
}
}
TSR Programs:
#include<BIOS.H>
#include<DOS.H>
void main()
{
geninterrupt (0x65);
geninterrupt (0x65);
}