Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

Example

#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,&regs,&regs);
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,&regs,&regs);
gets(st);
}

Use of ISRs for Library


Function

Writing ISRs

INT 65H

Getting Interrupt Vector:


INT #

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:

void interrupt (*intptr) ( )


intptr = getvect (0x08);
(*intptr) ( );

Setting Interrupt Vector:


INT #

Offset
Offset
Segment
Segment

far
Intproc

Interrupt
Pointer:

void interrupt newint ( )


{
}
setvect(0x08, newint);

.C

Program:

void interrupt *oldint65( );


char st[80] = {Hello World$};
void interrupt newint65(void);
void interrupt newint65( )
void main()
{
{
_AH = 0x09;
oldint65 = getvect(0x65);
_DX=(unsigned int)st;
setvect(0x65, newint65);
geninterrupt (0x21);
geninterrupt (0x65);
}
geninterrupt (0x65);
geninterrupt (0x65);
setvect(0x65, oldint65);
}

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);
}

You might also like