|
|
@@ -0,0 +1,43 @@
|
|
|
+# V3 step 5.3 — Math, WholeIO, input (done 2026-09-22)
|
|
|
+
|
|
|
+Third stdlib landing. Suite 93/93 (50 run — incl. 4 trap-aborts,
|
|
|
+4 sessions, 2 session-output, 2 session-input, 1 unit — + 43 reject).
|
|
|
+LL(1)-clean, zero gm2 warnings.
|
|
|
+
|
|
|
+## Math (`stdlib/math`)
|
|
|
+
|
|
|
+Direct libm bindings via `EXTERNAL` (the routine names are valid
|
|
|
+Modula-2 identifiers and match the C symbols): `sqrt`, `exp`, `ln`,
|
|
|
+`sin`, `cos`, `arctan`, plus `fabs` exposed as `abs`, and the
|
|
|
+constants `Pi` / `E`. REAL parameters/returns lower as QBE `d`.
|
|
|
+Harness now links `-lm`.
|
|
|
+
|
|
|
+`MathProg` → 12 (`sqrt(144.0) + sin(0.0)`).
|
|
|
+
|
|
|
+## Input (`runtime/syslib/shim.c` + `SysIO`)
|
|
|
+
|
|
|
+Shim additions `m2readchar` (fgetc), `m2readint` (whitespace-skipping
|
|
|
+signed decimal). `SysIO` gains `ReadChar` / `ReadInt`; the harness
|
|
|
+gains `expect_run_files_in` (pipes stdin). `ReadProg` reads two
|
|
|
+integers and prints the sum → `42`.
|
|
|
+
|
|
|
+## WholeIO (`stdlib/wholeio`)
|
|
|
+
|
|
|
+Classic `WriteInt` / `WriteCard` / `ReadInt(VAR)` / `ReadCard(VAR)`
|
|
|
+over the shim integer routines. `WholeIOProg` reads two ints and
|
|
|
+prints their product → `42`.
|
|
|
+
|
|
|
+## Notes
|
|
|
+
|
|
|
+- External functions returning `CHAR`/`INTEGER` bind directly
|
|
|
+ (`m2readchar() : CHAR`, `m2readint() : INTEGER`); a zero-parameter
|
|
|
+ external call is `name()`.
|
|
|
+- `math.def` REAL constants are emitted as globals flushed at
|
|
|
+ `main` startup (existing REAL-const path), so `Math.Pi` loads
|
|
|
+ correctly in clients.
|
|
|
+
|
|
|
+## Deferred to 5.4+
|
|
|
+
|
|
|
+`Files`, `Storage` / `SYSTEM` (`ALLOCATE`/`DEALLOCATE`, `ADDRESS`,
|
|
|
+generic pointers — needs SYSTEM types), explicit external link
|
|
|
+names, string escapes, `ReadString`. Traps still `$abort`.
|