File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ Identifiers shown in bold are taken from the Sinclair BASIC (beware their meanin
103103* ** [ THEN] ( if.md ) **
104104* ** [ TO] ( to.md ) **
105105* [ UBOUND] ( ubound.md ) ** (function)**
106+ * [ USR] ( usr.md ) ** (function)**
106107* [ UNTIL] ( do.md ) ** (statement)**
107108* ** [ VAL] ( val.md ) ** ** (function)**
108109* ** [ VERIFY] ( load.md ) ** ** (statement)**
Original file line number Diff line number Diff line change 1+ #USR
2+
3+ ##Syntax
4+
5+
6+ ```
7+ USR(<address>)
8+ USR(<string value>)
9+ ```
10+
11+ ##Description
12+
13+ This function exist for the sole compatibility with Sinclair BASIC. It's not needed in ZX Basic.
14+
15+ If used with a numeric argument, it will jump to the given memory address and start executing the machine code from there.
16+ To return the control to BASIC, a ` ret ` instruction must be executed. The value of the BC register will be used as the
17+ value (uInteger) returned by the function.
18+
19+ If used with a string argument, it will return the UDG (User Defined Graphic) memory address of the first character of the string.
20+ For example, for the ` \A ` UDG, ` USR "a" ` will return the address of it. This function is case insensitive.
21+
22+ Returned value type is [ UInteger] ( types.md#Integral ) .
23+
24+ ##Examples
25+
26+ To call a machine code routine:
27+ ```
28+ REM Uses USR to invoke a machine code routine
29+ PRINT "BC register returned "; USR @myRoutine
30+ END
31+
32+ myRoutine:
33+ Asm
34+ ld bc, 1234
35+ ret
36+ End Asm
37+ ```
38+
39+ To work with UDG:
40+ ```
41+ REM Creates an UDG with Horizontal lines
42+ FOR i = 0 TO 7:
43+ POKE USR "a" + i, 255 * (i MOD 2)
44+ NEXT i
45+ PRINT "\A is the UDG A"
46+ ```
47+
48+ ##Remarks
49+
50+ * This function is 100% Sinclair BASIC Compatible
51+
52+ ##See Also
53+
54+ * [ CODE] ( code.md )
You can’t perform that action at this time.
0 commit comments