Technical information

Serial Solutions Using NewBIOS
Example 2, Sending Data Out.__________________________
Service 1H is used to send char nextchar to COM2. This
example examines the status returned by the service to check
that the byte was sent correctly.
/* C code fragment to send a character to COM2. */
#include <bios.h> /* Defines REGS and int86() */
union REGS inregs, outregs; /* Declare variables. */
char nextchar;
inregs.h.ah = _COM_SEND; /* Service 1, send character. */
inregs.h.al = nextchar; /* character to send. */
inregs.x.dx = 0x1; /* COM2. */
int86(0x14, &inregs, &outregs); /* Async services */
if( outregs.h.ah & 0x80 ) /* Check that send successful. */
{
printf("COM2 timed out on output.\n");
exit(1);
};
Since the integer returned from the int86() procedure is the AX
register we could use:
if( int86(0x14, &inregs, &outregs) & 0x8000 )
{
printf("COM2 timed out on output.\n");
exit(1);
};
Example 3, Setting Port Addresses.______________________________
Service ADH sets the address of a port. Suppose that a
second dual serial card has been added to the machine giving
COM3 and COM4 at addresses com3addr and com4addr. The
BIOS must be informed of the location of the ports. The
program also checks for the presence of NewBIOS.
/* C code fragment to set COM3 and COM4 addresses. */
#include <bios.h> /* Defines REGS and int86() */
Page 52 Chapter 4