Make terminal xHEAD and xTAIL registers 32 bits

This enables waiting on them with memory.atomic.wait32 (there is no
wait8) which is needed to avoid spinning when waiting for a key.
This commit is contained in:
2026-03-02 18:51:42 +00:00
parent 22e477adf7
commit 2a3949e09f
4 changed files with 34 additions and 30 deletions

View File

@@ -44,12 +44,12 @@ You could use any HTTP server that sets these headers.
| Name | Address | Size / B | Access |
|--------|---------|----------|--------------|
| TXBUF | 0 | 32 | write |
| RXBUF | 32 | 32 | read |
| TXHEAD | 64 | 1 | atomic read |
| TXTAIL | 65 | 1 | atomic write |
| RXHEAD | 66 | 1 | atomic write |
| RXTAIL | 67 | 1 | atomic read |
| TXBUF | 00h | 32 | write |
| RXBUF | 20h | 32 | read |
| TXHEAD | 40h | 4 | atomic read |
| TXTAIL | 44h | 4 | atomic write |
| RXHEAD | 48h | 4 | atomic write |
| RXTAIL | 4Ch | 4 | atomic read |
For both sending (`TX`) and receiving (`RX`), there are three
registers: `xBUF`, `xHEAD` and `xTAIL`:
@@ -67,7 +67,7 @@ unoccupied byte between the tail and the head.
| Name | Address | Size / B | Access |
|----------|---------|----------|--------------|
| SYSREADY | 68 | 1 | atomic write |
| SYSREADY | 50h | 1 | atomic write |
The `SYSREADY` register is used to indicate when the system has booted
up and is ready for user input.

16
emu.js
View File

@@ -1,14 +1,14 @@
const TXBUF = 0;
const RXBUF = 32;
const TXHEAD = 64;
const TXTAIL = 65;
const RXHEAD = 66;
const RXTAIL = 67;
const SYSREADY = 68;
const TXBUF = 0x00;
const RXBUF = 0x20;
const TXHEAD = 0x40;
const TXTAIL = 0x44;
const RXHEAD = 0x48;
const RXTAIL = 0x4c;
const SYSREADY = 0x50;
const TXBUF_SIZE = 32;
const RXBUF_SIZE = 32;
const PERIPHS_SIZE = 69; // Nice
const PERIPHS_SIZE = 81;
const POLL_INTERVAL_MS = 20;

View File

@@ -63,18 +63,6 @@
46 EMIT
\ Peripheral register addresses
: TXBUF 0 ;
: RXBUF 32 ;
: TXHEAD 64 ;
: TXTAIL 65 ;
: RXHEAD 66 ;
: RXTAIL 67 ;
: SYSREADY 68 ;
46 EMIT
\ Printing utilities
: CR 10 EMIT ;
@@ -214,6 +202,22 @@ CHAR . EMIT
CHAR . EMIT
\ Peripheral register addresses
HEX
00 CONSTANT TXBUF
20 CONSTANT RXBUF
40 CONSTANT TXHEAD
44 CONSTANT TXTAIL
48 CONSTANT RXHEAD
4C CONSTANT RXTAIL
50 CONSTANT SYSREADY
DECIMAL
46 EMIT
\ A better word-not-found handler
: ANY-RX? RXHEAD AC@ RXTAIL AC@ <> ;

View File

@@ -8,9 +8,9 @@
(global $TXBUF i32 (i32.const 0x0000))
(global $RXBUF i32 (i32.const 0x0020))
(global $TXHEAD i32 (i32.const 0x0040))
(global $TXTAIL i32 (i32.const 0x0041))
(global $RXHEAD i32 (i32.const 0x0042))
(global $RXTAIL i32 (i32.const 0x0043))
(global $TXTAIL i32 (i32.const 0x0044))
(global $RXHEAD i32 (i32.const 0x0048))
(global $RXTAIL i32 (i32.const 0x004c))
;; Forth registers
(global $rsp (mut i32) (i32.const 0))