Technical information
Using NewBIOS Serial Solutions
Example 1, initialising a port.__________________________
This example uses service 0H to set the Baud rate etc. for
COM1. A later chapter, "NewBIOS Reference", contains details
of this and all other asynchronous services.
’QuickBASIC code fragment to set COM1 to 1200 Baud,
’even parity, seven data bits and 1 stop bit
DEFINT A-Z ’All parameters integers
REM $INCLUDE: ’QB.BI’
DIM inregs AS RegType, outregs AS RegType
inregs.ax = &H9A ’Ie AH = 00H, AL = 9AH
’==>Service 0H, initialise
’Parameters as above
inregs.dx = &H0 ’COM1
CALL INTERRUPT(&H14, inregs, outregs)
Note that the programmer does not have access to the byte
registers, AL, BH etc, as in Assembly language, C or Pascal.
Splitting word values into, and creating word values out of, byte
registers is illustrated in the next two examples.
Example 2, Sending Data Out.__________________________
This example uses service 1H to send a character to
COM2. It examines the status returned by the service to check
that the character was sent correctly.
’QuickBASIC code fragment to send a character to COM2
DEFINT A-Z
REM $INCLUDE: ’QB.BI’
DIM inregs AS RegType, outregs AS RegType
nextchar$ = "a"
inregs.ax = CVI(nextchar$ + CHR$(&H1))
’AH = 1, ==>Service 1H, send char
’AL = ASC(nextchar$)
’Generally:
’WordReg = CVI(CHR$(low_byte)+chr$(high_byte))
inregs.dx = &H1 ’COM2
CALL INTERRUPT(&H14, inregs, outregs) ’Asynchronous services
Chapter 4 Page 57