# B9 shared candidate API — HD61700 Rev. 0.45 (unqualified)
## Scope and calling environment
Exactly nine-byte Casio numeric values; decimal text conversion and raw value
transport. No arithmetic, expression editor, UI, viewer or serial dependency.
PB-2000C first. **Candidate, not released; HD61 and emulator pending.**
All RAM pointers must refer to caller-accessible RAM in UA=14h. Caller must
initialize `$SX=0` and `$SY=1` as the inherited donor expects; valid stack,
ROM/IX address mapping and exclusive scratch ownership are caller duties.
All methods leave UA=14 and clobber flags; **do not assume preservation of any
registers not expressly guaranteed below**. B9 conversion is non-reentrant.
| Service | Inputs | Success/output | Failure and guarantees |
| --- | --- | --- | --- |
| `B9_PARSE` | `$10/$11` ASCII RAM, `$12` length 0–23, `$14/$15` writable 9-byte B9 destination | `$0=0`; exact 9 bytes | `$0=1` syntax, `2` range, `3` length; destination unchanged |
| `B9_FORMAT` | `$10/$11` B9 RAM, `$12/$13` ASCII RAM destination, `$14` capacity >=20 bytes | `$0=0`, `$1` printed ASCII length before NUL; 13 significant digits in Casio scientific form except zero | `$0=1` invalid B9; `3` insufficient capacity; destination unchanged |
| `B9_VALIDATE` | `$10/$11` nine-byte RAM | `$0=0` valid, `$1=0` zero, `1` positive, `2` negative | `$0=1` bad encoding, `$1` undefined |
| `B9_ZERO` | `$10/$11` RAM dest | Writes canonical nine zero bytes | Precondition only, no status promise |
| `B9_COPY` | `$10/$11` RAM source, `$12/$13` dest | Copies exactly nine bytes | Overlap unsupported except identical pointers |
| `B9_LOAD_A` | `$10/$11` source RAM | Writes native A `$10..$18` | Inputs must be valid/present; no validation |
| `B9_SAVE_A` | `$24/$25` destination RAM | Stores native A `$10..$18` exactly without changing these bytes | Unvalidated raw transport |
| `B9_LOAD_B` | `$10/$11` source RAM | Writes native B `$0..$8` | Unvalidated raw transport |
| `B9_SAVE_B` | `$24/$25` destination RAM | Stores native B `$0..$8` exactly without changing these bytes | Unvalidated raw transport |
The `$24/$25` save pointer is deliberately outside both native operand blocks.
Using `$10/$11` as the save pointer for A would overwrite part of the result.
### Register side effects — source-inspected, NOT measured on the target
- Parse/format/validate: broad `$0..$21` and IX scratch effects; the exact
inherited converter clobber set is **NOT GUARANTEED** pending native probes.
- `B9_ZERO`: `$0,$20,IX` clobbered.
- `B9_COPY`: `$2..$5,$16,$20,IX` clobbered.
- `B9_LOAD_A`: native A is output; `$2/$3,$20..$23,IX` used by source.
- `B9_SAVE_A`: native A `$10..$18` is preserved by source design;
`$20..$23,IX` used.
- `B9_LOAD_B`: native B output; `$20..$23,IX` used.
- `B9_SAVE_B`: native B `$0..$8` preserved by source design;
`$20..$23,IX` used.
The actual register/firmware behavior and C-ROM side effects still require
owner HD61/emulator qualification. The converter's fixed UA14 RAM range is
**2E40h..2EC4h** (inclusive), including B9C_TEXT 2E40..2E57,
B9C_VALUE 2E60..2E68, B9C_FMT 2E70..2E87, B9C_DIG 2E90..2E9D,
B9C_TMP 2EA0..2EA8, per-byte flags 2EB0..2EBF and adapter slots
2EC0..2EC4. This intersects the original MathROM application workspace;
no combined MathROM image may import this candidate as-is.
### Minimal call pattern (source fragment, not an independently runnable ROM)
```asm
LDW $10,MY_ASCII ; caller RAM, not ROM
LD $12,5 ; e.g. 1E-99 length is 5
LDW $14,MY_B9 ; 9 writable bytes
CAL B9_PARSE
AN $0,$0
JP NZ,MY_ERROR
LDW $10,MY_B9
LDW $12,MY_TEXT ; at least 20 bytes
LD $14,20
CAL B9_FORMAT
```
### Tests and evidence boundary
Historical original B9CALC oracle (Oct 15 r001) has owner-reported
`B9GATE PASS 8` for its own converter/probe. Original host reference: 12
literal witnesses, 19 invalid strings, 5 range cases and 1000 seeded
round-trips. Those do **not** qualify these wrappers as a common library.
`src/b9-test01.s` is a new independent qualification ROM: see handoff and
manifest for source closure, exact fixture bytes, pending owner HD61 listing,
ROM hash, PB emulator observations and error receipts.