mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 04:32:05 +00:00
Describe 'pointer-to' operator
This commit is contained in:
parent
bddcd41327
commit
3b0e951e34
@ -269,6 +269,28 @@ def strlen(strptr)
|
||||
return ^strptr
|
||||
end
|
||||
```
|
||||
Pointers to structures or arrays can be referenced with the `->` and `=>` operators, pointing to `byte` or `word` sized elements.
|
||||
```
|
||||
const elem_id = 0
|
||||
const elem_addr = 1
|
||||
|
||||
def addentry(entry, id, addr)
|
||||
entry->elem_id = id ; set ID byte
|
||||
entry=>elem_addr = addr ; set address
|
||||
return entry + 3 ; return next enry address
|
||||
end
|
||||
```
|
||||
The above is equivalent to:
|
||||
```
|
||||
const elem_id = 0
|
||||
const elem_addr = 1
|
||||
|
||||
def addentry(entry, id, addr)
|
||||
(entry).elem_id = id ; set ID byte
|
||||
(entry):elem_addr = addr ; set address
|
||||
return entry + 3 ; return next enry address
|
||||
end
|
||||
```
|
||||
|
||||
##### Addresses of Data/Code
|
||||
Along with dereferencing a pointer, there is the question of getting the address of a variable. The `@` operator prepended to a variable name or a function definition name, will return the address of the variable/definition. From the previous example, the call to `strlen` would look like:
|
||||
|
Loading…
Reference in New Issue
Block a user