From 3b0e951e34596babf5adb4292b2c501b77aee863 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 4 Jul 2014 20:38:41 -0700 Subject: [PATCH] Describe 'pointer-to' operator --- Docs/Tutorials/PLASMA/User Manual.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Docs/Tutorials/PLASMA/User Manual.md b/Docs/Tutorials/PLASMA/User Manual.md index 2519e379..4e255e90 100644 --- a/Docs/Tutorials/PLASMA/User Manual.md +++ b/Docs/Tutorials/PLASMA/User Manual.md @@ -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: