LIB2 / FILE VIEW

API.md

DOWNLOAD ORIGINAL ↓

> **Versioned lib2 snapshot, 2026-11-10.** The original 23-file snapshot was byte-exact from the admitted `src/lib/math/` THIN-BETA-1 beta holding. The installed comment-only 2026-11-10 edition changes only 23 historical `USAGE` include-path examples, without new firmware, assembler, runtime or general-ABI evidence. Chapter 09 remains the donor witness. The original `src/lib/math/API.md` is the working-family contract; this version-local copy pins that contract to `src/lib2/math/1/` files.

# Native MathROM THIN — API for THIN-BETA-1

**Versioned source:** `lib-set-01/src/lib2/math/1/` (initially exact source snapshot of `src/lib/math/`; documentation-only source edition, readback verified) • **Edition:** 2026-11-10 • **Status:** donor-adopted beta holding; 23/23 **EXPERIMENTAL** caller APIs.

## 1. Scope and entry points

The 23 short HD61 include files export `MATH_*` labels that tail-jump into PB-2000C resident mathematics. They are original firmware *adapters*, not independent mathematical implementations, a firmware redistributable, or a general production ABI. MREVAL is a separate Chapter 09 application, not a 24th library member.

## 2. Method matrix — provisional donor register map

| Member | Resident JP | Provisional input | Provisional result | Inherited witness |
|---|---|---|---|---|
| `MATH_ACS` | `&H0993` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_ADD` | `&H068C` | B9 x $10-$18; y $00-$08 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_ASN` | `&H0991` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_ATN` | `&H0995` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_B2BCD` | `&H0B53` | signed? int16 $03/$04 | BCD $14-$16 | S: specialist/smoke |
| `MATH_CMP` | `&H0B13` | B9 x $10-$18; y $00-$08 | CPU C/Z flags | S: specialist/smoke |
| `MATH_CNVR` | `&H0B38` | signed int16 $15/$16 | B9 $10-$18 | S: specialist/smoke |
| `MATH_COS` | `&H0926` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_DIV` | `&H06F8` | B9 x $10-$18; y $00-$08 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_EXP` | `&H08EE` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_FIX` | `&H0A82` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_INC` | `&H068A` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_LGT` | `&H08B9` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_LOG` | `&H08B7` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_MUL` | `&H06B9` | B9 x $10-$18; y $00-$08 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_PI` | `&H0A77` | none explicit | B9 $10-$18 | S: specialist/smoke |
| `MATH_POWER` | `&H09E0` | B9 x $10-$18; y $00-$08 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_RND12` | `&H0A7B` | B9 x $10-$18 | B9 $10-$18 | S: specialist/smoke |
| `MATH_SIN` | `&H0924` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_SQ` | `&H06B5` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_SQR` | `&H071F` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_SUB` | `&H0686` | B9 x $10-$18; y $00-$08 | B9 $10-$18 | D: 18-function aggregate |
| `MATH_TAN` | `&H092A` | B9 x $10-$18 | B9 $10-$18 | D: 18-function aggregate |

**Important:** Inputs/outputs above are the donor evidence register's **proposed** map, not complete ABI certification. D classes have aggregate 16-input reports; these do not establish every exact result. S classes have heterogeneous specialist/return-path evidence. All 23 remain EXPERIMENTAL for general callers.

## 3. Calling convention

Include each relevant `math_*.inc` exactly once. In an initialized compatible PB-2000C application: prepare the typed input and machine environment; execute `CAL MATH_NAME`; consume the typed output immediately. The adapter executes one `JP &Hxxxx` into original low ROM. The caller's `CAL` frame is reused when native code returns. That explains the *form* of the call, not safety of all state or exceptional returns.

## 4. Environment and ownership

Resident PB-2000C low-ROM addresses are firmware dependencies. Caller owns correct firmware mapping, UA/banks, RAM/work area, B9 operand construction, stack and angle mode. None is initialized by the adapter. No alternate model, language-card parity, AI-1000 or physical-device qualification is claimed. `MATH_CMP` returns flags whose lifetime may end with the next flag-changing instruction; `MATH_B2BCD` gives **packed BCD** at `$14..$16`; `MATH_CNVR` accepts an integer-16-bit word in `$15..$16` under a still-bounded register contract.

## 5. Register, flag and memory effects

**Preservation guarantee: NONE beyond the specific evidence-backed, typed result fields described in the donor map.** For every function, detailed GPR, C/Z, UA/workspace, scratch RAM, stack, reentrancy, operand aliasing and exceptional-return effects remain `UNKNOWN/NOT GUARANTEED`. `UNKNOWN` is **not** proof of clobbering nor preservation. Always isolate and snapshot caller state for research and do not nest unqualified operations.

## 6. Status, domains and edge cases

Native raw wrappers have **no established uniform error/status policy**. MREVAL rejects some inputs at the *application* layer (e.g. division by zero); that cannot be attributed to the low-ROM service. Unqualified domain, signedness, angle, overflow/underflow, flags and alias behavior must be tested per member, preserving both mismatches and successful results. The donor register captures these precise open cases.

## 7. Minimal calling example (excerpt only)

```asm
#INCLUDE (lib2/math/1/math_cnvr.inc)

; After target-specific startup and environment setup
LDW     $15,1
CAL     MATH_CNVR
; Provisional B9 result at GPR $10..$18
; No other preservation is promised.
```

This is an excerpt from the donor Chapter 09 calling guide, not a self-contained cartridge. For a paired Math 1.1 comparison, do not assume M11_* uses the same input registers or scratch RAM.

