Commit graph

117 commits

Author SHA1 Message Date
Christophe de Dinechin
63eb8efabd catalog: Fix a subtle bug on DM32 with the catalog content
With the original code, the loop searching for commands to add to the
catalog skips many commands. I suspect this is another case of QSPI
hammering similar to what was observed for fonts. In any case, the
workaround appears to be to slightly deoptimize the code by selecting
a lower optimization level and adding an `else` clause in the inner
`if` statement.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-12 01:14:14 +01:00
Christophe de Dinechin
9e95425850 library: Add equations library and object library
These are two catalogs that behave much like the constants catalog,
and inherit most of the code.

The equations library is intended to store standard equations.

The library is for standard objects and various useful objects or
programs.

Both can be organized by topics.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 11:20:42 +01:00
Christophe de Dinechin
7c49adaf2c makefile: Add dependency of 'all' to the decimal constants
The dependency is not quite correct anyway, it's not the end result
that is dependent on the decimal headers, but the intermediate build
steps.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:10 +01:00
Christophe de Dinechin
c62b792b19 characterss: Add dynamic characters menu
Same principle as constants and units, but simpler.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-11 01:49:09 +01:00
Christophe de Dinechin
3db955b2ab doc: Add videos and pictures to quickstart guide
Add some quick videos and screen snapshots to the quickstart guide.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 14:02:14 +01:00
Christophe de Dinechin
bbec0939c8 date/time: Refactor the code and add Julian day number
Refactor the code to put all date and time related functions into the
`datetime.h` and `datetime.cc` files.

Also added Julian day number calculations, which enable the
computation of the day of the week in the date format rendering, and
will make it easier to implement future commands such as `DDAYS`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
f29346e830 makefile: Add helper to compare images
Add `compare-foo` to compare reference images for `foo`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
2782e32e42 expressions: Graphics rendering
Graphics rendering of expressions

