boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit 21cbd8312842f60c4ab99f36cedd0002d85fdac7
parent 25cd91ac28bfcead03871cd6a55f14c78ba3ff58
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Tue, 28 Apr 2026 09:32:40 -0700

scheme1: 8-aligned strings

Diffstat:
Mscheme1/scheme1.P1pp | 76+++++++++++++++++++++++++++++++---------------------------------------------
1 file changed, 31 insertions(+), 45 deletions(-)

diff --git a/scheme1/scheme1.P1pp b/scheme1/scheme1.P1pp @@ -6433,26 +6433,12 @@ :name_sys_argv "sys-argv" '00000000000000' :name_eof_object "eof-object" '0000000000' :name_eof_objectq "eof-object?" '00000000' - :name_values "values" '00' :name_call_with_values "call-with-values" '00000000000000' - :name_display "display" :name_write "write" '0000' :name_error "error" '0000' :name_format "format" '00' -;; The last three names are padded individually to 16 bytes (multiple -;; of 8) so subsequent 8-aligned data slots (prim_table $() rows, the -;; bss pointer slots) stay aligned. M0 appends a NUL to every "..." -;; string, so the listed length below counts the trailing NUL plus the -;; explicit 00 bytes. -;; "heap-mark" + NUL = 10 bytes; pad with 6 NUL to reach 16. -;; "heap-rewind!"+ NUL = 13 bytes; pad with 3 NUL to reach 16. -;; "heap-usage" + NUL = 11 bytes; pad with 5 NUL to reach 16. -;; "use-scratch-heap!" + NUL = 18 bytes; pad with 6 NUL to reach 24. -;; "use-main-heap!" + NUL = 15 bytes; pad with 1 NUL to reach 16. -;; "reset-scratch-heap!"+ NUL = 20 bytes; pad with 4 NUL to reach 24. -;; "heap-in-main?" + NUL = 14 bytes; pad with 2 NUL to reach 16. :name_heap_mark "heap-mark" '000000000000' :name_heap_rewind_bang "heap-rewind!" '000000' :name_heap_usage "heap-usage" '0000000000' @@ -6551,37 +6537,37 @@ &name_call_with_values %(0) $(16) &prim_call_with_values_entry %(0) :prim_table_end -:msg_usage "scheme1: usage: scheme1 SOURCE.scm" '0a' '00' -:msg_load_fail "scheme1: failed to read source" '0a' '00' -:msg_symtab_full "scheme1: symbol table full" '0a' '00' -:msg_unexp_rparen "scheme1: unexpected ')'" '0a' '00' -:msg_bad_hash "scheme1: bad #-syntax" '0a' '00' -:msg_unexp_eof "scheme1: unexpected EOF in form" '0a' '00' -:msg_unterm_list "scheme1: unterminated list" '0a' '00' -:msg_unbound "scheme1: unbound variable" '0a' '00' -:msg_not_proc "scheme1: not a procedure" '0a' '00' -:msg_heap_full "scheme1: heap exhausted" '0a' '00' -;; "scheme1: scratch exhausted" + auto-NUL = 27 bytes; '0a' '00' = 2; -;; pad to 32 (multiple of 4) so the code that follows stays 4-aligned -;; — aarch64 instruction fetch SIGBUSes on a misaligned PC. -:msg_scratch_full "scheme1: scratch exhausted" '0a' '00000000' -:msg_readbuf_full "scheme1: source buffer overflow" '0a' '00' -:msg_bv_oob "scheme1: bytevector index out of range" '0a' '00' -:msg_unterm_string "scheme1: unterminated string literal" '0a' '00' -:msg_bad_escape "scheme1: bad string escape" '0a' '00' -:msg_bad_char "scheme1: bad #\\ character literal" '0a' '00' -:msg_bad_number "scheme1: bad number literal" '0a' '00' -:msg_bad_ident "scheme1: bad identifier" '0a' '00' -:msg_internal_define "scheme1: internal define is not supported (use letrec)" '0a' '00' -:msg_pmatch_no_match "scheme1: pmatch: no clause matched" '0a' '00' -:msg_bad_unquote_pattern "scheme1: pmatch: malformed ,-pattern" '0a' '00' -:msg_case_lambda_no_match "scheme1: case-lambda: no clause matched arity" '0a' '00' - -:name_ch_tab "tab" -:name_ch_null "null" -:name_ch_space "space" -:name_ch_return "return" -:name_ch_newline "newline" +;; Each :msg_ entry must be an exact multiple of 8 bytes so that entries +;; stay 8-aligned (text + M0-auto-NUL + '0a' + zero padding). +;; len+2+pad == 0 mod 8 (len = text chars, 2 = NUL+'0a', pad = trailing zeros). +:msg_usage "scheme1: usage: scheme1 SOURCE.scm" '0a' '00000000' ;; 34+1+1+4=40 +:msg_load_fail "scheme1: failed to read source" '0a' ;; 30+1+1+0=32 +:msg_symtab_full "scheme1: symbol table full" '0a' '00000000' ;; 26+1+1+4=32 +:msg_unexp_rparen "scheme1: unexpected ')'" '0a' '00000000000000' ;; 23+1+1+7=32 +:msg_bad_hash "scheme1: bad #-syntax" '0a' '00' ;; 21+1+1+1=24 +:msg_unexp_eof "scheme1: unexpected EOF in form" '0a' '00000000000000' ;; 31+1+1+7=40 +:msg_unterm_list "scheme1: unterminated list" '0a' '00000000' ;; 26+1+1+4=32 +:msg_unbound "scheme1: unbound variable" '0a' '0000000000' ;; 25+1+1+5=32 +:msg_not_proc "scheme1: not a procedure" '0a' '000000000000' ;; 24+1+1+6=32 +:msg_heap_full "scheme1: heap exhausted" '0a' '00000000000000' ;; 23+1+1+7=32 +:msg_scratch_full "scheme1: scratch exhausted" '0a' '00000000' ;; 26+1+1+4=32 +:msg_readbuf_full "scheme1: source buffer overflow" '0a' '00000000000000' ;; 31+1+1+7=40 +:msg_bv_oob "scheme1: bytevector index out of range" '0a' ;; 38+1+1+0=40 +:msg_unterm_string "scheme1: unterminated string literal" '0a' '0000' ;; 36+1+1+2=40 +:msg_bad_escape "scheme1: bad string escape" '0a' '00000000' ;; 26+1+1+4=32 +:msg_bad_char "scheme1: bad #\\ character literal" '0a' '00000000' ;; 34+1+1+4=40 +:msg_bad_number "scheme1: bad number literal" '0a' '000000' ;; 27+1+1+3=32 +:msg_bad_ident "scheme1: bad identifier" '0a' '00000000000000' ;; 23+1+1+7=32 +:msg_internal_define "scheme1: internal define is not supported (use letrec)" '0a' ;; 54+1+1+0=56 +:msg_pmatch_no_match "scheme1: pmatch: no clause matched" '0a' '00000000' ;; 34+1+1+4=40 +:msg_bad_unquote_pattern "scheme1: pmatch: malformed ,-pattern" '0a' '0000' ;; 36+1+1+2=40 +:msg_case_lambda_no_match "scheme1: case-lambda: no clause matched arity" '0a' '00' ;; 45+1+1+1=48 + +:name_ch_tab "tab" '00000000' ;; 3+1+4=8 +:name_ch_null "null" '000000' ;; 4+1+3=8 +:name_ch_space "space" '0000' ;; 5+1+2=8 +:name_ch_return "return" '00' ;; 6+1+1=8 +:name_ch_newline "newline" ;; 7+1+0=8 # ========================================================================= # Startup -- heap_init