HowTo create this program?

Programs for HP-41

HowTo create this program?

Postby floppy_stuttgart » Mon Mar 29, 2021 2:44 pm

Hello,
what key sequence or module should I use for creating..

LBL 'RAC'
RDN <- this
CHS
ST/ Z <- this
ST+ X <- this
/
STO Z <- this
STO T <- this
X^2
+
SQRT
ST- Z <- this
+
END

I just wanted to show an HP41 program to a family member (since its works again after 30y). I just cannot find again the doc how to input this in PRGM mode.
floppy_stuttgart
...
...
 
Posts: 7
Joined: Mon Mar 29, 2021 2:36 pm

Re: HowTo create this program?

Postby dlachieze » Mon Mar 29, 2021 4:32 pm

Hello,
Congratulations for having again a working 41C ! It's a great machine with a lot of people still developing programs and modules for it.
The instructions you're looking for are part of the 41C instruction set, no need for an additional module.
Here are the key sequences:
  • RDN: the key above XEQ with R and a down arrow (RDN: RollDowN)
  • ST/ Z: STO / . Z (/ is the division symbol, when you press . the display will show ST/ ST, which means STO divide Stack, then you press Z to specify the stack register Z and the display will be ST/ Z)
  • ST+ X: STO + . X
  • STO Z: STO . Z
  • STO T: STO . T
  • ST- Z: STO - . Z
dlachieze
......
......
 
Posts: 22
Joined: Wed Mar 11, 2009 9:39 am

Re: HowTo create this program?

Postby floppy_stuttgart » Mon Mar 29, 2021 8:22 pm

Thanks: works.

Code: Select all
LBL 'RAC'
RDN
CHS
ST/ Z
ST+ X
/
STO Z
STO T
X^2
+
SQRT
ST- Z
+
END


This is solving a.X² +b.X+c = 0

By just doing..
c
ENTER
b
ENTER
a
ENTER
XEQ "RAC"

.. both solutionx X1 and X2 are in the X and Y of the stack.
(ERROR if no solution in real).

I am happy. My program anno 1983 works again.
floppy_stuttgart
...
...
 
Posts: 7
Joined: Mon Mar 29, 2021 2:36 pm

Re: HowTo create this program?

Postby mike-stgt » Sun Apr 04, 2021 10:00 am

I attempted to reduce it in size but got squeezed out one single byte only.
mike-stgt
.........
.........
 
Posts: 63
Joined: Tue Dec 24, 2019 12:12 pm

Re: HowTo create this program?

Postby floppy_stuttgart » Sun Apr 04, 2021 5:45 pm

mike-stgt wrote:I attempted to reduce it in size but got squeezed out one single byte only.

And: what is the result of that squeezed out byte?
If I remember RDN was not necessary in the program if no "ENTER" is made after the entry "a". But for the beauty and symetrie of the entry sequence, clicking on "enter" after introducing "a" would make the symetrie of clicking "enter" after c and b and a.
So, the only squeeze possibility was to avoid that RDN.
If you have the print document (or scan to it in a link) when it was published in (198x?) I would be happy to receive it.
floppy_stuttgart
...
...
 
Posts: 7
Joined: Mon Mar 29, 2021 2:36 pm

Re: HowTo create this program?

Postby mike-stgt » Sun Apr 04, 2021 11:50 pm

floppy_stuttgart wrote:And: what is the result of that squeezed out byte?
I may use the saved byte elsewhere for something much more meaningful :mrgreen:
[...] But for the beauty and symetrie of the entry sequence, clicking on "enter" after introducing "a" would make the symetrie of clicking "enter" after c and b and a.
I've got that, therefore my routine starts with the stack set as yours.
So, the only squeeze possibility was to avoid that RDN.
As just said I start with the same stack setup. Following one of my unhappy attempts, saving one byte only was not worth the effort. Result is almost the same as with your routine, mine shows the lower root in X -- I prefer that, as it complies with the common reading direction in Europe.
Code: Select all
 01▶LBL "QG3"
ST/ T  +  /  STO T  X^2
-  CHS  SQRT  ENTER^  R^
ST- Z  +  CHS  END 

        12,00000 ENTER^
        -7,00000 ENTER^
         1,00000 ENTER^
                    RUN
         3,00000    ***
                   X<>Y
         4,00000    ***

Well, others solve sudokus or do crosswords, my preferred brainteaser is "squeezing" HP-41 routines.
mike-stgt
.........
.........
 
Posts: 63
Joined: Tue Dec 24, 2019 12:12 pm

Re: HowTo create this program?

Postby floppy_stuttgart » Thu Apr 08, 2021 8:23 am

I see. Lets adopt an other story telling ("alternative fact" -:) and now we could become "lean": lets chase waste of clicking too much the HP41CV.
By feeding the stack with
c
ENTER
b
ENTER
a

then executing a program
XEQ 'RAC'

where
LBL 'RAC'
CHS
ST/ Z
ST+ X
/
STO Z
STO T
X^2
+
SQRT
ST- Z
+
END

then we solve the equation a.X² +b.X+c = 0 and both solutions X1 and X2 are in the stack in X and Y
(only solutions in real; no solution in complex given; it would else give ERROR).
So now, is that RAC program lean/clean/short or has anybody an idea how to make it smaller?
a) smaller in number of lines
b) or smaller in number of bytes

Whatever, can somebody remember me to know how is the size of this "RAC"?
floppy_stuttgart
...
...
 
Posts: 7
Joined: Mon Mar 29, 2021 2:36 pm

Re: HowTo create this program?

Postby mike-stgt » Fri Apr 09, 2021 12:01 am

Altering the input protocol/procedure is a game changer. For the original stack setup I was able to shorten the routine by another byte:
Code: Select all
 01▶LBL "QG5"
ST/ T  +  /  CHS  ENTER^
ENTER^  X^2  R^  -  SQRT
+  X<>Y  LASTX  -  END

The size of routines is shown in CAT 1, at least on a 41CX.
mike-stgt
.........
.........
 
Posts: 63
Joined: Tue Dec 24, 2019 12:12 pm

Re: HowTo create this program?

Postby mike-stgt » Sun Apr 11, 2021 10:45 am

floppy_stuttgart wrote:So now, is that RAC program lean/clean/short or has anybody an idea how to make it smaller?
a) smaller in number of lines
b) or smaller in number of bytes

Yes, no problem. Starting from the new stack setup, plugging an Advantage and a printer offers a Einstein–Rosen bridge to a routine with a) fewer lines and b) less bytes.
Code: Select all
 01▶LBL "QGL"
2  STO 22  R^  STO 00 
R^  STO 01  R^  STO 02
SF 00  XROM "RTS"  END
I guess, this is only an intermediate stage towards the optimum.
mike-stgt
.........
.........
 
Posts: 63
Joined: Tue Dec 24, 2019 12:12 pm


Return to HP-41 Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron