HP Forums
(50g) Integer Square Root Rounded to Nearest Integer - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (50g) Integer Square Root Rounded to Nearest Integer (/thread-8992.html)



(50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-06-2017 07:37 AM

For integer input N the programme returns the square root rounded to the nearest integer.

Edit: Please do not use this programme - see latter postings.

Size: 193.

CkSum: # 300Eh

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    ::
      DUP
      ZINT 2
      Z<
      DUP
      ?SEMI
      DROPDUP
      FPTR2 ^Z>ZH
      FPTR2 ^ZBits
      BINT2
      #/
      #+
      ZINT 2
      SWAP
      FPTR2 ^PPow#
      BEGIN
      SWAPDROPDUP
      3PICKOVER
      FPTR2 ^ZQUOText
      FPTR2 ^QAdd
      ZINT 2
      FPTR2 ^ZQUOText
      2DUP
      Z>
      NOT_UNTIL
      DROPDUP
      FPTR2 ^ZSQ_
      ROT
      EQUAL
    ;
    case
    SWAPDROP
    DUPDUP
    FPTR2 ^RADDext
    ZINT 1
    FPTR2 ^RADDext
    FPTR2 ^ZSQ_
    ZINT 4
    FPTR2 ^ZDIVext
    DROPROT
    Z<
    NOT?SEMI
    ZINT 1
    FPTR2 ^RADDext
  ;
;



RE: (50g) Integer Square Root Rounded to Nearest Integer - Joe Horn - 09-06-2017 01:08 PM

ASM Error: Can't Find ^ZSQ_

I tried replacing ^ZSQ_ with ^ZSQRT, which assembles ok, but it yields a different checksum and doesn't run correctly. What is HP's MASD name for this flashpointer (e.g. FPTR 6 FF)?


RE: (50g) Integer Square Root Rounded to Nearest Integer - DavidM - 09-06-2017 01:32 PM

(09-06-2017 01:08 PM)Joe Horn Wrote:  ASM Error: Can't Find ^ZSQ_

I tried replacing ^ZSQ_ with ^ZSQRT, which assembles ok, but it yields a different checksum and doesn't run correctly. What is HP's MASD name for this flashpointer (e.g. FPTR 6 FF)?

Try FPTR 6 24E (WRONG)

Edit: My bad. It was already hexified. Should be FPTR 6 590


RE: (50g) Integer Square Root Rounded to Nearest Integer - DavidM - 09-06-2017 01:52 PM

Joe, you might find this document from Carsten Dominik's entry database page helpful for finding some of the "unknown's", since I believe it lists many (if not all) of the additional extable entries that went into the emacs extable file.


RE: (50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-06-2017 02:20 PM

Sorry, I thought I'd caught all the ?_ but hadn't.

Here a better version of the programme:

Size: 195.5

CkSum: # 782Ah

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    ::
      DUP
      ZINT 2
      Z<
      DUP
      ?SEMI
      DROPDUP
      FPTR2 ^Z>ZH
      FPTR2 ^ZBits
      BINT2
      #/
      #+
      ZINT 2
      SWAP
      FPTR2 ^PPow#
      BEGIN
      SWAPDROPDUP
      3PICKOVER
      FPTR2 ^ZQUOText
      FPTR2 ^QAdd
      ZINT 2
      FPTR2 ^ZQUOText
      2DUP
      Z>
      NOT_UNTIL
      DROPDUP
      DUP
      FPTR2 ^QMul
      ROT
      EQUAL
    ;
    DROP
    DUPDUP
    FPTR2 ^RADDext
    ZINT 1
    FPTR2 ^RADDext
    DUP
    FPTR2 ^QMul
    ZINT 4
    FPTR2 ^ZQUOText
    ROT
    Z<
    NOT?SEMI
    ZINT 1
    FPTR2 ^RADDext
  ;
;

Trust it compiles & works correctly.

^ZSQ_ is FPTR 6 590 which squares its argument.


RE: (50g) Integer Square Root Rounded to Nearest Integer - Joe Horn - 09-06-2017 09:44 PM

(09-06-2017 01:52 PM)DavidM Wrote:  Joe, you might find this document from Carsten Dominik's entry database page helpful for finding some of the "unknown's", since I believe it lists many (if not all) of the additional extable entries that went into the emacs extable file.

Very helpful! Thank you!

EDIT: Uh oh... Upon examination, I am not sure I trust that document's addresses as being "stable". For example, it says that #34133h is the address of a string called tokCopyright which contains "Copyright HP xxxx". But it doesn't, and executing PTR 34133 crashes. Same for 340CB (tokVersion) "Version HP49-B...".

These were valid in the 49G but are not valid in the 50g. Is there a document that lists the useful "Unsupported But Stable" entry points for the 50g?


RE: (50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-07-2017 05:37 AM

On a 49G, ver 1,19-6

tokCOPYRIGHT doesn't work

but

tokVERSION is OK.


RE: (50g) Integer Square Root Rounded to Nearest Integer - DavidM - 09-07-2017 06:44 AM

(09-06-2017 09:44 PM)Joe Horn Wrote:  Uh oh... Upon examination, I am not sure I trust that document's addresses as being "stable". For example, it says that #34133h is the address of a string called tokCopyright which contains "Copyright HP xxxx". But it doesn't, and executing PTR 34133 crashes. Same for 340CB (tokVersion) "Version HP49-B...".

These were valid in the 49G but are not valid in the 50g. Is there a document that lists the useful "Unsupported But Stable" entry points for the 50g?

Yikes! Good question. I just did some sleuthing and found that my currently-installed extable matches bytes and cksum with the "extable2.lib" version from emacs211a, and it definitely includes those two tokens as well.

While I was looking at this, I also noticed that Jazz 50g has a rather large extable replacement as well. Perhaps if Han sees this he can provide some insight as to the symbol source for that one, but a quick check showed that it also has those two tokens. So I'm thinking that most of the updated ones are probably pulling a similar list to Carsten's database, which has both of those. As well as the newer ZINTs and FPTRs, and... lots of other things it appears.

That's a long way to say "I don't know of one" Smile. But maybe we can shake enough trees to see what kind of fruit will fall.


RE: (50g) Integer Square Root Rounded to Nearest Integer - Eric Rechlin - 09-07-2017 07:11 PM

(09-07-2017 06:44 AM)DavidM Wrote:  Yikes! Good question. I just did some sleuthing and found that my currently-installed extable matches bytes and cksum with the "extable2.lib" version from emacs211a, and it definitely includes those two tokens as well.

While I was looking at this, I also noticed that Jazz 50g has a rather large extable replacement as well. Perhaps if Han sees this he can provide some insight as to the symbol source for that one, but a quick check showed that it also has those two tokens. So I'm thinking that most of the updated ones are probably pulling a similar list to Carsten's database, which has both of those. As well as the newer ZINTs and FPTRs, and... lots of other things it appears.

That's a long way to say "I don't know of one" Smile. But maybe we can shake enough trees to see what kind of fruit will fall.

I suspect that development on the 50g has come to enough of a standstill that there just plain isn't a comprehensive entry point list that is accurate for it, and there's not much incentive for someone to make one now. And showing how few people use Jazz for the 50g, here we are more than a decade past the 50g's release, and approaching 20 years since the 49G's release, and Jazz still doesn't compile ZINT 0 properly.


RE: (50g) Integer Square Root Rounded to Nearest Integer - Gerald H - 09-08-2017 02:54 PM

I'm reminded of Robert Recorde

http://www.hpmuseum.org/forum/thread-3223.html