Technical information
Using NewBIOS Serial Solutions
1020 :
1030 DEFINT A-Z ’Parameters are Integers
1040 :
1050 GOSUB 5000 ’Set up machine code
1060 :
1080 AX = &H9A ’Service 0, initialise
1090 ’Parameters as above
1100 DX = &H0 ’COM1
1110 BX = 0 ’These variables must exist
1115 CX = 0 ’before call even if not used
1120 DEF SEG
1130 ADDR = VARPTR(ASM%(0))
1140 CALL ADDR(AX,BX,CX,DX) ’Call interrupt
1150 :
1160 END
The build-up to the call in lines 1080 to 1130 is important. All
the parameters must be created (lines 1080 to 1115), the segment
must be set to that of BASIC (line 1120), and the address of the
interface routine calculated (line 1130). This calculation should
be repeated every time the call is made because the array
ASM% may have been relocated in memory. Note, as for
QuickBASIC, that we do not has access to the byte registers,
and that the program must explicitly build word registers from,
and decompose word registers into, byte values. This is shown in
the next example.
Example 2, Sending Data Out.__________________________
This example uses service 1H to send a character to
COM2. The status returned by the service is examined to check
that the character was sent correctly.
2000 ’GW-BASIC code fragment to send a character to COM2
2030 DEFINT A-Z
2040 :
2050 GOSUB 5000 ’Set up machine code
2060 :
2070 NEXTCHAR$ = "a"
2080 AX = CVI(NEXTCHAR$+CHR$(&H1))
2085 ’Service 1H, send character
2090 ’General form of byte to word conversion:
2095 ’WORD = CVI(CHR$(lo_byte)+CHR$(hi_byte)
2100 DX = &H1 ’COM2
2110 BX = 0 ’Must always create these
Chapter 4 Page 61