Post Reply 
[50g] Assign VIEW to a key
07-23-2018, 04:29 PM (This post was last modified: 07-23-2018 05:02 PM by SammysHP.)
Post: #1
[50g] Assign VIEW to a key
Hi,

I own a HP 50g for more than a year (and a HP-42S as well, but that's a different topic). Although I studied computer science and work as a software developer, I never found a good start for SysRPL programming.

Currently I want to assign the TOOL → VIEW function to a key in USR mode so that I can view any object on stack level 1 with a single key (similar to EDIT/EDITB with "down"). The problem is that this function is not available as a UserRPL command and that I'm a bit lost with the output of "K&SA" from KeyMan which obviously shows some low level code:

Code:
:: PTR 275C6 PTR 06E97 :: PTR 79E9A PTR 2B8AA; FPTR 2 0 ;

Maybe I can just use that program for the assignment, but I'd like to understand it as well. The start looks like TakeOver, but after that I'm not sure anymore (extable might help).

Can you tell me if I can use this output for the assignment via "A?D" and what the various addresses mean?
What would be a good start for understanding and learning SysRPL programming? You can find many tools for low-level development on the HP 50g, each with some kind of manual, but most of them just explain what it does, but not why or how you use it. I usually work with high-level languages like C or C++, Java etc. and even some low-level languages like smali or AVR assembler. I have the feeling that nothing of that can be compared with SysRPL or ASM on HP calculators (reference, toolchain, usability in general).

Regards,
Sven


edit: Meanwhile I found the two books "Programming in System RPL" and "Using the HP49G for System RPL Programming" that might be a good introduction into SysRPL programming. I'll start reading them but I'm still grateful for additional tips and an answer to my first question.
Find all posts by this user
Quote this message in a reply
07-23-2018, 05:36 PM
Post: #2
RE: [50g] Assign VIEW to a key
(07-23-2018 04:29 PM)SammysHP Wrote:  What would be a good start for understanding and learning SysRPL programming? You can find many tools for low-level development on the HP 50g, each with some kind of manual, but most of them just explain what it does, but not why or how you use it. I usually work with high-level languages like C or C++, Java etc. and even some low-level languages like smali or AVR assembler. I have the feeling that nothing of that can be compared with SysRPL or ASM on HP calculators (reference, toolchain, usability in general).

Regards,
Sven


edit: Meanwhile I found the two books "Programming in System RPL" and "Using the HP49G for System RPL Programming" that might be a good introduction into SysRPL programming. I'll start reading them but I'm still grateful for additional tips and an answer to my first question.

The books you've found by Eduardo M. Kalinowski and Carsten Dominik (be sure to get V2) are huge, excellent and the most complete SysRPL reference for the 50g, but it does not contain too much instructional text.

The initial SysRPL book by Jim Donnelly, "Introduction to System RPL and Assembly Language", although written for the 48 series, is probably the best introduction/tutorial type text on SysRPL. you can find it here:

https://www.hpcalc.org/details/7114

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-23-2018, 05:57 PM
Post: #3
RE: [50g] Assign VIEW to a key
A much simpler way to do this is to assign the following program to your preferred key:

Code:
« DUP SCROLL »

SCROLL is nearly identical to VIEW from the TOOL menu. SCROLL removes its argument from the stack, so prefacing it with DUP keeps you from losing the object.

(Note: I shamelessly stole the gist of the above from a post on another forum from Joe Horn, who is probably typing up a similar response as you are reading this Smile He deserves all the credit for finding it).

Bob has already pointed out what I think are probably the best introductions to SysRPL programming on the RPL systems. If you haven't already found it, another great resource is looking through posts in the comp.sys.hp48 usenet newsgroup. The collected knowledge in that archive is immense.
Find all posts by this user
Quote this message in a reply
07-23-2018, 06:17 PM
Post: #4
RE: [50g] Assign VIEW to a key
Thanks for your suggestions!

(07-23-2018 05:36 PM)rprosperi Wrote:  The initial SysRPL book by Jim Donnelly, "Introduction to System RPL and Assembly Language", although written for the 48 series, is probably the best introduction/tutorial type text on SysRPL.
I'll start reading it as soon as possible, thank you. A HP 48G(X) is still on my wish list. Made my first experiences with HP calculators with Emu48 and later Droid48.

(07-23-2018 05:57 PM)DavidM Wrote:  A much simpler way to do this is to assign the following program to your preferred key:

Code:
« DUP SCROLL »
I already found SCROLL in the AUR, but was unsure about the performance of DUP (because VIEW isn't called in a high rate usually this wouldn't be a big issue, though) and if there are other differences between SCROLL and VIEW.

(07-23-2018 05:57 PM)DavidM Wrote:  If you haven't already found it, another great resource is looking through posts in the comp.sys.hp48 usenet newsgroup. The collected knowledge in that archive is immense.
Thanks, I've been reading there a lot for years., but often you do not find exactly what you need. Anyway I found many interesting things, although I was looking for something different.
Find all posts by this user
Quote this message in a reply
07-23-2018, 08:07 PM
Post: #5
RE: [50g] Assign VIEW to a key
(07-23-2018 04:29 PM)SammysHP Wrote:  
Code:
:: PTR 275C6 PTR 06E97 :: PTR 79E9A PTR 2B8AA ; FPTR 2 0 ;
...and what the various addresses mean?
...
What would be a good start for understanding and learning SysRPL programming? You can find many tools for low-level development on the HP 50g, each with some kind of manual, but most of them just explain what it does, but not why or how you use it. I usually work with high-level languages like C or C++, Java etc. and even some low-level languages like smali or AVR assembler. I have the feeling that nothing of that can be compared with SysRPL or ASM on HP calculators (reference, toolchain, usability in general).

Re-reading your request, it feels like a bit more explanation is in order.

Yes, the above SysRPL program is executed upon pressing the VIEW menu item when the TOOL menu is shown. You could theoretically assign that code segment to a key and execute it, but it wasn't designed to be activated that way and as was already mentioned, there's a better way to do it.

As you probably already realize, SysRPL routines (sometimes referred to as "secondaries") are generally encapsulated between the :: and ; tokens (their formal names are DOCOL and SEMI).

Yes, installing extable will help you somewhat by showing names for certain entries instead of their PTR addresses. But be aware that not all routines in ROM have formal names. In this case, only a couple of the ones identified above do:

PTR 275C6: TakeOver
PTR 06E97: ' (usually pronounced "tick")

The others are references to ROM routines that aren't named, and are only accessible by the PTR reference. Non-named ROM routines are more likely to be inconsistent from one ROM version to the next, and it's best not to call them directly unless your code has already verified that it's OK to do so. Knowing when that's OK is not an easy concept to describe, so most sources you find will simply say "don't do it".

That first pointer in the ticked secondary (79E9A) appears to be the heart of the command. The details aren't meaningful at a high level, but it essentially checks some things, performs a DUP, then calls a named ROM command named ViewObject. That's where the main functionality of that menu item takes place.

The second one appears to perform some specialized functions based on the last nibble of the address of the current item in stack level 1, but I'm too lazy to keep tracing the code to see why. Why? Because there's already a much easier solution (the previously-mentioned SCROLL command), and because that code is likely to create problems if you attempt to call a routine like that out of context. Assigning the above code segment to a user key qualifies as "calling it out of context". It may work, it may not. It may work sometimes, but not others. And by "not working", I mean things like "crashing the calculator and losing data in the process". Is it worth it?

Finally, FPTR 2 0 is a specialized command that makes the preceding secondary run its objects in such a way that the appropriate memory bank is switched in before the secondary runs, and then switched back out when it finishes. Not unlike other environments that have a limited address space, this is required in order to have access to far more code than will fit in the relatively paltry addressable space that the Saturn environment affords.

It's nice to see others that are still interested in SysRPL/Saturn coding! I hope the above does more to pique your interest than to dissuade you.
Find all posts by this user
Quote this message in a reply
07-23-2018, 11:00 PM
Post: #6
RE: [50g] Assign VIEW to a key
(07-23-2018 04:29 PM)SammysHP Wrote:  Hi,
...
Currently I want to assign the TOOL → VIEW function to a key in USR mode so that I can view any object on stack level 1 with a single key (similar to EDIT/EDITB with "down").

It may be worth to look at Wolfgang Rautenberg's tools like Keyman and others at https://www.hpcalc.org/hp49/utils/interface/

HTH
Find all posts by this user
Quote this message in a reply
07-23-2018, 11:22 PM
Post: #7
RE: [50g] Assign VIEW to a key
(07-23-2018 05:57 PM)DavidM Wrote:  SCROLL is nearly identical to VIEW from the TOOL menu. SCROLL removes its argument from the stack, so prefacing it with DUP keeps you from losing the object.

(07-23-2018 06:17 PM)SammysHP Wrote:  I already found SCROLL in the AUR, but was unsure about the performance of DUP (because VIEW isn't called in a high rate usually this wouldn't be a big issue, though) and if there are other differences between SCROLL and VIEW.

Internally (in System RPL), VIEW performs DUP ViewObject, and SCROLL just performs ViewObject. So in User RPL << DUP SCROLL >> is identical to pressing the VIEW key in the TOOL menu.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-24-2018, 02:31 AM
Post: #8
RE: [50g] Assign VIEW to a key
(07-23-2018 04:29 PM)SammysHP Wrote:  edit: Meanwhile I found the two books "Programming in System RPL" and "Using the HP49G for System RPL Programming" that might be a good introduction into SysRPL programming. I'll start reading them but I'm still grateful for additional tips and an answer to my first question.
Hello Sven,
If you read French, Paul Courbis wrote several books on RPL/SystemRPL, you can download them HERE.
Sylvain
Find all posts by this user
Quote this message in a reply
07-24-2018, 01:17 PM
Post: #9
RE: [50g] Assign VIEW to a key
(07-24-2018 02:31 AM)Sylvain Cote Wrote:  If you read French, [...]

A vrai dire, on n'est probablement pas très nombreux sur ce forum à pouvoir le faire... Sad
Find all posts by this user
Quote this message in a reply
07-24-2018, 03:54 PM
Post: #10
RE: [50g] Assign VIEW to a key
Wow, so many high quality replies in such a short time, amazing.

(07-23-2018 08:07 PM)DavidM Wrote:  Re-reading your request, it feels like a bit more explanation is in order.
[…]
It's nice to see others that are still interested in SysRPL/Saturn coding! I hope the above does more to pique your interest […]
Thank you for the explanation. Absolutely. I already started reading "An Introduction to HP 48 System RPL and Assembly Language" (currently at page 40). It's not the first time that I work with low level programming. One of the reasons for buying the HP 50g was to play around with it. Wink

(07-23-2018 11:00 PM)RMollov Wrote:  It may be worth to look at Wolfgang Rautenberg's tools like Keyman
Already in use, but thanks for the recommendation.
(07-23-2018 04:29 PM)SammysHP Wrote:  […] I'm a bit lost with the output of "K&SA" from KeyMan […]

(07-23-2018 11:22 PM)Joe Horn Wrote:  Internally (in System RPL), VIEW performs DUP ViewObject, and SCROLL just performs ViewObject. So in User RPL << DUP SCROLL >> is identical to pressing the VIEW key in the TOOL menu.
Makes sense. That should be a good solution for my use case.

(07-24-2018 01:17 PM)grsbanks Wrote:  
(07-24-2018 02:31 AM)Sylvain Cote Wrote:  If you read French, [...]

A vrai dire, on n'est probablement pas très nombreux sur ce forum à pouvoir le faire... Sad
That might be true. To be honest, I used Google Translator to understand your post. Wink
Find all posts by this user
Quote this message in a reply
07-24-2018, 04:49 PM
Post: #11
RE: [50g] Assign VIEW to a key
(07-24-2018 01:17 PM)grsbanks Wrote:  
(07-24-2018 02:31 AM)Sylvain Cote Wrote:  If you read French, [...]

A vrai dire, on n'est probablement pas très nombreux sur ce forum à pouvoir le faire... Sad

Sounds like a question for a survey! Big Grin
Find all posts by this user
Quote this message in a reply
07-30-2018, 11:02 AM
Post: #12
RE: [50g] Assign VIEW to a key
(07-24-2018 01:17 PM)grsbanks Wrote:  
(07-24-2018 02:31 AM)Sylvain Cote Wrote:  If you read French, [...]

A vrai dire, on n'est probablement pas très nombreux sur ce forum à pouvoir le faire... Sad

T'es pas tout seul, mon pote Smile
Find all posts by this user
Quote this message in a reply
Post Reply 




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