Fixes: #47

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 01:11:00 +01:00
Christophe de Dinechin
beaaee23e4 constants: Evaluate constants from config/constants.csv
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`

Fixes: #497

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-02 00:55:00 +01:00
Christophe de Dinechin
c12d27ac8b hwfp: Add support for hardware-accelerated floating-point
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.

See numbers recorded in `doc/6-Performance.md` for details.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
fc2c7bae10 decimal: Add Euler's constant
Add Euuler's constant to the list of built-in large constants

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:09 +01:00
Christophe de Dinechin
14b48eb21c decimal: Add code to generate constants
A single 10000-digit constant takes about 4K in QSPI space.
Constants are generated in a cache and rebuilt when precision changes.

For now, store pi, which we will need to implement sin/cos/tan

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:09 +01:00
Christophe de Dinechin
0aa6a813aa decimal: Add decimize tool to generate mantissa files
This makes it possible to store constants in packed decimal format.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:09 +01:00
Christophe de Dinechin
27aa945013 decimal: Switch DM42 back to -O2
We now have sufficient room to do that.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:09 +01:00
Christophe de Dinechin
6f2158107e decimal: Remove all the BID128 stubs and related decimal types
Remove all the bid128 interfaces to make room for the decimal stuff.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:33:06 +01:00
Christophe de Dinechin
6286deafcf decimal: First baby steps of variable-precision decimal code
The `decimal` class represents a variable-size decimal, similar to
what can be found in newRPL.

This commit implements the base class.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 19:32:23 +01:00
Christophe de Dinechin
77c5f57f8a dm42: Restore Intel decimal library by default
It's interesting to prove that we can build without it, but we can't
do a release without it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-25 11:51:13 +01:00
Christophe de Dinechin
f7484708ad decimal128: Add ability to disable decimal code
At some point, we will need to shift to variable-precision decimal.
Being able to disable all `decimal128` code will help evaluate
how much room we have for that.

With decimal128 active, sizes are:

   text	   data	    bss	    dec	    hex	filename
2254248	   3840	   2524	2260612	 227e84	build/dm42/release/db48x.elf
wc -c db48x.pgm
  710180 db48x.pgm

Without decimal128, sizes are:
   text	   data	    bss	    dec	    hex	filename
 455864	   2872	   2412	 461148	  7095c	build/dm42/release/db48x.elf
wc -c db48x.pgm
  282236 db48x.pgm

In other words, decimal128 at the moment uses 427944 bytes out of our
716800 budget (i.e. 59.7%) and 1798384 in the total size (79.7%).
Chances that a variable decimal implementation can be made smaller
than that.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-12-05 18:15:30 +01:00
Christophe de Dinechin
af64992f47 Makefile: Add check-ids target
The `check-ids` target checks if commands are in the menus
or in the help.

The `src/ignored_menus.csv` and `src/ignored_help.csv` indicate what
does not need to be reported by the tools. It was initialized with the
current state of missing things, and can serve as a reference for what
commands need to either be documented or added to menus.

Fixes: #615

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-26 22:46:21 +01:00
Christophe de Dinechin
20489b6b8a statistics: Initial implementation
Just the infrastructure to be able to build the statistics commands.

This originally exceeded the RAM section on DM42, which is surprising
(RAM, not Flash). It turns out that this was the size of the sorted
commands for the catalog, which was fixed.

Fixes: #495

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-15 01:59:04 +01:00
Christophe de Dinechin
76150c6289 files: Allow STO and RCL to write to filesystem
When the argument describing the variable is a text, interpret that as
a file path on the disk. By default, data is stored in in a directory
named `data`, which will be created if necessary. For example, you can
use `3 "foo.48s" STO` to store the value `3` in a file named
`data/foo.48s` on disk.

How the file is stored depends on the extension given to the file:

* For `.txt` files, the object is stored as text
* For `.48s` files, the object is stored as DB48X source code
* For `.48b` files, the object is stored in binary format
* For `.csv` files, the object is stored in comma-separated format.

The binary format used for `.48b` includes a 4-byte magic number
identifying a DB48X format, and a 4-byte checksum used to ensure
binary compatibility between the firmware and the disk format.

At least during early days of development (prior to 1.0), it is quite
unlikely that the binary format for one version of the firmware would
be readable or writable by another version. If you need to recover
data from another version, you need to install that version and save
the object again in `.48s` (text) format.

Fixes: #375

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-15 01:59:04 +01:00
Christophe de Dinechin
328c2e484f Makefile: install demo state and configuration
Better to update the demo and unit configuration files when updating

Fixes: #547

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-06 00:19:11 +01:00
Christophe de Dinechin
c548d19413 Implement debug_printf
Implement a `debug_printf` that shows something on the screen, and a
`debug_wait` to wait for a given delay or a key.

Fixes: #541

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-05 14:19:59 +01:00
Christophe de Dinechin
d49a9bb478 Rename equation as expression
The `equation` type does not really represent equations (it may)
but arithmetic expressions.

Fixes: #518

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-11-01 19:54:49 +01:00
Christophe de Dinechin
c8d9f4fb9d Makefile: Add a sync before ejecting
This avoids havinf `hdiutil eject` complaining that the resource is busy

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:18:47 +02:00
Christophe de Dinechin
a5ae7bcbe9 dm32: Generate config-independent font file
The generated font files contained an ID that could depend on the
configuration settings for the build. That caused the font file on
DM32 to be incorrect, which caused a crash when editing text.

Fixes: #458

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:18:47 +02:00
Christophe de Dinechin
b4eeaa6bb8 unit: Implementation of unit objects
This is a very basic implementation of unit objects.
Unit objects are treated as equations where the outermost object
is an ID_mkunit operator.

Fixes: #16

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00
Christophe de Dinechin
76927fcd20 documentation: Distinct sections for DM32 and DM42
Add the ability to have machine-specific text in the on-line help.

Fixes: #450

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-23 00:10:03 +02:00
Christophe de Dinechin
572cd55ed2 documentation: Update DM42 to DM32 for DB50X
For the moment, simply perform textual replacements

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-22 23:46:37 +02:00
Christophe de Dinechin
9f5ca3dcd2 help: Skip images in the source file
Allow images in the source markdown files, but skip them on calculator

Note that we need to skip them at runtime if we want to be able to
have them in the GitHub file correctly.

Fixes: #438

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
ba206a6e33 build: Build DB50X with CONFIG_FIXED_BASED_OBJECTS
This is mostly to validate the sanity of that build option
(a compilation bug was actually fixed).

Fixes: #432

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
a9b08b3f52 build: Rename 'simulator' to 'db48x'
The name `simulator` is both long and non-descriptive.
Since the `db48x.pgm` and `db48x.pg5` cannot be confused with either
`db48x.app` (macOS), `db48x.exe` (Losedows) or `db48x` (Linux/BSD), it
seems safe to rename the simulator as `db48x`.

Also always build the files with lowercase names.

Fixes: #417

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-20 20:25:16 +02:00
Christophe de Dinechin
6f3c07e759 integrate: Initial implementation of numerical integration
Implement a really basic algorithm for integration evaluation.
This divides the integration surface by two every time.
This appears much less efficient than the integration done by HP calculators.

Fixes: #42

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
6cce8f9a45 Add root command
Add the `root` command, which implements a numerical solver

Fixes: #36

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-15 22:11:33 +02:00
Christophe de Dinechin
2b8c44c4d7 makefile: Automatically regenerate image files
The PNG image files are easy to generate from Keynote, but getting
from there to the file used in the simulator build was still manual.

Generate the target files automatically from the Keynote output.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-05 18:51:39 +02:00
Christophe de Dinechin
582aba1fda Makefile: Prepare copy on other platforms
In case we want to build on some other platform, make it easier to
copy the file. Also makes it possible to use rsync instead.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-10-01 14:01:42 +02:00
Christophe de Dinechin
d887eceed1 help: Create simulator help files that are target-specific
Generate different files for DB48X.md and DB50X.md.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 23:54:36 +02:00
Christophe de Dinechin
52d15bda32 Makefile: Move the QSPI CRC in a variant-dependent directory
This makes it easier to rebuild the DM32 and DM42 in parallel
during release.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 23:13:12 +02:00
Christophe de Dinechin
294c6a4664 Call DM32 builds 'DB50X'
In order to properly distinguish the DM32 and DM42 builds, call
the DM32 variant 'DB50X' (both for program and QSPI file).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 20:09:42 +02:00
Christophe de Dinechin
3b7af3a360 Makefile: Switch to -Os for DM42
We are now reaching the point where we need to use that option to fit
on the DM42. The time has come to switch to `-Os` to compress the code
a little.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 10:41:51 +02:00
Christophe de Dinechin
012ddf2548 grob: Add support for bitmap graphic objects
Graphic objects (GROB in RPL parlance) represent bitsmaps of arbitrary
size. They can be used to represent the screen or any other graphic
surface.

Fixes: #30

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-30 10:41:42 +02:00
Christophe de Dinechin
5645c4f8c3 Implement Tag type
The tag type is used to add a label to any arbitrary object.
It is parsed as `:Label:object`, and renders the same, except on the
stack where it renders as `Label:object`.

Note that the HP48 renders a label with an extra space. The space is
apparently gone on the HP50.

Fixes: #21

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-09-13 16:45:49 +02:00
Christophe de Dinechin
209d202ea7 Implement source-code comments
This commit implements comments that are preserved in the source code.

A comment begins with `@` and ends with the end of line.
It acts as a no-operation during execution.
It is rendered beginning with a new-line.

This commit also adjusts various issues related to rendering of
newlines and indentation in loops or blocks.

Fixes: #94

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-27 10:23:03 +02:00
Christophe de Dinechin
eb68728c77 Add support for PPAR / PlotParameters special variable
The PPARM variable defines the plotting / drawing range

Fixes: #319

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-13 19:23:30 +02:00
Christophe de Dinechin
3140e71524 makefile: Add version information to output of build
Also integrate the correct version of the QSPI into the release files

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-08 00:12:52 +02:00
Christophe de Dinechin
225de7d7f5 license: Change to GPL v3, disconnect from DMCP
The dmcp code is moved to a submodule, with its own BDS 3-clause license.
The DB48X code uses DMCP, but is not derived from it.
The GPL license will provide better protection against derivatives with
proprietary additions that are not contributed back to the community.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
d043d8a99f makefile: Add 'make clangdb'
Add a rebuild target for the clangd database

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
078563d278 Implement if-then-else and iferr
Implement `if` `then` `else` blocks, as well as the `iferr` variants.

Being able to test `iferr` also required implementing several
secondary error-management commands, like `errm`, `errn` and `doerr`.

Fixes: #290
Fixes: #291

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:58:27 +02:00
Christophe de Dinechin
412685818d DMCP5 support and DM32 build
Add support for DMCP5 and DM32 build
This is not perfect at the moment. Some glyphs, like the complex-i,
are missing from menus or the help display, as well as from the
editor font, but show on the stack font. This is rather weird.
Displaying some menus, like the STATS menu, cause a crash in
what appears to be sparse_font::glyph.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-08-07 23:56:41 +02:00
Christophe de Dinechin
e8da3016f8 makefile: Cleanup Emacs backup files before packaging
Running `make dist` could package files that do not belong.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2023-07-30 15:27:01 +02:00