software interruptions??

This is a discussion on software interruptions?? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I need to use software interruptions in c, does someone know about a manual or a webpage about them?? I ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    2

    software interruptions??

    I need to use software interruptions in c, does someone know about a manual or a webpage about them??

    I found a function that uses a interruption to issue the tcp/ip packets, to connect and transmitt data. But i want to know more about interruptions.

    what are the arguments??
    here is the source:


    void interrupt zzz(bp, di, si, ds, es, dx, cx, bx, ax, ip, cs, flags)
    unsigned short bp, di, si, ds, es, dx, cx, bx, ax, ip, cs, flags;
    {
    printf("Reciever ax=%d Packet Size %d\n",ax,cx);
    if ( ax == 0) {
    es=FP_SEG(e);
    di=FP_OFF(e);
    ii=cx;
    }
    if ( ax==1) {
    for ( i=0;i<=ii;i++)
    abc(e[i]);
    }

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Well I have no idea why they are preserving all of those registers manually, and also cannot see how this code would execute a software interrupt.

    You can use the REGS union with the int86() family of functions. Those will automatically preserve the register values before the call and after, save for the explicit return registers like ax,bx,cx, and dx.

    To execute an interrupt 10h

    Code:
    union REGS regs;
    regs.x.ax=0x13;
    int86(0x10,& regs, & regs);
    This will set the video mode to 13h or 320x200x256.
    Now return values will be in the regs union. Some like to use inregs and outregs - two separate unions, but, personally, I find no use in doing that.

    To execute an interrupt 67h

    This will return the page frame segment of EMS in _BX, given that EMM386.EXE is there.

    Code:
    union REGS regs;
    regs.x.ax=0x4100;
    int86(0x67,& regs,& regs)
    Now regs.x.bx will hold the page frame segment for EMS if _AH is 00. Just an example, more is needed to actually use EMS.

    You can also do this:
    Code:
    _AX=0x4100;
    geninterrupt(0x67);
    I would not recommend this, though, as none of the register states are preserved before or after the interrupt. Even though _BX will hold the page frame segment (if _AH is 00h) if you do not assign _BX to your variable that will hold the segment, it is possible that _BX will not hold the value that you want.

    For instance:
    Code:
    _AX=0x4100;
    geninterrupt(0x67);
    printf("Hello\n");
    unsigned int EMSsegment=_BX;

    This may or may not work. Sometimes _BX will be used by other functions (a lot of times) and those functions will alter _BX. Since we are executing a printf prior to assigning _BX to our variable, it is possible that printf may have used _BX and thereby altered its contents. Most functions should preserve the registers that they use, however, I have had printf do this to me before when I was programming a mouse library way back when.

    Best bet - use int86(), int86x(), etc., and the REGS union.
    You can also execute interrupts via inline assembly, but I will not explain that here.

    Also, if you are not programming in DOS, for instance, Visual C++, you cannot use interrupts. Windows does not allow software interrupts or direct interaction with hardware.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    2
    Im working in DOS, so what u say above is helpful to me.

    thnx.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Software Design/Test - Redmond, WA
    By IRVolt in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 06-11-2008, 10:26 AM
  2. cout << SunTradingLLC << "is looking for C++ Software Developers" << endl;
    By sun trading in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 04-02-2008, 11:48 AM
  3. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 08:09 AM
  4. Adding trial period to software
    By BobS0327 in forum C Programming
    Replies: 17
    Last Post: 01-03-2006, 01:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21