Post Reply 
(50g) Integer Square Root Rounded to Nearest Integer
09-06-2017, 07:37 AM (This post was last modified: 09-06-2017 02:08 PM by Gerald H.)
Post: #1
(50g) Integer Square Root Rounded to Nearest Integer
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
  ;
;
Find all posts by this user
Quote this message in a reply
09-06-2017, 01:08 PM (This post was last modified: 09-06-2017 01:17 PM by Joe Horn.)
Post: #2
RE: (50g) Integer Square Root Rounded to Nearest Integer
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)?

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
09-06-2017, 01:32 PM (This post was last modified: 09-06-2017 01:45 PM by DavidM.)
Post: #3
RE: (50g) Integer Square Root Rounded to Nearest Integer
(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
Find all posts by this user
Quote this message in a reply
09-06-2017, 01:52 PM
Post: #4
RE: (50g) Integer Square Root Rounded to Nearest Integer
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.
Find all posts by this user
Quote this message in a reply
09-06-2017, 02:20 PM
Post: #5
RE: (50g) Integer Square Root Rounded to Nearest Integer
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.
Find all posts by this user
Quote this message in a reply
09-06-2017, 09:44 PM (This post was last modified: 09-06-2017 10:42 PM by Joe Horn.)
Post: #6
RE: (50g) Integer Square Root Rounded to Nearest Integer
(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?

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
09-07-2017, 05:37 AM
Post: #7
RE: (50g) Integer Square Root Rounded to Nearest Integer
On a 49G, ver 1,19-6

tokCOPYRIGHT doesn't work

but

tokVERSION is OK.
Find all posts by this user
Quote this message in a reply
09-07-2017, 06:44 AM
Post: #8
RE: (50g) Integer Square Root Rounded to Nearest Integer
(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.
Find all posts by this user
Quote this message in a reply
09-07-2017, 07:11 PM
Post: #9
RE: (50g) Integer Square Root Rounded to Nearest Integer
(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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-08-2017, 02:54 PM
Post: #10
RE: (50g) Integer Square Root Rounded to Nearest Integer
I'm reminded of Robert Recorde

http://www.hpmuseum.org/forum/thread-3223.html
Find all posts by this user
Quote this message in a reply
Post Reply 




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