From 4fb4dffa202bb7a09eb2c0c2784f28eb11137f04 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 18:14:02 +0330 Subject: fix: bytes test read one byte past the fixed map into the heap rt.MW is the end of the fixed map (PW) since the growing heap landed; the heap starts right there, so ld16(addr_b(rt.MW)-1) read the heap's first byte: 0 on the default map by luck, 0x40 on the small map (16384). Probe the real byte-op bound instead: core answers syscall(9,10) with the host reservation MW; micro ports, whose bound is their memory size, fall back to syscall(9,0). --- tests/programs/bytes.zc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/programs/bytes.zc b/tests/programs/bytes.zc index 1332c26..97a0480 100644 --- a/tests/programs/bytes.zc +++ b/tests/programs/bytes.zc @@ -13,7 +13,7 @@ fn sumbytes(n) { return s; } fn main() { - let buf[3], b; + let buf[3], b, lim; buf[0] = 0; buf[1] = 0; buf[2] = 0; b = rt.addr_b(buf); rt.st8(b, 0x11); @@ -32,7 +32,9 @@ fn main() { rt.put_n(buf[1]); sp(); rt.st8(0 - 1, 99); rt.put_n(rt.ld8(0 - 1)); sp(); - rt.put_n(rt.ld16(rt.addr_b(rt.MW) - 1)); sp(); + lim = rt.syscall(9, 10, 0, 0); + if (lim < 0) lim = rt.syscall(9, 0, 0, 0); + rt.put_n(rt.ld16(rt.addr_b(lim) - 1)); sp(); rt.put_n(sumbytes(1000)); rt.put_c(10); let p = f; -- cgit v1.2.3