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.