commit 46ec483232ff0280e763c43eee8cd18722e41531
parent fad50416e39be23ec087f04784c294373e7327a0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sun, 19 Mar 2023 09:34:40 -0400
hal: formalize API in docs
Diffstat:
2 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/fs/doc/hal.txt b/fs/doc/hal.txt
@@ -1,12 +1,8 @@
# Harmonized Assembly Layer
-## Kernel
+TODO: description
-Operand structure:
-b1:0 type (0=W, 1=A, 2=PSP, 3=RSP)
-b30:2 displacement
-b31 immediate? If set, the rest of the structure is ignored and b30:0
- represent an absolute address.
+## Low HAL
Operand words:
@@ -14,9 +10,26 @@ W) -- op
A) -- op
PSP) -- op
RSP) -- op
-i) addr -- op
+m) addr -- op
+) op disp -- op
+Maximum displacement in Low HAL: 8-bit
+
+Branching and conditions:
+
+Z)
+NZ)
+
+W=0>Z,
+A=0>Z,
+Z>W,
+
+execute, a --
+branch, a -- a
+branchC, a cond -- a
+branch! tgtaddr braddr --
+branchA, --
+
Compiler words:
ps+, n --
@@ -26,6 +39,14 @@ A+n, n -- *Z*
W>A, --
A>W, --
W<>A, --
+lea, op --
+neg, --
+cmpn, n --
+<<n, n --
+>>n, n --
+andn, n --
+orn, n --
+xorn, n --
Width-aware compiler words:
@@ -35,23 +56,35 @@ Width-aware compiler words:
+, op -- *Z*
[@], op --
[!], op --
+cmp, op --
[+n], n op -- *Z*
-lea, op -- (width aware, but has the same behavior in all widths)
-Conditions
+## High HAL
+
+The "high" layer of the HAL is provided by the assembler.
+
+Operand words:
+
+i)
-=)
-<>)
+Branching and conditions:
+
+C)
+NC)
<)
->)
<=)
+>)
>=)
-Z)
-NZ)
-C)
-NC)
+s<)
+s<=)
+s>)
+s>=)
-branchC, ( a cond -- a )
->branchC, ( a cond -- a ) drop and branch
-=0>Z,
-Z>W,
+Width-aware compiler words:
+
+-, op --
+*, op --
+/, op --
+%, op --
+<<, op --
+>>, op --
diff --git a/posix/vm.c b/posix/vm.c
@@ -9,6 +9,9 @@ b3 has disp? (type "memory" always has disp)
b7:4 number bank id
b8 16b?
b9 8b?
+
+Full HAL: Unlike regular kernels, this VM contains the full HAL because it has
+no assembler to complete the HAL to "full" level later. It's all in there.
*/
#include <inttypes.h>
#include <stdio.h>