[an error occurred while processing this directive]
Node:Pseudo-registers,
Previous:NEAR and FAR,
Up:Converting
Q: Since DJGPP doesn't recognize Borland-style pseudo-register
variables like _AX
, how should I port code which uses them to
DJGPP?
A: These pseudo-variables are typically used in two different contexts:
To port such code to DJGPP, use the fields of the __dpmi_regs
structure (declared on the dpmi.h
header file) to set the
register values, and library function __dpmi_int
to invoke the
interrupt service. For example, consider the following code snippet:
#include <dos.h> void _highcolor (void) { _AH = 0x10; _AL = 0x03; _BL = 0; geninterrupt (0x10); }
Here's one way to express this in DJGPP30:
#include <dpmi.h> void _highcolor (void) { __dpmi_regs r; r.h.ah = 0x10; r.h.al = 0x03; r.h.bl = 0; __dpmi_int (0x10, &r); }
Please read how to call real-mode interrupt functions, elsewhere in this document, for further details on how call real-mode services from DJGPP programs.
GCC features extensive inline assembly facilities which allow you to assign values to, or read values from registers from the inline assembly code. Since you will have to rewrite your inline assembly code anyway, make it refer directly to your C variables, instead of referencing pseudo-register variables from C. See description of inline assembly, for further info.