GW-BASIC User's Guide
moved the current stack pointer into BP; that is, MOV BP,SP. When 3 parameters are
passed, the location of PO is at BP+10, P1 is at BP+8, and P2 is at BP+6.
3. The called routine must do a RETURN n (n is two times the number of parameters in the
argument list) to adjust the stack to the start of the calling sequence. Also, programs must
be defined by a PROC FAR statement.
4. Values are returned to GW-BASIC by including in the argument list the variable name that
receives the result.
5. If the argument is a string, the parameter offset points to three bytes called the string
descriptor. Byte 0 of the string descriptor contains the length of the string (0 to 255). Bytes
1 and 2, respectively, are the lower and upper eight bits of the string starting address in
string space.
Note
The called routine must not change the contents of any of the three bytes of the string
descriptor.
6. Strings may be altered by user routines, but their length must not be changed. GW-BASIC
cannot correctly manipulate strings if their lengths are modified by external routines.
7. If the argument is a string literal in the program, the string descriptor points to program
text. Be careful not to alter or destroy your program this way. To avoid unpredictable
results, add +"" to the string literal in the program. For example, the following line forces
the string literal to be copied into string space allocated outside of program memory space:
20 A$="BASIC"+""
The string can then be modified without affecting the program.
Examples:
100 DEF SEG=&H2000
110 ACC=&H7FA
120 CALL ACC(A,B$,C)
.
.
.
Line 100 sets the segment to 2000 hex. The value of variable ACC is added into the address as
the low word after the DEF SEG value is left-shifted four bits (this is a function of the
microprocessor, not of GW-BASIC). Here, ACC is set to &H7FA, so that the call to ACC
[Link] (3 of 8)28/03/2004 21.29.05