17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

Note<br />

● Values are returned to GW-BASIC by including in the argument list the name of the<br />

variable that is to receive the result.<br />

● If the argument is a string, the parameter offset points to three bytes called the string<br />

descriptor. Byte 0 of the string descriptor contains the length of the string (0 to 255). Bytes<br />

1 and 2, respectively, are the lower- and upper-eight bits of the string starting address in<br />

the string space.<br />

● If the argument is a string literal in the program, the string descriptor points to program<br />

text. Be careful not to alter or destroy a program this way. To avoid unpredictable results,<br />

add +"" to the string literal in the program, as in the following:<br />

20 A$="BASIC"+""<br />

This forces the string literal to be copied into the string space. Now the string may be<br />

modified without affecting the program.<br />

Strings may be altered by user routines, but their length must not be changed. GW-BASIC cannot<br />

correctly erase strings if their lengths are modified by external routines.<br />

For more information on the CALL statement and USR function, see Appendix D in the GW-<br />

BASIC <strong>User's</strong> Guide.<br />

Example 1:<br />

100 DEF SEG=&H2000<br />

110 ARK=0<br />

120 CALL ARK(A, B$, C)<br />

.<br />

.<br />

.<br />

Line 100 sets the segment to hex 2000. ARK is set to zero so that the call to ARK executes the<br />

subroutine at location 2000:0.<br />

Example 2:<br />

The following sequence of 8086 Assembly Language demonstrates access of the parameters<br />

passed and stored in variable C:<br />

PUSH BP<br />

MOV BP, SP ; Gets current stack position in BP.<br />

MOV BX, 8[BP] ; Gets address of B$ descriptor.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/CALL.html (2 of 3)28/03/2004 21.29.13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!