Q2X: Configure counter by variable

This commit is contained in:
Dennis Twardowsky
2019-10-18 22:54:24 +02:00
parent 39ee11b688
commit 7535181ac1

View File

@@ -1,8 +1,6 @@
00 { 164-Byte Prgm }
00 { 172-Byte Prgm }
01 LBL "Q2F"
02 SIZE 25
03 CLRG
// Save Stack
@@ -37,104 +35,106 @@
29 STO 05
// Init counter
30 10
31 1000
32 ÷
33 0.00001
34 +
35 STO 06
36 10
37 STO 07
30 RCL "Q2MAX"
31 X=0?
32 12
33 1000
34 ÷
35 0.00001
36 +
37 STO 06
38 10
39 STO 07
38 CLST
39 RCL 01
40 CLST
41 RCL 01
// [[A]] [LOOP-BEGIN] Build continued fraction
40 LBL A
41 ENTER
42 IP
43 STO IND 07
44 X<>Y
45 FP
46 STO 08
42 LBL A
43 ENTER
44 IP
45 STO IND 07
46 X<>Y
47 FP
48 STO 08
// Check if configured tolerance is reached --> goto B
47 RCL 05
48 X>Y?
49 GTO B
49 RCL 05
50 X>Y?
51 GTO B
// .. if not, roll-down check value
50 R↓
52 R↓
// ... and invert result for next round
51 1/X
53 1/X
// Increase REG-index
52 1
53 STO+ 07
54 R↓
54 1
55 STO+ 07
56 R↓
// Proceed, if max num of rounds is reached --> repeat A
55 ISG 06
56 GTO A
57 ISG 06
58 GTO A
// [LOOP-END] Build continued fraction
57 GTO C
59 GTO C
// [[B]] FINISHED building continued fraction by tolerance
58 LBL B
60 LBL B
// Remove last stack entry used for tolerance check
59 R↓
61 R↓
// [[C]] FINISHED building continued fraction by max num of rounds
60 LBL C
62 LBL C
// Init loop for reverse calculation from old value
61 RCL 06
62 IP
63 0.00001
64 +
65 STO 06
63 RCL 06
64 IP
65 0.00001
66 +
67 STO 06
// Start calculation of final fraction
// NOTE: 1. fraction always has nominator =1
66 CLST
67 1
68 RCL IND 07
69 PRSTK
68 CLST
69 1
70 RCL IND 07
71 PRSTK
// [[D]] [LOOP-BEGIN] Reverse calculation
70 LBL D
71 ENTER
72 R↓
73 X<>Y
74 R↑
72 LBL D
73 ENTER
74 R↓
75 X<>Y
76 R↑
// Decrease REG-index
75 1
76 STO- 07
77 CLX
77 1
78 STO- 07
79 CLX
78 RCL IND 07
79 ×
80 +
81 PRSTK
80 RCL IND 07
81 ×
82 +
83 PRSTK
82 DSE 06
83 GTO D
84 DSE 06
85 GTO D
// [LOOP-END] Perform reverse calculation
// Prepare Alpha-Register
84 CLA
85 AIP
86 X<>Y
87 ⊢"/"
88 AIP
86 CLA
87 AIP
88 X<>Y
89 ⊢"/"
90 AIP
// Revert Stack
89 RCL 04
90 RCL 03
91 RCL 02
92 RCL 01
91 RCL 04
92 RCL 03
93 RCL 02
94 RCL 01
// Show Result
//90 AVIEW
93 END
95 END