Post Reply 
Factor
04-21-2014, 02:48 PM (This post was last modified: 04-21-2014 03:50 PM by Dieter.)
Post: #5
RE: Factor
(04-20-2014 07:48 AM)Thomas Klemm Wrote:  
(04-20-2014 07:02 AM)Les Bell Wrote:  Is this for the 41, Thomas?
Nah, the 42S.

Since this is the HP41 Software Library, here is a version that runs on all 41s. Here is the code:

Code:
 01 LBL "FACTOR"
 02 STO 00
 03 2
 04 CLA
 05 ENTER
 06 XEQ 01
 07 RDN
 08 3
 09 XEQ 01
 10 XEQ 01
 11 LBL 00
 12 XEQ 01
 13 +
 14 XEQ 01
 15 XEQ 01
 16 +
 17 XEQ 01
 18 XEQ 01
 19 +
 20 XEQ 01
 21 +
 22 +
 23 XEQ 01
 24 XEQ 01
 25 +
 26 +
 27 GTO 00
 28 LBL 03
 29 RCL 00
 30 XEQ 04
 31 PROMPT
 32 LBL 02
 33 +
 34 ST/ 00
 35 XEQ 04
 36 AVIEW
 37 >"X"
 38 LBL 01
 39 RCL 00
 40 RCL Y
 41 /
 42 X<Y?
 43 GTO 03
 44 FRC
 45 X=0?
 46 GTO 02
 47 CLX
 48 +
 49 +
 50 RTN
 51 LBL 04
 52 RCL d
 53 FIX 0
 54 CF 29
 55 ARCL Y
 56 STO d
 57 CLX
 58 +
 59 END

This version includes a short routine at LBL 04 that replaces the AIP command. There are two synthetic instructions (RCL d and STO d) that save and restore the display state. If you do not know how to handle this, simply replace that subroutine with...

Code:
 51 LBL 04
 52 FIX 0
 53 CF 29
 54 ARCL X
 55 FIX 4
 56 SF 29
 57 END

There also is an additional AVIEW in line 36 so that you can watch the result build up. ;-) Omit it if you don't like it.

Both program versions have a slight design flaw: they stop with pending subroutine calls, to that they cannot end with a RTN or END and a final PROMPT is required. I did not take a closer look at the way FACTOR works, so I left it that way.

Dieter

Edit: corrected an error in the listing.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Factor - Thomas Klemm - 04-18-2014, 06:10 PM
RE: Factor - Les Bell - 04-20-2014, 07:02 AM
RE: Factor - Thomas Klemm - 04-20-2014, 07:48 AM
RE: Factor - Les Bell - 04-20-2014, 08:44 AM
RE: Factor - Dieter - 04-21-2014 02:48 PM
RE: Factor - Thomas Klemm - 04-21-2014, 04:50 PM
RE: Factor - Les Bell - 04-22-2014, 06:03 AM
RE: [HP-42s] Factor - Thomas Klemm - 04-22-2014, 07:45 AM
RE: [HP-42s] Factor - Les Bell - 04-22-2014, 09:08 AM



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