CALL and USR
BASIC provides two methods for running sections of code,
P% = code% [ OPT l% .exit MOV PC, R14 .printit CMP R0, #0 MOVEQ PC, R14 SWI "OS_Write0" B exit ]You have defined three possible entry points:
$code% = filename$+CHR$0 code%!12 = filetype% code%!16 = filelength% CALL process_fileParameters will have already been set up, so to read the filename you just
ADRa register, then
LDRB r, [pointer], #1until you reach a zero byte.
USR accept register values. Whatever you set A% to H% to
be will be stored in R0 to R7.
A% = 1 B% = 2 CALL somecodeThe function somecode will be entered with R0 set to 1 and R1 set to 2.
The principal difference, however, is that with CALL you can pass parameters...
CALL mycode, name$, address$, file_handle%...and USR takes no parameters, but will return the value of R0.
result% = USR(mycode)
Unfortunately, you cannot pass parameters AND return a value in R0 at the same time.
For simple code, or code that could be run stand-alone (i.e., not from BASIC), this is all you
really need to know.
However BASIC offers much much more. All of this is detailed in the section on extended BASIC facilities. It is worth taking a look at, as it offers access to several useful BASIC functions and status words.