Dismal Arithmetic & 3 Progs for 49G & Others
05-08-2015, 01:35 AM
Post: #19
 Dave Britten Senior Member Posts: 2,314 Joined: Dec 2013
RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S
For those of you who have already died of boredom, here's a TI-95 version. It's not terribly fast. Even with all the control transfer statements ASMed, it took 42 seconds to compute 435,821 * 2,949,229.

Run the program to get the main menu, then separate your two arguments with x~t and press F1 or F2 to add or multiply. (As if anybody here besides me has a TI-95 and cares enough to try this.)

Code:
280 Bytes DFN CLR DFN F1:ADD@AD DFN F2:MLT@ML RTN LBL NL IF= 014 RTN ABS LOG + 1 = INT RTN LBL DG - 1 = INV LOG x~t / x~t = INT / 10 = FRC * 10 = RTN LBL AD STO 001 SBL NL STO 002 x~t STO 000 SBL NL IF> 002 STO 002 1 STO 003 0 STO 005 STO 014 LBL A1 RCL 000 x~t RCL 003 SBL DG STO 004 RCL 001 x~t RCL 003 SBL DG IF< 004 RCL 004 * ( RCL 003 - 1 ) INV LOG = ST+ 005 INC 003 RCL 003 INV IF> 002 GTL A1 RCL 005 RTN LBL ML STO 007 SBL NL STO 010 x~t STO 006 SBL NL STO 008 0 STO 013 STO 014 LBL M1 0 STO 012 RCL 007 x~t RCL 010 SBL DG STO 011 1 STO 009 LBL M2 RCL 006 x~t RCL 009 SBL DG IF> 011 RCL 011 * ( RCL 009 - 1 ) INV LOG = ST+ 012 INC 009 RCL 009 INV IF> 008 GTO M2 RCL 013 * 10 = x~t RCL 012 SBL AD STO 013 DSZ 010 GTL M1 RCL 013 RTN Labels NL - Number length DG - Get digit AD - Add A1 - Add loop ML - Multiply M1 - Multiply outer loop M2 - Multiply inner loop Variables 000 - Addend 1 001 - Addend 2 002 - Addend max length (loop end) 003 - Add loop counter 004 - Addition scratch register 005 - Sum 006 - Factor 1 007 - Factor 2 008 - Factor 1 length (inner loop end) 009 - Inner loop counter, incrementing (factor 1) 010 - Outer loop counter, decrementing (factor 2) 011 - Outer loop current digit (factor 2) 012 - Product 013 - Sum of products 014 - Zero (constant for comparison tests)

Some notes:

If you ASM and then subsequently INV ASM the program, the GTL M1 instruction doesn't get converted back from the step number. No idea why.

The comparison tests are very flexible, yet limited at the same time. You can compare the display register (x) with any storage register and skip the next instruction if false, but there's no way to compare x with 0 without storing 0 somewhere, and you can't directly test x against t unless you unprotect the system and access it via system register number 2079.

The lack of ISG is surprisingly annoying.

I may attempt doing this on the TI-66 if I hit my head and forget how awful the comparison tests are on that. (You only get x=t, x!=t, x>=t, and x<t, and you're only able to have an implied GTO after it, so doing a conditional RTN requires a label followed by a RTN floating around in your program somewhere.)
 « Next Oldest | Next Newest »

 Messages In This Thread Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 04-21-2015, 04:18 PM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Didier Lachieze - 04-21-2015, 09:19 PM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Gerald H - 04-22-2015, 07:04 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Didier Lachieze - 04-22-2015, 07:16 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Didier Lachieze - 04-22-2015, 07:45 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Dave Britten - 04-22-2015, 01:09 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - brouhaha - 04-22-2015, 01:18 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Tugdual - 04-22-2015, 06:55 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Gerald H - 04-22-2015, 08:54 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Didier Lachieze - 04-22-2015, 09:56 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G - Gerald H - 04-22-2015, 10:07 AM RE: Dismal Arithmetic with Two Programmes for the HP 49G & the Prime - Dave Britten - 05-06-2015, 05:34 PM RE: Dismal Arithmetic with Two Programmes for the HP 49G & the Prime & the HP 48S - Dave Britten - 05-07-2015, 01:48 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Gerald H - 05-07-2015, 03:25 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Gerald H - 05-07-2015, 03:57 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Gerald H - 05-07-2015, 04:59 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Dave Britten - 05-07-2015, 05:36 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Gerald H - 05-07-2015, 06:01 PM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Dave Britten - 05-08-2015 01:35 AM RE: Dismal Arithmetic with Two Programmes 49G, the Prime, 48S & 32S - Dave Britten - 05-08-2015, 02:53 PM RE: Dismal Arithmetic & 2 Progs for 49G, the Prime, 48S & 32S & TI & C... - Dave Britten - 05-11-2015, 04:16 PM RE: Dismal Arithmetic & 2 Progs for 49G, the Prime, 48S & 32S & TI & C... - Marcus von Cube - 05-11-2015, 06:04 PM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 05-13-2015, 09:19 AM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Dave Britten - 05-13-2015, 05:59 PM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 05-13-2015, 06:37 PM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Dave Britten - 05-13-2015, 07:26 PM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 10-28-2015, 02:17 PM RE: Dismal Arithmetic & 3 Progs for 49G & Others - Gerald H - 10-30-2015, 10:43 AM

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