[DM41] solver

This is the place to discuss the usage of DM1x/DM41 machines and to share any tips & tricks you may have stumbled across.

If discussing a specific model, please ensure that you prefix topic subjects with the model number this way:

[DM41] How to change the number of program steps available
Post Reply
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

[DM41] solver

Post by grsbanks »

Hot on the heels of the bit of work I did calculating current passing through the infrared LED of the DM42 (see this topic), I decided to put the DM41L to work on the same problem but, of course, the DM41L doesn't have a solver built in.

So, I quickly knocked one together using the secant method. There's little to no error checking in it and I'm sure someone else can optimise it if they want to, but here it is for what it's worth.

It assumes that any known or unknown variables are in registers. Part of the process entails telling the solver which of the registers used by the program to to solve is the unknown. It uses registers 10-16 itself so don't use those in the program to solve. It also places the value of the unknown variable in the X register before XEQing the target program.

Code: Select all

01 LBL'SOLVE
02 'FUNC?
03 AON
04 PROMPT
05 ASTO 14
06 AOFF
07 LBL 01
08 'ACCUR?
09 PROMPT
10 STO 12
11 'UNKNOWN?
12 PROMPT
13 STO 13
14 'GUESS1?
15 PROMPT
16 STO 10
17 STO IND 13
18 'GUESS2?
19 PROMPT
20 STO 11
21 RCL 10
22 XEQ IND 14
23 STO 15
24 ABS
25 RCL 12
26 X>Y?
27 GTO 09
28 RCL 11
29 LBL 02
30 STO IND 13
31 XEQ IND 14
32 STO 16
33 ENTER^
34 ABS
35 RCL 12
36 X>Y?
37 GTO 09
38 RDN
39 RDN
40 RCL 11
41 RCL 10
42 -
43 X<>Y
44 *
45 LASTX
46 RCL 15
47 -
48 /
49 RCL 11
50 X<>Y
51 -
52 X<> 11
53 STO 10
54 RCL 16
55 STO 15
56 RDN
57 RCL 11
58 GTO 02
59 LBL 09
60 RCL IND 13
61 STOP
62 GTO 01
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Post Reply