(15C) Arithmetic with Fractions
|
09-24-2018, 12:27 PM
(This post was last modified: 09-25-2018 06:38 AM by Dieter.)
Post: #4
|
|||
|
|||
RE: (15C) Arithmetic with Fractions
(09-24-2018 02:19 AM)Gamo Wrote: I have changed to all of your recommended corrections. There is still room for improvement. ;-) The add/subtract routine at LBL B has a final X<>Y which is not required if you store numerator and denominator in the same way as at LBL C and D. Simply swap R5 and R6: Code: LBL B // Add or Subtract After this change all functions end with GSB 5 GTO 6. So you can combine LBL 5 and LBL 6: At the end of the GCD routine, remove the RTN and continue with the LBL 6 stuff directly. This means: at the end of the LBL B and C routines you replace GSB 5 GTO 6 with a simple GTO 5, and at the end of LBL D the program directly continues with LBL 5. The GCD routine at LBL 5 does not require any registers so R0, R7 and R8 don't have to be used. Also the initial test is not required. If you keep it (X>Y? X<>Y) you may save one loop if X is greater than Y, but I removed it anyway: Code: LBL 5 Finally, the two consecutive X<>Y at LBL E do not make any sense, so they should be removed. The final program should have about 90 lines then. ;-) Edit: here is another listing of the GCD routine including the stack contents, so you can see how it works. One step could be saved by using a R^ command, but the way it is now it can also be used on the 12C. Code: LBL 5 // b a ? ? HTH, Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(15C) Arithmetic with Fractions - Gamo - 09-23-2018, 09:24 AM
RE: (15C) Arithmetic with Fractions - Dieter - 09-23-2018, 05:12 PM
RE: (15C) Arithmetic with Fractions - Gamo - 09-24-2018, 02:19 AM
RE: (15C) Arithmetic with Fractions - Dieter - 09-24-2018 12:27 PM
RE: (15C) Arithmetic with Fractions - Gamo - 09-25-2018, 02:08 AM
RE: (15C) Arithmetic with Fractions - Dieter - 09-25-2018, 06:39 AM
RE: (15C) Arithmetic with Fractions - Gamo - 09-27-2018, 02:14 AM
RE: (15C) Arithmetic with Fractions - Jlouis - 02-05-2019, 04:02 AM
|
User(s) browsing this thread: 1 Guest(s)