Post Reply 
(50g) FNINVARS: Object finder for couch hackers
10-11-2017, 08:38 PM
Post: #5
RE: (50g) FNINVARS: Object finder for couch hackers
(10-11-2017 06:50 PM)rprosperi Wrote:  I'm sure it's a simple thing, but anyone know why these are different?

When given a global ID as an argument, the BYTES command on a rev. 2.15 50g calls the internal code for VARSIZE, a SysRPL command. VARSIZE is where the discrepancy comes in, as it very specifically adds a constant 9 nibbles (4.5 bytes) to the memory used by the characters of the global ID to sum up the final byte count. I'm not sure if other O/S versions are the same, but that's where the "4.5 + n chars" comes into play, at least on that system.

I would be inclined to call that a bug, as the size of a global identifier is definitely "3.5 + n chars". The only reason I can think of adding anything in addition to the global ID size would be if you wanted to include the stack pointer as well, but that would be an additional 2.5 bytes, not 1. So that wouldn't explain the difference.

For the curious, here's the code of the VARSIZE command (with some comments added). Even if you're not all that familiar with SysRPL, you can probably follow along with what it's doing:
Code:
::
   DUP                       ( DUPs the global ID given as the argument )
   @                         ( SysRPL version of RCL, which also returns TRUE if successful or FALSE if not )
   NOTcase SETNONEXTERR      ( essentially "raise non-existent error if RCL didn't work" )
   OCRC                      ( returns size, checksum )
   SWAPROT                   ( guess )
   ID>$                      ( converts the duplicated ID from above into a string )
   LEN$                      ( returns the length of the converted string in chars )
   #2*                       ( converts char count to nibbles used )
   #+                        ( adds char count nibbles to size of object )
   # 9                       ( System Binary 9 -- why 9 instead of 7?? )
   #+                        ( add the 9 to the accumulated size )
   UNCOERCE                  ( convert the System Binary size [in nibbles] to a real number )
   %2                        ( real 2 constant )
   %/                        ( divide by 2 to convert nibbles to bytes )
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (50g) FNINVARS: Object finder for couch hackers - DavidM - 10-11-2017 08:38 PM



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