Trap Int21h problem

G

gerotica

I saw a lot of info about the problems of trapping int21h, but I
really don´t understand what happens. I need to watch some serial
operations from another program, wich uses fopen() function as
interface for the comm port. Here´s my code:

void interrupt (*old21)();

void interrupt int21(void)
{
char far* str;
if (_AH == 0x3d)
{
str = MK_FP(_DS, _DX);
if (str == "com1:")
reboot(); //Debugging purpouses
}
old21();
}

void main(void)
{
union REGS regs;
long far* vect;

old21 = getvect(0x21);
vect = MK_FP(0, 0x21 * 4); //using direct address cause setvect
could cause conflict??
*vect = int21 // Not sure about this

reboot = MK_FP(0xffff, 0x0000);

regs.x.ax = 0x3100;
regs.x.dx = 0x1000;
intdos(&regs, &regs);
}

Im not sure if this pointers operations are correct but Im interested
about what happens inside the int21 function.
Tks in advance
 
G

gerotica

Changed the string comparison to:

if (_fstricmp(str, "com1:") == 0)
reboot(); //Debugging purpouses
 
C

CBFalconer

gerotica said:
I saw a lot of info about the problems of trapping int21h, but I
really don´t understand what happens. I need to watch some serial
operations from another program, wich uses fopen() function as
interface for the comm port. Here´s my code:

This has nothing to do with the standard C language. I suspect you
want a group that deals with your particular system, which is
probably some form of MsDos.
 
J

Jack Klein

I saw a lot of info about the problems of trapping int21h, but I
really don´t understand what happens. I need to watch some serial
operations from another program, wich uses fopen() function as
interface for the comm port. Here´s my code:

void interrupt (*old21)();

There is no such thing as an "interrupt" keyword in C.
void interrupt int21(void)
{
char far* str;
if (_AH == 0x3d)

....no "_AH".
{
str = MK_FP(_DS, _DX);
if (str == "com1:")
reboot(); //Debugging purpouses
}
old21();
}

void main(void)

"void main(void)" is not a legal function definition in C, main()
returns int ALWAYS.
{
union REGS regs;
long far* vect;

old21 = getvect(0x21);
vect = MK_FP(0, 0x21 * 4); //using direct address cause setvect
could cause conflict??
*vect = int21 // Not sure about this

reboot = MK_FP(0xffff, 0x0000);

regs.x.ax = 0x3100;
regs.x.dx = 0x1000;
intdos(&regs, &regs);
}

Im not sure if this pointers operations are correct but Im interested
about what happens inside the int21 function.

The C language has no "int21" function. This is a non-standard,
platform specific extension.
Tks in advance

You need to ask about MS-DOS system calls in
These things are defined by and part
of the MS-DOS operating system, not defined by or part of the C
language.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top