Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
doc: add USR function
Browse files Browse the repository at this point in the history
  • Loading branch information
boriel committed Oct 13, 2023
1 parent 1512ab5 commit 0e05e2c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/identifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Identifiers shown in bold are taken from the Sinclair BASIC (beware their meanin
* **[THEN](if.md)**
* **[TO](to.md)**
* [UBOUND](ubound.md) **(function)**
* [USR](usr.md) **(function)**
* [UNTIL](do.md) **(statement)**
* **[VAL](val.md)** **(function)**
* **[VERIFY](load.md)** **(statement)**
Expand Down
40 changes: 40 additions & 0 deletions docs/usr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#USR

##Syntax


```
USR(<address>)
USR(<string value>)
```

##Description

This function exist for the sole compatibility with Sinclair BASIC. It's not needed in ZX Basic.

If used with a numeric argument, it will jump to the given memory address and start executing the machine code from there.
To return the control to BASIC, a `ret` instruction must be executed. The value of the BC register will be used as the
value (uInteger) returned by the function.

If used with a string argument, it will return the UDG (User Defined Graphic) memory address of the first character of the string.
For example, for the `\A` UDG, `USR "a"` will return the address of it. This function is case insensitive.

Returned value type is [UInteger](types.md#Integral).

##Examples

```
REM Creates an UDG with Horizontal lines
FOR i = 0 TO 7:
POKE USR "a" + i, 255 * (i MOD 2)
NEXT i
PRINT "\A is the UDG A"
```

##Remarks

* This function is 100% Sinclair BASIC Compatible

##See Also

* [CODE](code.md)

0 comments on commit 0e05e2c

Please sign in to comment.