(41cx) Mancala Board Game (42s, 35s)
05-10-2016, 03:17 PM
Post: #21
 Ángel Martin Senior Member Posts: 1,254 Joined: Dec 2013
RE: (41cx) Mancala Board Game
(05-10-2016 01:27 PM)brianddk Wrote:
(05-10-2016 08:03 AM)Massimo Gnerucci Wrote:  What speed did you set in V41 (Options / More Settings...)?
Cranked up full, yes, that helped alot, but couldn't figure out how to use 'Turbo'-tab.

TURBO works *while* you keep the TAB key down...
05-10-2016, 06:43 PM
Post: #22
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (41cx) Mancala Board Game
(05-10-2016 06:14 AM)brianddk Wrote:  Light testing using hp41uc (through dosbox) and v41r8.exe as the emulator. Honestly, my impressions are that is likely too slow to realistically play through the simulator. Real HW might be faster.

LOL – have you ever used a real hardware HP41? Man, this was 1979! The 41C was about three times as fast as the 67/97, but still it does not even come close to a contemporary home computer (with 1 MHz at that time). Execution times of one or more minutes are common for iterative math programs (e.g. matrix inversion).

Try a simple program:

Code:
CLX LBL 01 SIN SIN SIN GTO 01

With a speed setting that comes close to a hardware HP41 this should run with about one loop per second (watch the "flying goose" in the display move).

Yes, the emulator can do it MUCH faster than this. There is a speed setting in the menu and a Turbo mode which is activated by pressing the TAB key. So if you want speed, start your program on V41 and then press TAB. In most cases a short key press is sufficient as the program now has finished within the fraction of a second. ;-)

Dieter
05-10-2016, 07:19 PM (This post was last modified: 05-10-2016 07:21 PM by brianddk.)
Post: #23
 brianddk Junior Member Posts: 24 Joined: Apr 2016
RE: (41cx) Mancala Board Game
(05-10-2016 06:43 PM)Dieter Wrote:  LOL – have you ever used a real hardware HP41? Man, this was 1979! The 41C was about three times as fast as the 67/97, but still it does not even come close to a contemporary home computer (with 1 MHz at that time). Execution times of one or more minutes are common for iterative math programs (e.g. matrix inversion).

Thx... feel better now. BTW anyone ever try the DM41L (*want*)? Does that run at HP41 speeds, or closer to V41 speeds? Might put this on my Christmas list just to keep the company a float. Since I've endoctrinated my kids with hp calculators, it would be nice for some company to continue to make an hp clone.

(05-10-2016 03:17 PM)Ángel Martin Wrote:  TURBO works *while* you keep the TAB key down...

Ahhhh, so it turns out CAPLOCK != TAB. Yes, that is much much better. Thx

(05-07-2016 07:37 AM)Dieter Wrote:  After a short look at the code I wonder why some integer constants carry trailing zeroes (e.g. 4.0, 0.0, 6.0 ...). And what about an optimized more effective (shorter and faster) version ?-)

Wow.. I just realized that '4.0' uses more program memory than '4'. That really surprised me. I'll need to start looking at how opcodes and constants are stored.

(05-07-2016 07:26 PM)brianddk Wrote:  I did eventually find an "Educators" page where you can request teaching material (including emulators), but I don't know that I qualify. I sent my syllabus / lesson-plan for the computer class I teach, but it's not really in the same realm as Calculus III. Might be interesting to add a section on low-level programming. The RPN 'language' has some similarities to assembler and microcode that would be fun to present.

Got my approval as an Educator *hurray*, so now I'm offically sporting hp35s emulation.

(05-09-2016 11:12 AM)brianddk Wrote:  ... When I'm done, I will hopefully have mancala-hp41c.raw, mancala-hp42s.raw, and mancala-hp35s.ep all building from the same source (well maybe not the EP file).

Got the EP file from clicking in the keys at breakfast. Took just over an hour to key in, and just under half and hour to review for errors. Found 2, so I was keying at about a 99% success rate. It runs very well on the sim, I'll report on the physical HW later. In the meantime, can anyone speak to the 35s emulator speed -vs- the actual HW? Where they well aligned?

I'll update the release to 0.2 with the updates as well as some bug-fixes (WIN-BEANS was bugged).

MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)}
Blog: https://brianddk.github.io/
05-10-2016, 08:43 PM (This post was last modified: 05-10-2016 08:57 PM by Dieter.)
Post: #24
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (41cx) Mancala Board Game
(05-10-2016 07:19 PM)brianddk Wrote:  BTW anyone ever try the DM41L (*want*)? Does that run at HP41 speeds, or closer to V41 speeds?

I can't say anything about DM41L, but you can safely assume that V41 in Turbo mode is waaaaayyyyy faster. The latter essentially is an emulation of the original Nut CPU code on today's hardware (i.e. something working with roughly 3 GHz).

If you want a fast RPN calculator, get resp. make yourself a WP34s. It's also in a class of its own in terms of precision, accuracy and its huge function set.

