Post Reply 
HP50G - Library ROMID question
07-01-2019, 12:08 PM
Post: #1
HP50G - Library ROMID question
If a library is on level 1 of the stack is there any SYSRPL command or routine that will give the ROMID number of the library

Thanks Jeff
Find all posts by this user
Quote this message in a reply
07-01-2019, 03:59 PM
Post: #2
RE: HP50G - Library ROMID question
Here's a really fugly brute-force way to it in User RPL. The first literal string is a single space.

<< ->STR DUP " " POS 1 + OVER ":" POS 1 - SUB OBJ-> >>

This might not work on unnamed libraries (I didn't check), in which case the ":" POS should be modified as needed.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
07-01-2019, 08:43 PM
Post: #3
RE: HP50G - Library ROMID question
Hi Joe

I see what you have done

I'm doing my own simple Lib ATTACH/PURGE program. This will save having to input the ROMID

Thanks Jeff
Find all posts by this user
Quote this message in a reply
07-01-2019, 09:29 PM
Post: #4
RE: HP50G - Library ROMID question
The below version is definitely overkill for an application like this, and is almost twice the size of Joe's excellent (definitely not fugly) program. But since I know you (Jeff) are experimenting with SysRPL/Saturn/Debug4x right now, I thought I'd show an example that uses a SysRPL wrapper around a Saturn code object to directly extract the number from the library on the stack. The exact location of the library number is dependent on the length of the library title, so the program has to assess the title field before extracting it:
Code:
RPL

::
   ( must have at least one object on stack )
   CK1NOLASTWD

   CK&DISPATCH1
   # 8F ( SL1 must be a library ) ::

      ( put a placeholder BINT in SL1 )
      BINT0 TOTEMPOB

      ( obtain the library number directly from the library [now in SL2] )
      CODEM
         % save the RPL environment registers
         GOSBVL =SAVPTR

         % make a backup copy of SL1 pointer in R0.A for later use
         AD1EX
         D1=A
         R0=A A

         % D1 -> SL2
         D1+5

         % A.A -> SL2 object
         A=DAT1 A

         % A.A & D1 -> start of library name field
         A+10 A
         D1=A

         % C.A = size of library name (in *characters*, not nibbles)
         C=0 A
         C=DAT1 B

         % if library name has no characters, field length is 2 nibbles
         ?C=0 B ->{
            LC 2
         }
         SKELSE % otherwise, determine field name length from char count
         {
            % convert char count to nibble count by doubling it
            C+C A

            % increment field length by 4 (for size nibbles at beg/end of field)
            C+4 A
         }

         % skip name field in A.A based on nibble count determined above
         A+C A

         % C.A = library number
         D1=A
         C=0 A
         C=DAT1 X

         % D1 -> SL1
         A=R0 A
         D1=A

         % D1 -> SL1 object data
         A=DAT1 A
         D1=A
         D1+5

         % write the library number to the BINT data field
         DAT1=C A

         % restore the RPL registers
         GOSBVL =GETPTR

         % drop the library object currently in SL2 (equiv. to SWAPDROP)
         A=DAT1 A
         D1+5
         D+1 A
         DAT1=A A

         % return to RPL
         GOVLNG =Loop
      ENDCODE

      ( convert BINT result to real number )
      UNCOERCE
   ;
;

It shows several techniques that are common to this type of coding, including:
- checking the stack for appropriate arguments
- allocating memory for results prior to executing a Saturn code object
- use of MASD skip structure for conditional execution
- simple stack manipulation in Saturn code
Find all posts by this user
Quote this message in a reply
07-01-2019, 11:01 PM
Post: #5
RE: HP50G - Library ROMID question
(07-01-2019 03:59 PM)Joe Horn Wrote:  Here's a really fugly brute-force way to it in User RPL. The first literal string is a single space.

<< ->STR DUP " " POS 1 + OVER ":" POS 1 - SUB OBJ-> >>

This might not work on unnamed libraries (I didn't check), in which case the ":" POS should be modified as needed.

Clever! and not fugly at all, in fact, it's darned elegant, as long as the library is not too big...

I was looking at your FININVARS program and the program for identifying libraries used in a given program for hints but was not sure of the exact format of a library object. Where is that documented, other than in the heads of you guys that think in RPL?

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-02-2019, 02:36 AM
Post: #6
RE: HP50G - Library ROMID question
(07-01-2019 11:01 PM)rprosperi Wrote:  ...but was not sure of the exact format of a library object. Where is that documented, other than in the heads of you guys that think in RPL?

I usually go to the "Introduction to Saturn Assembly Language" book from Gilbert Fernandes (Edited and Maintained by Eric Rechlin) when trying to discern RPL object structures. If that fails, I make some examples on the emulator and alter them to see what happens. For something like a library, it must have taken a lot of trial-and-error testing to reverse engineer the format. Smile There's quite a bit in library objects.
Find all posts by this user
Quote this message in a reply
07-02-2019, 03:24 AM
Post: #7
RE: HP50G - Library ROMID question
(07-02-2019 02:36 AM)DavidM Wrote:  
(07-01-2019 11:01 PM)rprosperi Wrote:  ...but was not sure of the exact format of a library object. Where is that documented, other than in the heads of you guys that think in RPL?

I usually go to the "Introduction to Saturn Assembly Language" book from Gilbert Fernandes (Edited and Maintained by Eric Rechlin) when trying to discern RPL object structures. If that fails, I make some examples on the emulator and alter them to see what happens. For something like a library, it must have taken a lot of trial-and-error testing to reverse engineer the format. Smile There's quite a bit in library objects.

Thanks David, and of course thank you Joe.

LOL, the laugh's on me. After examining the format in confusion for a while, comparing Joe's code, I finally see that he's simply grabbing it from the title; I thought he was converting the entire library to a string and then parsing through that to find the ID following the name. And of course, this solution is even more innovative than I thought as it demonstrates the non-obvious but simple idea to just use the name as shown.

Sure, math is interesting, but puzzles like this are far more interesting to me.

Also, thanks David for sharing your nicely documented SysRPL/Saturn routine (which actually does what I thought Joe was doing). I've long since given up on any chance of learning Saturn coding, but more samples like this along the way would have helped a lot. Saturn code always made more sense for 71B code for me than for 48/49/50 code, likely due to the more linear flow in the 71 vs RPL structures.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-02-2019, 10:46 AM
Post: #8
RE: HP50G - Library ROMID question
Hi David

For now my comfort zone is RPL and Joe's program is easy for me to understand.

I will cut and paste your ASM code into Debug4 and experiment with it.

Although I'm not fully with your code I can see overall what its doing.

I have also looked at the library object structure on page 126 of Introduction to Saturn Assembly Language.

All very interesting

Very much appreciated David - gives me plenty to think about


Jeff
Find all posts by this user
Quote this message in a reply
Post Reply 




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