BASIC: scientific functions and OPTION ANGLE DEGREES

ASIN, ACOS, ANGLE, SEC, CSC, COT; SINH, COSH, TANH and their inverses;
LOG10, LOG2; IP, FP, CEIL, ROUND, TRUNCATE; MOD; MIN and MAX of any number of
values; FACT; PI, DEG, RAD; OPTION ANGLE DEGREES|RADIANS. Out-of-domain values
give ILLEGAL FUNCTION CALL. basic/test-math.py checks each against Python's
math (within 3 ulp); the manual and README cover them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
brad ArantandClaude Opus 5.5 committed 2026-12-01 16:39:29 -08:00
1 parent 79aef8ed38
commit 25c8286cf2
8 files changed
+2985 -2375

No files matched your search

+8 -4
View File
@@ -14,8 +14,10 @@ RISC-V processor written from scratch in Verilog:
- **USB keyboard** on the board's USB host port, with a keys-held port for
games.
- **Files** saved in the board's configuration flash.
- **Software**: Dartmouth-style BASIC with graphics, sound and files, and
`DO … LOOP`, block `IF … ELSE … END IF` and `SELECT CASE`; a
- **Software**: Dartmouth-style BASIC with graphics, sound and files,
`DO … LOOP`, block `IF … ELSE … END IF` and `SELECT CASE`, and scientific
functions (inverse and hyperbolic trigonometry in radians or degrees,
`LOG10`, `ROUND`, `MOD`, `FACT` …); a
machine-code monitor with a RISC-V disassembler and assembler, and five
original games.
@@ -156,7 +158,9 @@ All in C (plus a little assembly), compiled with GCC:
`ilp32f`), correctly rounded, and the structured statements of later
Dartmouth BASIC and True BASIC (`DO … LOOP`, `EXIT`, block `IF`, `SELECT
CASE`). `lib/` has the few C library functions it
needs (small string functions, `setjmp`, and `sinf` … `sqrtf`), since
needs (small string functions, `setjmp`, and `sinf` … `sqrtf`, `asinf`,
`sinhf`, `atanhf`, `log10f`, an exact `fmodf` and the rest, each within 3
ulp), since
newlib's bring in its stdio and malloc.
- `monitor/` — the machine-code monitor: memory, registers (integer and
floating point), step, breakpoints, a RISC-V disassembler and a two-pass
@@ -196,7 +200,7 @@ the configuration flash.
| `scripts/cputest.sh` | the official [riscv-tests](https://github.com/riscv-software-src/riscv-tests) (`rv32ui`, `rv32um`, `rv32uf`, `rv32mi`, fetched into `third_party/`) and `tests/` (interrupts, the NMI and single step) on `rv32_cpu.v` in xsim, with random wait states on the data bus. Two riscv-tests don't apply: `ma_data` expects misaligned loads and stores to work (here they trap, as the spec allows) and `pmpaddr` needs PMP. |
| `scripts/sim.sh` | the whole design in xsim: the terminal, BASIC, both graphics modes, sprites, scrolling, flash files, the monitor (step, breakpoint, Pause, memory files, the assembler, Intel HEX), 3 Mbaud. `scripts/sim.sh quick` skips the terminal and the monitor; `wide` checks the 132 × 64 start-up. |
| `monitor/test-disasm.py`, `test-asm.py` | the disassembler against GNU objdump on thousands of random instructions, and the assembler against GNU as |
| `basic/test-*.py`, `games/*/test-*.py` | BASIC's line editor, RENUM, string arrays, block structures and graphics modes, and each game, on `tools/rv32emu.py` (a Python RV32IMF emulator of the machine; `tools/boardemu.py` models the game hardware). They need `pyte` and Pillow. |
| `basic/test-*.py`, `games/*/test-*.py` | BASIC's line editor, RENUM, string arrays, block structures, graphics modes and maths functions (bit for bit against Python's `math`), and each game, on `tools/rv32emu.py` (a Python RV32IMF emulator of the machine; `tools/boardemu.py` models the game hardware). They need `pyte` and Pillow. |
| `bench/` | the processor alone with 64 KB of RAM, for timing |
## Toolchain