View Full Version : software interruptions??

11-08-2001, 08:24 PM
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) {
if ( ax==1) {
for ( i=0;i<=ii;i++)

11-08-2001, 11:57 PM
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

union REGS regs;
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.

union REGS regs;
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:


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:

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.

11-09-2001, 05:35 PM
Im working in DOS, so what u say above is helpful to me.