By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,904 Members | 4,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,904 IT Pros & Developers. It's quick & easy.

Trap Int21h problem

P: n/a
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

Mar 24 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Changed the string comparison to:

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

Mar 24 '07 #2

P: n/a
gerotica wrote:
>
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.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com

Mar 24 '07 #3

P: n/a
Sorry...

Mar 24 '07 #4

P: n/a
On 23 Mar 2007 19:38:56 -0700, "gerotica" <pg*******@gmail.comwrote
in comp.lang.c:
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
news:comp.os.msdos.programmer. 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
Mar 24 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.