Post Reply 
nonpareil-0.79 and HP41 modules
01-17-2021, 04:54 PM
Post: #1
nonpareil-0.79 and HP41 modules
Hi all,

after 15+ years of HP-41 absence I've been building my own HP-41 frankenclone for some weeks now, based on a Adafruit Feather M4 in Arduino mode (C/C++, not CircuitPython due to some hardware limitations like interrupts and sleep modes). The source code is here (ugly stuff, be careful!) https://github.com/hmilz/hp-99 . Most basic HP-41C stuff is implemented and works fine or requires little work to finish, plus a couple of extra functions not available on the original HP-41, above all the much higher math precision due to the use of MAPM, an arbitrary precision decimal library.

Like Free42, this is a complete rewrite without any HP code, but Free42 is 15 years and a couple of lightyears ahead ;-) The box was meant as a research & fun device and is not HP-41 binary compatible, i.e. there is no programmability yet, and I would have to rewrite everything from scratch. I've come to a point where I need to make a decision either to continue the frankenclone with its inherent limitations, or change direction.

Nonpareil would be something to look at, and basically I would have to write a compatibility layer interfacing my hardware to nonpareil (keyboard and display, namely). The main advantage would be that Nonpareil would give me 100% HP-41 binary compatibility. Now I've played a bit with the build on Linux, and as it seems that version 0.79 (I use the the snap build for Ubuntu https://snapcraft.io/install/nonpareil-cm/ubuntu) seems not to be able to load modules. When I try to load any module that should be supported according to mod1_file.c, I get e.g.

Unsupported hardware: HEPAX Module

and any of the application packages like MATH gives me

Currently only MOD1 pages at fixed page numbers are supported

Question: What am I missing? Should this be working and there is a layer 8 problem?

TIA!
Find all posts by this user
Quote this message in a reply
01-18-2021, 09:35 AM
Post: #2
RE: nonpareil-0.79 and HP41 modules
OK I can load PRINTER just fine. But it is usually at a fixed ROM page, whereas application pacs are not:

(01-17-2021 04:54 PM)hmilz Wrote:  Currently only MOD1 pages at fixed page numbers are supported

So Nonpareil 0.79 cannot handle dynamic ROM pages for application pacs? Still trying to understand the source code. In proc.c, function static bool sim_read_mod1_page appears to explicitly exclude ROMs with page.Page > 0x0f, in particular POSITION_ANY from mod1_file.h. Apparently, after this code, something is missing to find an empty slot and allocates it to page.Bank. If that is done, the remaining code (the for loop) should load the ROM page just fine.

Any insight?

TIA!
Find all posts by this user
Quote this message in a reply
01-18-2021, 02:34 PM
Post: #3
RE: nonpareil-0.79 and HP41 modules
Hard-configured ROMs are at fixed addresses: i.e. Printer @page #6, HPIL @page #7

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
01-18-2021, 08:55 PM
Post: #4
RE: nonpareil-0.79 and HP41 modules
Hi hmilz,

I am happy that https://github.com/achan001/MAPM-5 got used in your project.

Just a comment on conversion from MAPM number to integer.
https://github.com/hmilz/hp-99/blob/main/hp-99.ino#L727
Quote:// sadly, there is no function to convert MAPM to int directly.
// alternative:
// i = (int) sto[i].toDouble(); // converts to double and casts to int.

Actually, "alternative" is much faster than doing MAPM -> string -> int.

m_apm_to_double(x) is fast, *and* with correct rounding.
Find all posts by this user
Quote this message in a reply
01-19-2021, 08:56 AM (This post was last modified: 01-19-2021 08:57 AM by hmilz.)
Post: #5
RE: nonpareil-0.79 and HP41 modules
Hi Albert,

(01-18-2021 08:55 PM)Albert Chan Wrote:  I am happy that https://github.com/achan001/MAPM-5 got used in your project.

Yes - I was looking for a suitable decimal library and MAPM appeared to be the most suitable one. Also, it compiled out of the box using gcc-arm 9.2.1. Thank you for picking up Mike's work after his passing!

(01-18-2021 08:55 PM)Albert Chan Wrote:  Actually, "alternative" is much faster than doing MAPM -> string -> int.
m_apm_to_double(x) is fast, *and* with correct rounding.

Certainly. It only has one downside in that double32 does not provide more than, say, 6 or 7 significant digits, so I can't use it e.g. for OCT/DEC conversion with more than this many digits.

The downside to moving to Nonpareil and stock HP-41 ROMs would be to ditch MAPM and hence lose the better precision. But looking at the Nonpareil code more throughly, I am not sure if I'll be able to carve out all the thread and Gtk stuff. The idea would be to have NP as a static library so to speak because there is no such thing like threading in an embedded Arduino environment per se. Maybe ArduinoThread would help but using NP looks like a lot of work. I think the NP-41 guys must have done something like this but they did not release any code, and the project looks stale now. So if someone could help converting NP to library that would be nice!
Find all posts by this user
Quote this message in a reply
01-24-2021, 03:20 PM
Post: #6
RE: nonpareil-0.79 and HP41 modules
In the meantime I found Khanh-Dang Nguyen Thu Lam's patch which allows for port based module adressing, autoloading, and HP-IL, and I also fixed some Python3 triggered errors in scons so that I was able to build a patched version that (auto)loads standard application pacs just fine. I will probably expand this a bit to allow for entering a ROM page between, say, 6 and F, in X.

I created just another github repo that holds my code.

The next step would be to see how I can separate the Gtk layer from the simulator proper, and I'm hoping that Chris Chung sends me his NP-41 code in the next few days. I'll then add some Nonpareil code in proc.c to provide a 040 (NOP) interface for a few simple Mcode programs, allowing to plug, unplug and catalog available modules (in QSPI flash memory) without a GUI.

I'm also exploring to write a bit-banging driver for the Adafruit part connecting to a genuine HP-41 display. This would require a bit more of "electric" work, and I would need an old HP-41 with a know good display and an empty port module to attach a logic analyzer to the bus. Although I must say I am very hesitant to rip apart any of the vintage stuff. So it's either a vintage HP-41 revived or something like the Aricalculator which I find rather neat. I might also use my existing emulator box that works perfectly fine electrically. Not sure yet.

Btw does anyone know if the DM-41X is built in a similar way, or do they have their own emulation layer on top of the Cortex-M4? AFAIK it's not open sourced in any way, which it would have to be if they used Nonpareil under the GPLv2. At least for paying customers.
Find all posts by this user
Quote this message in a reply
01-24-2021, 08:29 PM
Post: #7
RE: nonpareil-0.79 and HP41 modules
(01-24-2021 03:20 PM)hmilz Wrote:  Btw does anyone know if the DM-41X is built in a similar way, or do they have their own emulation layer on top of the Cortex-M4? AFAIK it's not open sourced in any way, which it would have to be if they used Nonpareil under the GPLv2. At least for paying customers.

The emulation layer for the DM41X is not related to Nonpareil, it was purpose-built, from scratch for the DM41X product. It is indeed not open sourced.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
11-29-2021, 10:39 PM
Post: #8
RE: nonpareil-0.79 and HP41 modules
(01-24-2021 03:20 PM)hmilz Wrote:  I created just another github repo that holds my code.

Hi hmilz,

Started to embark on using the guts of Nonpareil in other ways, but wanted to check to see if I didn't need to re-invent the wheel too much... Is this code available anywhere? I have made a simple Arduino library for the HP-35 emulator that other's created, and would like something similar for later HP models.

My lib is currently being used in this project.

Thanks!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)