Trap Int21h problem

Discussion in 'C Programming' started by gerotica, Mar 24, 2007.

  1. gerotica

    gerotica Guest

    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
     
    gerotica, Mar 24, 2007
    #1
    1. Advertisements

  2. gerotica

    gerotica Guest

    Changed the string comparison to:

    if (_fstricmp(str, "com1:") == 0)
    reboot(); //Debugging purpouses
     
    gerotica, Mar 24, 2007
    #2
    1. Advertisements

  3. gerotica

    CBFalconer Guest

    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.
     
    CBFalconer, Mar 24, 2007
    #3
  4. gerotica

    gerotica Guest

    Sorry...
     
    gerotica, Mar 24, 2007
    #4
  5. gerotica

    Jack Klein Guest

    There is no such thing as an "interrupt" keyword in C.
    ....no "_AH".
    "void main(void)" is not a legal function definition in C, main()
    returns int ALWAYS.
    The C language has no "int21" function. This is a non-standard,
    platform specific extension.
    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
     
    Jack Klein, Mar 24, 2007
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.