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 />

USR Function<br />

Purpose:<br />

To call an assembly language subroutine.<br />

Syntax:<br />

v=USR[n](argument)<br />

Comments:<br />

n specifies which USR routine is being called.<br />

argument can be any numeric or string expression.<br />

Although the CALL statement is recommended for calling assembly language subroutines, the<br />

USR function call may also be used. See Appendix D in the GW-BASIC <strong>User's</strong> Guide for a<br />

comparison of CALL and USR and for a detailed discussion of calling assembly language<br />

subroutines.<br />

Only values 0-9 are valid for n. If n is omitted, USR0 is assumed (see DEF USR for the rules<br />

governing n).<br />

If a segment other than the default segment (GW-BASIC data segment, DS) is used, a DEF SEG<br />

statement must be executed prior to a USR call. This ensures that the code segment points to the<br />

subroutine being called.<br />

The segment address given in the DEF SEG statement determines the starting segment of the<br />

subroutine.<br />

For each USR function, a corresponding DEF USR statement must have been executed to define<br />

the USR call offset. This offset and the currently active DEF SEG segment address determine the<br />

starting address of the subroutine.<br />

If more than 10 user routines are required, the value(s) of DEF USR may be redefined for the<br />

other starting addresses as many times as needed.<br />

The type (numeric or string) of the variable receiving the function call must be consistent with the<br />

argument passed. If no argument is required by the assembly language routine, then a dummy<br />

argument must be supplied.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/USR.html28/03/2004 21.29.05

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

Saved successfully!

Ooh no, something went wrong!