## 8. Source identities, version and qualification

- Versioned generation `math/1` carries library edition `THIN-BETA-1` and names exactly these 23 source bytes and this API metadata, **not** a source revision rewrite. Raw comparison on 2026-11-10: 23/23 byte-identical donor/library copies; 0 mismatches. SHA-256 for each file in `API.json`.
- Donor [curation R002](https://drive.google.com/file/d/1hLXe0GZiqvC1B09Y-rEzJaaJKC09Prk4/view): `CURATION_CLOSED / ACCEPTED_WITH_LIMITATIONS / BETA_RESEARCH` with constrained test inheritance.
- Donor [ABI and evidence register](https://drive.google.com/file/d/19bVyDsC7PZFsvi7dk1scEO3wAjNZ4pd1/view) and [source-identity audit](https://drive.google.com/file/d/1gsaHRNZo8U-XB7HHS8XIymqSrUz-7Cg4/view).
- Donor [23-function manual](https://drive.google.com/file/d/1eWCFPXMijasjLxHNah-UvQcrGaLgPzSN/view) and [public teaching edition](https://drive.google.com/drive/folders/1PF_fPh3J6wFWwh3VSpSg0bSIBOdrIysa).
- Local [member origin/API policy](https://drive.google.com/file/d/1E3Q35ZOB0JpEfJyEEwY2iS7Neso_Wdzx/view), and [Math 1.1 family](https://drive.google.com/drive/folders/1FgDR2kGdoTWwSzSH7YxvCuNFIyTrm423).
- Intake classification: **ADOPTED BETA HOLDING**, caller ABI **EXPERIMENTAL**; no new assembly, emulator, physical test, public Stable, broad accuracy, rights clearance, knowledge promotion, or claimed consumer adoption.

### Per-member hash ledger

| Source include | Source bytes | SHA-256 |
|---|---:|---|
| `math_acs.inc` | 1574 | `57ae420cc736d5fd432a9c41bee469e9befa868158f343b2120c395a9e0e52d7` |
| `math_add.inc` | 1554 | `d525a98b47635a661c107ba308ad612c486f12d447a57f3a8f62761ba7059fa3` |
| `math_asn.inc` | 1531 | `18872ca5095b262c3958b6e1040f185d54ebb7033bc68753224e21af5b17f3a4` |
| `math_atn.inc` | 1534 | `5fd8eb97ddeae6c02f51953dbe0e3cc9a7a6b5fb045bb6dd908f626ed4430e63` |
| `math_b2bcd.inc` | 1584 | `fb4e060c82da29444bfc77040bd1134a2af565a41f9a0b8fb58db7fbbf41b6c0` |
| `math_cmp.inc` | 1629 | `f9a486edb3bbe9036ddac07c2ce512c6345be9c22b33e06d4b98351194edc623` |
| `math_cnvr.inc` | 1640 | `becabafbef2a5d074acbbd1e2a60a044603184ecf5e4eee51de086dfd3359e12` |
| `math_cos.inc` | 1530 | `fcbbf630c931c9e3d0c93b82e5e83760355b6988782b582a577079e29f9555cb` |
| `math_div.inc` | 1609 | `7cc5cc8d3f6e600bb03a2dc86409b55f615b821f24064a0f9e2ff6380cbb79ba` |
| `math_exp.inc` | 1544 | `b2a970cb4f21e230b9bd20254c122b46b605487367a5846d46ffaed3473b41a9` |
| `math_fix.inc` | 1587 | `be5fc0701b3172fb24c36a7cafe833fdbdf33ccee734ef862dfa53195eaae747` |
| `math_inc.inc` | 1589 | `8a62556d0f9d2868786e907b29b1ec7b1824d43785dc22651a639eebf6c4b9c9` |
| `math_lgt.inc` | 1588 | `f151547bd5c4ff31088174c5418b554324e231cc0a749a9618e331185c600cd8` |
| `math_log.inc` | 1578 | `71b62a75a8e9131f660041a9bfd034f473e6221d9fb3a1e7d0f4bacb6445e8d9` |
| `math_mul.inc` | 1560 | `0d1a3d708d4d52ba0c505418de016e165fe45822e76a52e68d33033746cb12ba` |
| `math_pi.inc` | 1593 | `7ed3eeec84fb1d095187fa2c70c612722ba1c6be82f84a0a35d2888c5a85f907` |
| `math_power.inc` | 1620 | `eb21a3df4e8e2f68d4aff13d3a50c2e0876657f1c9db60a5fe338876155bb29f` |
| `math_rnd12.inc` | 1607 | `fe16ad0dd7a4579441752c3b82e9bc7cbc4512f9521317b3292f2c57e6b6e59f` |
| `math_sin.inc` | 1528 | `df315e9986c427d5b540619968ae69fffefb961b13da7158ddba5e9307bddac4` |
| `math_sq.inc` | 1546 | `c6e30550e96f225b4ca81d58adfe91a2bf23412307d4170c5b3594ac1c2850e4` |
| `math_sqr.inc` | 1552 | `bafbb9c771d0b7519e0c1651df8c82af3689c38a6af5d9c08f807e8dda416979` |
| `math_sub.inc` | 1559 | `1c497156e9e777df9689c1eeac81b0298f7a32fe624e5cb964b53e9dacfa19be` |
| `math_tan.inc` | 1531 | `213a14216307f41703d2eb3c2cb88180c66c4fcbe24996be0441d7937303aa26` |

*This API records a research-grade contract faithfully and intentionally labels unknowns. It is designed for improvement through an independent, instrumented consumer.*