Find a file
Christophe de Dinechin 9a47650ca9 Add expand, collect and simplify functions
Add the basic rules for `expand`, `collect` and `simplify`.

And to be honest, I am quite proud of the fact that the core code looks
_exactly_ like this (this is actual code):

```c++
    return rewrite((x+y)*z,     x*z+y*z,
                   x*(y+z),     x*y+x*z,
                   (x-y)*z,     x*z-y*z,
                   x*(y-z),     x*y-x*z);
```

A lot of template metaprogramming to turn that into transparent
building of _compile-time constants_ representing the RPL objects for
the equations, and passing that to the `rewrite` function that was
implemented earlier.

What is really neet about this is that the generated equations:

* Are automatically _shared_ if used multiple times, because they are
  represented by the same template. So the equations used in `collect`
  and those used in `expand` (which are the same in reverse) share the
  same memory.

* Automatically go into QSPI, not consuming precious flash space,
  because they are represented as initialized data arrays, and I
  requested that all C++ .rodata go in QSPI.

I intentionally did not support the historical names
(`expan` and `colct`). Our level of compatibility with the HP48 is
never going to be that good anyway.

The code as is works with `clang`, but runs into unsatisfied symbols
with g++ 10.3 due to what I believe is a g++ bug (that's what living
on the edge of template metaprogramming gives you):

```
/opt/homebrew/Cellar/arm-none-eabi-gcc/10.3-2021.07/gcc/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld: build/release/equation.o: in function `equation::collect() const':
equation.cc:(.text._ZNK8equation7collectEv+0xd0): undefined reference to `eq<(unsigned char)10, (unsigned char)1, (unsigned char)120, (unsigned char)10, (unsigned char)1, (unsigned char)122, (unsigned char)57, (unsigned char)10, (unsigned char)1, (unsigned char)121, (unsigned char)10, (unsigned char)1, (unsigned char)122, (unsigned char)57, (unsigned char)55>::object_data'
```

Fixes: #231

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-29 20:59:28 +02:00
DB48X-Keys keys: Update key layout for easier matrix/vector entry 2023-07-25 19:22:05 +02:00
dmcp Convert main to C++ 2023-06-19 21:56:30 +02:00
doc Add link to HP Museum and to Paul Graham's explanations on Lisp 2023-07-29 09:32:52 +02:00
fonts Add expand, collect and simplify functions 2023-07-29 20:59:28 +02:00
inc Decimal128 objects and related 2023-06-19 21:56:30 +02:00
lib DMCP Version 3.13 2019-05-22 14:19:31 +02:00
recorder@9b1b214ab2 Update version of the recorder 2023-07-01 09:32:52 +02:00
sim header: Draw time in the header depending on options 2023-07-28 21:57:16 +02:00
src Add expand, collect and simplify functions 2023-07-29 20:59:28 +02:00
STATE Release v0.2.4 - Dynamic spacing while editing 2023-07-11 09:53:17 +02:00
tools Attempt to build a QSPI image that is compatible with DM42 program 2023-06-25 21:18:11 +02:00
.clangd Find includes two level up (necessary e.g. for target.h) 2023-06-20 18:47:55 +02:00
.gitignore Add various files to .gitignore 2023-07-05 08:32:30 +02:00
.gitmodules Change submodule path to https 2023-06-19 21:56:32 +02:00
BUILD.md help: Add various acknowledgements to the help file 2023-07-21 12:08:08 +02:00
FREEDOM_COVENANT.txt Add freedom covenant to that repository 2023-07-07 21:23:43 +02:00
Keyboard-Cutout.png keys: Update key layout for easier matrix/vector entry 2023-07-25 19:22:05 +02:00
Keyboard-Layout.png keys: Update key layout for easier matrix/vector entry 2023-07-25 19:22:05 +02:00
LICENSE.txt Initial definition of the runtime and object type 2023-06-19 21:56:30 +02:00
Makefile list: Split list.h and list.cc into program, equation and array 2023-07-22 15:07:19 +02:00
README.md Add link to HP Museum and to Paul Graham's explanations on Lisp 2023-07-29 09:32:52 +02:00
STATUS.md equations: Implement equation rewrite engine 2023-07-26 09:03:19 +02:00

DB48X on DM42

The DB48X project intends to rebuild and improve the user experience of the HP48 family of calculators, notably their "Reverse Polish Lisp" (RPL) language with its rich set of data types and built-in functions, and Lisp-level programming power.

The project in this repository is presently targeting the SwissMicro DM42 calculator, and leveraging its built-in software platform, known as DMCP. There is also a simulator that is tested on macOS or Linux.

In the long-term, the vision is to be able to port DB48X on a number of different physical calculator platforms, like the ARM-based HP50 and related machines (HP49, HP48Gii, etc), and the HP Prime (at least the G1, since the G2 seems a bit more locked down), maybe others. The basis for that work can be found in the DB48X project.

This project was presented at FOSDEM 2023

Watch the video

Why name the project DB48X?

DB stands for "Dave and Bill", who are more commonly known as Hewlett and Packard. The order is reversed compared to HP, since they reportedly chose the order at random, and it's about time Dave Packard was given preeminence.

Part of Dave and Bill's great legacy (beyond giving birth to the Silicon Valley) is a legendary series of calculators. The HP48 remains one of my favorites, notably for its rich built-in programming language, known as Reverse Polish Lisp (RPL). This project aims at recreating a decent successor to the HP48, at least in spirit.

State of the project

This is currently UNSTABLE and INCOMPLETE software. Please only consider installing this if you are a developer and interested in contributing. Or else, have a paperclip at hand just in case you need to reset your calculator.

The detailed current status is described in the STATUS file.

Self-test in the simulator

How to build this project

There is a separate document explaining how to build this project. The simulator includes a test suite, which you should run before submitting patches. To run these tests, pass the -T option to the simulator, or hit the F12 key in the simulator.

Built-in documentation

The calculator features an extensive built-in documentation that uses a restricted version of Markdown. You access that built-in help by holding a key down, or using the Help command

Other documentation

There is DMCP interface doc in progress see DMCP IFC doc (or you can download html zip from doc directory).

The source code of the DM42PGM program is also quite informative about the capabilities of the DMCP.