(05-10-2016 07:19 PM)brianddk Wrote:  Wow.. I just realized that '4.0' uses more program memory than '4'. That really surprised me. I'll need to start looking at how opcodes and constants are stored.

Well, a "4" or "4.0" does not store the value of this number, it stores exactly what you typed. On an HP41 each character takes one byte, so 4.0 uses three bytes and -3.5E-17 requires eight.

The 35s is somewhat different. Numeric constants can take up to 37 bytes, and they noticeably slow down the calculator. That's why I try to avoid this kind of constants in my 35s programs, e.g. by prestoring 1 and 2 in two registers as the program initializes (which also has the advantage of RCL-arithmetics: instead of "1 +" or "2 x" you can use RCL+A resp. RCLxB, which is much faster and requires less memory). Even replacing a simple 1 by "π SGN", a 2 by "e IP" or a 3 by "π IP" usually is a good idea.

While we're at it: why did you use 10 and y^x several times instead of the faster and shorter 10x command?

(05-10-2016 07:19 PM)brianddk Wrote:  In the meantime, can anyone speak to the 35s emulator speed -vs- the actual HW? Where they well aligned?

I can't say how the emulator controls its execution speed, and in how far this varies with the hardware it is used on. But I can say that my emulator, which is running on an old 1,5 GHz machine, matches the speed of my hardware 35s quite well.

Dieter
05-10-2016, 09:22 PM
Post: #25
 brianddk Junior Member Posts: 24 Joined: Apr 2016
RE: (41cx) Mancala Board Game
(05-10-2016 08:43 PM)Dieter Wrote:  If you want a fast RPN calculator, get resp. make yourself a WP34s. It's also in a class of its own in terms of precision, accuracy and its huge function set.

Huh... I thought the WP34s was original HW, just with new FW. If this isn't the case what original HW does it use? Just the keyboard and the case? Regardless, a sight better than the cost of the DM41L

(05-10-2016 08:43 PM)Dieter Wrote:  Well, a "4" or "4.0" does not store the value of this number, it stores exactly what you typed. On an HP41 each character takes one byte, so 4.0 uses three bytes and -3.5E-17 requires eight.

Great tips... I'll look at replacing 1000000 with 1e6 or 6,10x

(05-10-2016 08:43 PM)Dieter Wrote:  The 35s is somewhat different. Numeric constants can take up to 37 bytes, and they noticeably slow down the calculator. That's why I try to avoid this kind of constants in my 35s programs, e.g. by prestoring 1 and 2 in two registers as the program initializes (which also has the advantage of RCL-arithmetics: instead of "1 +" or "2 x" you can use RCL+A resp. RCLxB, which is much faster and requires less memory). Even replacing a simple 1 by "π SGN", a 2 by "e IP" or a 3 by "π IP" usually is a good idea.

More food for thought. I could have my 'compiler' find all constants and create a block of STO commands then replace all references with the appropriate RCL cmd. Costs size, but might gain speed in loops.

(05-10-2016 08:43 PM)Dieter Wrote:  While we're at it: why did you use 10 and y^x several times instead of the faster and shorter 10x command?

I had originally intended this to be just a 35s app, but when I looked at the final version I decided that some degree of testing and debugging would be required. Not wanting to steal my son's calculator (and the awkward discussion that would follow about Daddy's important work writing an 8bit game for it), I decided to use the 42s emulator instead. Once there, 41cx was a short leap.

Anyway, I soon found out that 42s and 41cx don't have simple hex mode selectors like 35s does, so I went with decimal. This makes you more susceptible to the overflow bug, but I'm working on code for that as well.

MyCalcs: Physical: {hp48gx, hp50g, hp35s} Emu: {hp42s(Free42), hp41c(v41)}
Blog: https://brianddk.github.io/
05-10-2016, 10:41 PM
Post: #26
 brianddk Junior Member Posts: 24 Joined: Apr 2016
RE: (41cx) Mancala Board Game (42s, 35s)

Touchy Testing
Previous disclaimers as before. I did key the entire program into a 35s, here's the checksum, but it may only match if you clear memory first (not likely). It took me just over an hour to key it in, and just under an hour to check my work for errors. I found 2. I would suggest that you set aside about 90 minutes to get it running on a 35s.

Code:
LBL M CK=E450 LN=768

Contents (in zip)
• EP file - Save file from official HP emulator (35s)
• TXT file - Program listing to use to enter program from, or import into simulator (41cx, 42s, 35s)
• LST file - Debug listing to help in debugging the program to provide comments and better LBL data (41cx, 42s, 35s)
• ASM file - The source file, like LST, but with much more detail.

Bugs
• Display is base 10, so more than 9 beans in a pit is a problem.
• When a player empties all their pits the game is supposed to end... it doesn't
• First to 24 wins, though it should catch ties... it doesn't

Fixes
• Fixed bug in [WIN-BEANS] that caused player to not win beans on capture moves.
• Fixed reference to 'MOD' on 35s, which should be RMDR.
• Fixed opening LBL and closing END on 35s listing.

Attached File(s)