Post Reply 
newRPL - Wiki examples for PEEK, POKE and NEWOB commands
09-22-2021, 12:31 AM
Post: #2
RE: newRPL - Wiki examples for PEEK, POKE and NEWOB commands
(09-21-2021 09:09 PM)JoJo1973 Wrote:  I'm adding a batch of commands to the wiki and I'd like to include meaningful examples when the command is obscure and rarely used.

PEEK, POKE and NEWOB fall into the description, and I can't come with an example that satisfies me: I could show how PEEK and POKE work on some random memory location, but is there some special address that I could use?

NEWOB is even worse in this respect: the HP50G AUR suggested an example, but the presence of 8 levels of UNDO stack make it not very didactically interesting...

I'm out of ideas, do you have any?

PEEK and POKE are low-level commands, can only be used by "certain people" with "certain knowledge". It's OK if there's no examples, they simply read or write a 32-bit word at a word-aligned ARM address. They aren't meant for the general public, but mainly to aid the developers on hardware debugging. Using "some random address" you will either cause a crash (data abort exception), or corrupt your precious data.

NEWOB is exactly the same as the HP48 command NEWOB. There's one very important use for this command:
Let's say you have a list of 1000 numbers. Using GET to put one of the objects on the stack will place a pointer to the object that's *within the list* on the stack. And for as long as you keep that one number around, you'll keep the entire list eating out your memory.
You can simply use NEWOB after GET to create a stand-alone copy of the number, and the list will be gone in the next garbage collection.
It's an obscure command used by memory-intensive applications.
Another use is for self-modifying objects. On the hp48/49/50 you could modify an object from assembler, so you could create a new copy first, then change it rather than allocating new memory and creating the object from scratch. None of that can happen in newRPL so this use case is not valid.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - Wiki examples for PEEK, POKE and NEWOB commands - Claudio L. - 09-22-2021 12:31 AM



User(s) browsing this thread: 1 Guest(s)