Page 1 of 1

Conditional Programming

PostPosted: Mon Mar 28, 2022 9:54 pm
by eroeder
Hello!
I am new to the site, but a big fan of the HP-41CX. I am trying to brush up on my old programming, but stuck. I see that some conditionals are on the keyboard, while others are in blue. I have completely forgotten the keystrokes to put in the line of code X<0?

How do you code ASCII letters while you are programming? Old brain has hit a brick wall, and the manuals I have don't step you through the exact keystrokes, I guess we all just knew back in the day...

Re: Conditional Programming

PostPosted: Mon Mar 28, 2022 10:42 pm
by Garth
Welcome.

Whether in program mode mode or not, you'll press:

XEQ ALPHA X shift I shift 0 3 ALPHA

The X is on the 6 key. Shift-I is the less-than symbol, shift-0 is the text 0, and 3 gives you the question mark.

Re: Conditional Programming

PostPosted: Mon Mar 28, 2022 10:46 pm
by eroeder
Wow, I feel so stupid!
Is there a cheat sheet to show the unlabeled characters below when in ALPHA? Oh wait, found it on page 25 of the manual. Ugh!

Thanks!

Re: Conditional Programming

PostPosted: Mon Mar 28, 2022 10:53 pm
by Garth
It's on the back of the calculator too.

Re: Conditional Programming

PostPosted: Tue Mar 29, 2022 2:18 am
by eroeder
Ugh! Why didn’t I remember that???

Re: Conditional Programming

PostPosted: Sun Apr 10, 2022 6:50 pm
by floppy_stuttgart
eroeder wrote:Ugh! Why didn’t I remember that???

Looks like a person need an on-site training. Have a look at upcoming meetings in your country and you will meet and you will speed(catch)-up.
From south-germany.

Re: Conditional Programming

PostPosted: Sun Apr 10, 2022 10:10 pm
by eroeder
:D

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 4:49 am
by jamhaley
Can’t believe I found my 1987 HP41CX in a storage box, ordered a 3D printed battery case and VOILA! It’s alive! Just one problem. I tried this sample looping program from p. 305 of manual. It should count down to zero, beep and end, but instead just keeps going into negative numbers. Both my iOS emulator and calculator do the same thing. Any ideas? Fixes?

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 5:17 am
by Garth
It works for me.  What number did you start with?  If you start with a really high number, it will take a long time to reach 0 and beep.  I'm surprised they used a global label to branch to though.  If you put LBL 01 after LBL "ABC", then put GTO 01 instead of GTO "ABC", it will run much faster, because the branch distance gets compiled.

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 6:20 am
by jamhaley
Hmmm…I started with 100. I tried your suggestion of LBL 01 & GTO 01, although it executed faster, it still just kept going past zero into negative numbers. Could I have some syntax error in my X>0?

I literally haven’t programmed it since the eighties. Although just spherical trig and arithmetic, I used it to calculate my cargo on a tanker and celestial navigation.

If I can’t get this simple thing to work I’m beyond pathetic! Help me Mr. Wizard!

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 6:50 am
by Garth
If you single-step it, can you see the number going down?

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 6:54 am
by jamhaley
Yes, it does…

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 7:14 am
by Garth
The calc does seem to be working, so I doubt there's a problem with its hardware.  It'll probably be one of those forehead slappers when you figure it out.  Now I'm interested.

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 7:32 am
by jamhaley
Yep, I’ll get back to you when I finally figure it out. How hard could a 7 step program be?
Thanks,
JH

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 5:26 pm
by jamhaley
Getting out the cobwebs…still working on that 7 step program, but wanted to test hardware. HP41CX will “beep” if I SF 11 and power cycle, but does not beep when I run this:

LBL BP
“BEEP”
PSE
GOTO BP
END

It just loops but never beeps???

Is there a command to test everything?

Thanks,
JH

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 7:35 pm
by Garth
Flag 26 is the audio-enable flag.  It sounds like it's clear.  If you do a SF 26, the beep should work again.  It's strange though, as flag 26 should be set when you first power up.  Also, I don't think that would affect the test and branch in your original problem.

Is there a command to test everything?

There's no command for that, but there is a module that does that.  I have no idea where, or even if, you could get one anymore.  Serious users these days are using something like Diego's Clonix or NoV-64 hardware plug-in modules (I have the Clonix-D) that hold lots of ROM module images in their flash memory, or a 41CL transplant board which has hundreds of modules pre-installed and runs up to 50 times as fast as the original, or the MAXX module which should be available soon (see https://www.systemyde.com/pdf/maxx-4d_manual.pdf for the manual), or maybe another option or two I might be forgetting.  There's also SwissMicros' DM41x which is a modern replacement that's better in nearly every way but the huge drawback for me is that there's no option for HP-IL.

As you figure out and post more of what does and does not work, hopefully another member here who knows more about the insides than I do will be checking in soon and give you some better guidance than I can. 

Re: Conditional Programming

PostPosted: Fri Jan 26, 2024 8:16 pm
by jamhaley
Thanks Garth,I’ll post any progress worth mentioning.
JH

Re: Conditional Programming

PostPosted: Sun Jan 28, 2024 6:27 am
by jamhaley
Ah Hah…head smacking complete!

When entering my X>0?, I was merely typing ALPHA X>0? instead of XEQ ALPHA X>0?, so it was just an ALPHA string not a command! It looked right on the display, but had that telltale little “T” character in front, and still looped due to the GOTO line, but had no proper conditional test to exit the loop.

Sorry to have bugged you Garth for such a dumb error. Shows how much one can forget since 1980-something. Hail HP for building a machine that would sleep in a storage box for 36 years and then spring to life again!

Humbly,
JH

Re: Conditional Programming

PostPosted: Sun Jan 28, 2024 6:39 am
by Garth
Yeah, forehead slapper for sure.  Obviously I hadn't thought of that.  I'm glad all is fine now.