Technical information
Serial Solutions Using NewBIOS
unsigned int ax;
unsigned int bx;
unsigned int cx;
unsigned int dx;
unsigned int si;
unsigned int di;
unsigned int cflag;
};
struct BYTEREGS {
unsigned char al, ah;
unsigned char bl, bh;
unsigned char cl, ch;
unsigned char dl, dh;
};
union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};
Note how the union of WORDREGS and BYTEREGS reflects
the actual organisation of the 8086 register set.
int86() places the values in ’inregs’ in the registers of the
8086 and performs an INT n. On return the values in the 8086
registers are copied into ’outregs’. The value returned is that of
the AX register. This means that the assembly language
examples above are very easy to translate into C.
The reader not familiar with the interrupt routines may
wish to read the section ’accessing asynchronous services’ earlier
in this chapter.
Example 1, Initialising A Port.__________________________
This example uses service 0H to set up the baud rate etc
for COM1. Later chapter "NewBIOS Reference", contains details
of this and all other BIOS services.
/* C code fragment to set COM1 to 1200 baud*/
/* even parity, seven data bits and 1 stop bit. */
#include <bios.h> /* Defines REGS and int86() */
union REGS inregs, outregs; /* Declare variables. */
inregs.h.ah = 0x0; /* Service 0, initialise. */
Page 50 Chapter 4