commit 6ce02250c5f5982da088c191b4da1ac0ce6a4958
parent d87400a1c88fefd1ead7b3d84d9a7a03f3f276c9
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Fri, 24 Apr 2026 20:39:45 -0700
Refactor M1pp.P1 boilerplate: BSS init loop, lex helper, char-class table
Four independent simplifications, 57 lines net:
- p1_main's BSS pointer-slot init is now a table walk over bss_init_tbl
instead of 16 unrolled 4-line blocks.
- The five single-char lex blocks (lex_lparen/rparen/comma/lbrace/rbrace)
share a new lex_punct1 helper; each block is now 4 lines.
- lex_loop and lex_word_scan dispatch via a 256-byte lex_char_class table
in rodata, collapsing two linear char-comparison ladders.
- err_* stubs drop their explicit message length; fatal computes it via
an inline strlen loop, and msg_* strings are NUL-terminated.
Adds ZERO4 and :lex_punct_kind. P1 backend tables regenerated by the
prune step pick up a handful of new register/offset combos.
Diffstat:
4 files changed, 207 insertions(+), 243 deletions(-)
diff --git a/M1pp/M1pp.P1 b/M1pp/M1pp.P1
@@ -44,6 +44,7 @@ DEFINE MODE_0644 A401000000000000
DEFINE AT_FDCWD 9CFFFFFFFFFFFFFF
DEFINE ZERO32 '0000000000000000000000000000000000000000000000000000000000000000'
DEFINE ZERO8 '0000000000000000'
+DEFINE ZERO4 '00000000'
DEFINE TOK_WORD 0000000000000000
DEFINE TOK_STRING 0100000000000000
@@ -139,70 +140,25 @@ DEFINE OFF_expr_frames 0049410000000000
:p1_main
enter_0
- # --- init BSS pointer slots from ELF_end ---------------------------------
+ # --- init BSS pointer slots from ELF_end via table walk ------------------
+ # Each bss_init_tbl entry is 16 bytes:
+ # +0 slot ptr (&label + 4 zero pad = 8-byte absolute address)
+ # +8 offset (8-byte OFF_* constant)
+ # For each entry: *slot_ptr = ELF_end + offset.
la_t0 &ELF_end
- la_t1 &paste_scratch_ptr
- st_t0,t1,0 # paste_scratch_ptr = ELF_end
- li_t1 OFF_local_label_scratch
- add_t1,t0,t1
- la_t2 &local_label_scratch_ptr
- st_t1,t2,0 # local_label_scratch_ptr = ELF_end + OFF_local_label_scratch
- li_t1 OFF_scope_stack
- add_t1,t0,t1
- la_t2 &scope_stack_ptr
- st_t1,t2,0 # scope_stack_ptr = ELF_end + OFF_scope_stack
- li_t1 OFF_df_name_scratch
- add_t1,t0,t1
- la_t2 &df_name_scratch_ptr
- st_t1,t2,0 # df_name_scratch_ptr = ELF_end + OFF_df_name_scratch
- li_t1 OFF_ebc_str_scratch
- add_t1,t0,t1
- la_t2 &ebc_str_scratch_ptr
- st_t1,t2,0 # ebc_str_scratch_ptr = ELF_end + OFF_ebc_str_scratch
- li_t1 OFF_arg_starts
- add_t1,t0,t1
- la_t2 &arg_starts_ptr
- st_t1,t2,0 # arg_starts_ptr = ELF_end + OFF_arg_starts
- li_t1 OFF_arg_ends
- add_t1,t0,t1
- la_t2 &arg_ends_ptr
- st_t1,t2,0 # arg_ends_ptr = ELF_end + OFF_arg_ends
- li_t1 OFF_input_buf
- add_t1,t0,t1
- la_t2 &input_buf_ptr
- st_t1,t2,0 # input_buf_ptr = ELF_end + OFF_input_buf
- li_t1 OFF_output_buf
- add_t1,t0,t1
- la_t2 &output_buf_ptr
- st_t1,t2,0 # output_buf_ptr = ELF_end + OFF_output_buf
- li_t1 OFF_text_buf
- add_t1,t0,t1
- la_t2 &text_buf_ptr
- st_t1,t2,0 # text_buf_ptr = ELF_end + OFF_text_buf
- li_t1 OFF_source_tokens
- add_t1,t0,t1
- la_t2 &source_tokens_ptr
- st_t1,t2,0 # source_tokens_ptr = ELF_end + OFF_source_tokens
- li_t1 OFF_macros
- add_t1,t0,t1
- la_t2 ¯os_ptr
- st_t1,t2,0 # macros_ptr = ELF_end + OFF_macros
- li_t1 OFF_macro_body_tokens
- add_t1,t0,t1
- la_t2 ¯o_body_tokens_ptr
- st_t1,t2,0 # macro_body_tokens_ptr = ELF_end + OFF_macro_body_tokens
- li_t1 OFF_streams
- add_t1,t0,t1
- la_t2 &streams_ptr
- st_t1,t2,0 # streams_ptr = ELF_end + OFF_streams
- li_t1 OFF_expand_pool
- add_t1,t0,t1
- la_t2 &expand_pool_ptr
- st_t1,t2,0 # expand_pool_ptr = ELF_end + OFF_expand_pool
- li_t1 OFF_expr_frames
- add_t1,t0,t1
- la_t2 &expr_frames_ptr
- st_t1,t2,0 # expr_frames_ptr = ELF_end + OFF_expr_frames
+ la_t1 &bss_init_tbl
+ la_t2 &bss_init_tbl_end
+:bss_init_loop
+ la_br &bss_init_done
+ beq_t1,t2
+ ld_a2,t1,0
+ ld_a3,t1,8
+ add_a3,a3,t0
+ st_a3,a2,0
+ addi_t1,t1,16
+ la_br &bss_init_loop
+ b
+:bss_init_done
# --- end BSS init -------------------------------------------------------
# a0 = argc, a1 = argv (pointer to argv[0]).
@@ -489,64 +445,50 @@ DEFINE OFF_expr_frames 0049410000000000
la_a1 &lex_ptr
st_a0,a1,0
:lex_loop
- # c = *lex_ptr; if (c == '\0') done
+ # c = *lex_ptr; dispatch on lex_char_class[c].
+ # 0 word, 1 skip ws, 2 newline, 3 string, 4 hash, 5 comment,
+ # 6 '(', 7 ')', 8 ',', 9 '{', 10 '}', 11 NUL (fall through to done).
la_a0 &lex_ptr
ld_t0,a0,0
lb_a0,t0,0
- la_br &lex_done
- beqz_a0
+ la_a1 &lex_char_class
+ add_a1,a1,a0
+ lb_a2,a1,0
- # non-newline whitespace: ' ' '\t' '\r' '\f' '\v' -> skip one
- li_a1 %32 %0
- la_br &lex_skip_one
- beq_a0,a1
- li_a1 %9 %0
- la_br &lex_skip_one
- beq_a0,a1
- li_a1 %13 %0
- la_br &lex_skip_one
- beq_a0,a1
- li_a1 %12 %0
- la_br &lex_skip_one
- beq_a0,a1
- li_a1 %11 %0
+ la_br &lex_word
+ beqz_a2
+ li_a1 %1 %0
la_br &lex_skip_one
- beq_a0,a1
-
- # single-char dispatch: '\n' '"' '\'' '#' ';' '(' ')' ','
- li_a1 %10 %0
+ beq_a2,a1
+ li_a1 %2 %0
la_br &lex_newline
- beq_a0,a1
- li_a1 %34 %0
- la_br &lex_string
- beq_a0,a1
- li_a1 %39 %0
+ beq_a2,a1
+ li_a1 %3 %0
la_br &lex_string
- beq_a0,a1
- li_a1 %35 %0
+ beq_a2,a1
+ li_a1 %4 %0
la_br &lex_hash
- beq_a0,a1
- li_a1 %59 %0
+ beq_a2,a1
+ li_a1 %5 %0
la_br &lex_comment
- beq_a0,a1
- li_a1 %40 %0
+ beq_a2,a1
+ li_a1 %6 %0
la_br &lex_lparen
- beq_a0,a1
- li_a1 %41 %0
+ beq_a2,a1
+ li_a1 %7 %0
la_br &lex_rparen
- beq_a0,a1
- li_a1 %44 %0
+ beq_a2,a1
+ li_a1 %8 %0
la_br &lex_comma
- beq_a0,a1
- li_a1 %123 %0
+ beq_a2,a1
+ li_a1 %9 %0
la_br &lex_lbrace
- beq_a0,a1
- li_a1 %125 %0
+ beq_a2,a1
+ li_a1 %10 %0
la_br &lex_rbrace
- beq_a0,a1
-
- # otherwise: word
- la_br &lex_word
+ beq_a2,a1
+ ## class 11 (NUL) — fall through
+ la_br &lex_done
b
:lex_skip_one
@@ -679,63 +621,50 @@ DEFINE OFF_expr_frames 0049410000000000
## then fall through to lex_advance_one_then_loop to bump lex_ptr.
:lex_lparen
- la_a0 &const_lparen
- li_a1 %1 %0
- la_br &append_text
- call
- mov_a1,a0
li_a0 TOK_LPAREN
- li_a2 %1 %0
- la_br &push_source_token
- call
- la_br &lex_advance_one_then_loop
+ la_a1 &const_lparen
+ la_br &lex_punct1
b
:lex_rparen
- la_a0 &const_rparen
- li_a1 %1 %0
- la_br &append_text
- call
- mov_a1,a0
li_a0 TOK_RPAREN
- li_a2 %1 %0
- la_br &push_source_token
- call
- la_br &lex_advance_one_then_loop
+ la_a1 &const_rparen
+ la_br &lex_punct1
b
:lex_comma
- la_a0 &const_comma
- li_a1 %1 %0
- la_br &append_text
- call
- mov_a1,a0
li_a0 TOK_COMMA
- li_a2 %1 %0
- la_br &push_source_token
- call
- la_br &lex_advance_one_then_loop
+ la_a1 &const_comma
+ la_br &lex_punct1
b
:lex_lbrace
- la_a0 &const_lbrace
- li_a1 %1 %0
- la_br &append_text
- call
- mov_a1,a0
li_a0 TOK_LBRACE
- li_a2 %1 %0
- la_br &push_source_token
- call
- la_br &lex_advance_one_then_loop
+ la_a1 &const_lbrace
+ la_br &lex_punct1
b
:lex_rbrace
- la_a0 &const_rbrace
+ li_a0 TOK_RBRACE
+ la_a1 &const_rbrace
+ ## fall through into lex_punct1
+
+## lex_punct1(a0=kind, a1=const_ptr): append 1 byte to text arena, push a
+## 1-byte token of the given kind, advance lex_ptr by 1, branch back to
+## lex_loop. Called by tail-branch from the single-char lex_X blocks, which
+## all share lex_source's frame. Spills `kind` since append_text clobbers
+## a0..a3.
+:lex_punct1
+ la_t0 &lex_punct_kind
+ st_a0,t0,0
+ mov_a0,a1
li_a1 %1 %0
la_br &append_text
call
mov_a1,a0
- li_a0 TOK_RBRACE
+ la_t0 &lex_punct_kind
+ ld_a0,t0,0
li_a2 %1 %0
la_br &push_source_token
call
+ ## fall through to lex_advance_one_then_loop
+
:lex_advance_one_then_loop
# lex_ptr++
la_a0 &lex_ptr
@@ -750,50 +679,13 @@ DEFINE OFF_expr_frames 0049410000000000
la_a1 &lex_start
st_t0,a1,0
:lex_word_scan
- # c = *lex_ptr; stop at: '\0' ws/\n '#' ';' '(' ')' ','
- lb_a0,t0,0
- la_br &lex_word_finish
- beqz_a0
- li_a1 %32 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %9 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %13 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %12 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %11 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %10 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %35 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %59 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %40 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %41 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %44 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %123 %0
- la_br &lex_word_finish
- beq_a0,a1
- li_a1 %125 %0
+ # c = *lex_ptr; terminate the word if lex_char_class[c] != WORD (0).
+ lb_a2,t0,0
+ la_a1 &lex_char_class
+ add_a1,a1,a2
+ lb_a2,a1,0
la_br &lex_word_finish
- beq_a0,a1
- # else lex_ptr++
+ bnez_a2
addi_t0,t0,1
la_br &lex_word_scan
b
@@ -5771,125 +5663,114 @@ DEFINE OFF_expr_frames 0049410000000000
:err_usage
la_a0 &msg_usage
- li_a1 %29 %0
la_br &fatal
b
:err_open_input
la_a0 &msg_open_input
- li_a1 %25 %0
la_br &fatal
b
:err_read
la_a0 &msg_read
- li_a1 %20 %0
la_br &fatal
b
:err_input_too_big
la_a0 &msg_input_too_big
- li_a1 %20 %0
la_br &fatal
b
:err_open_output
la_a0 &msg_open_output
- li_a1 %26 %0
la_br &fatal
b
:err_write
la_a0 &msg_write
- li_a1 %22 %0
la_br &fatal
b
:err_text_overflow
la_a0 &msg_text_overflow
- li_a1 %20 %0
la_br &fatal
b
:err_token_overflow
la_a0 &msg_token_overflow
- li_a1 %21 %0
la_br &fatal
b
:err_output_overflow
la_a0 &msg_output_overflow
- li_a1 %22 %0
la_br &fatal
b
:err_unterminated_macro
la_a0 &msg_unterminated_macro
- li_a1 %30 %0
la_br &fatal
b
:err_bad_macro_header
la_a0 &msg_bad_macro_header
- li_a1 %16 %0
la_br &fatal
b
:err_too_many_macros
la_a0 &msg_too_many_macros
- li_a1 %15 %0
la_br &fatal
b
:err_macro_body_overflow
la_a0 &msg_macro_body_overflow
- li_a1 %19 %0
la_br &fatal
b
:err_not_implemented
la_a0 &msg_not_implemented
- li_a1 %15 %0
la_br &fatal
b
:err_unbalanced_braces
la_a0 &msg_unbalanced_braces
- li_a1 %17 %0
la_br &fatal
b
:err_bad_directive
la_a0 &msg_bad_directive
- li_a1 %27 %0
la_br &fatal
b
:err_unterminated_directive
la_a0 &msg_unterminated_directive
- li_a1 %36 %0
la_br &fatal
b
:err_bad_scope_header
la_a0 &msg_bad_scope_header
- li_a1 %16 %0
la_br &fatal
b
:err_scope_depth_overflow
la_a0 &msg_scope_depth_overflow
- li_a1 %20 %0
la_br &fatal
b
:err_scope_underflow
la_a0 &msg_scope_underflow
- li_a1 %15 %0
la_br &fatal
b
:err_scope_not_closed
la_a0 &msg_scope_not_closed
- li_a1 %16 %0
la_br &fatal
b
:err_bad_scope_label
la_a0 &msg_bad_scope_label
- li_a1 %15 %0
la_br &fatal
b
-## fatal(a0=msg_ptr, a1=msg_len): writes "m1pp: <msg>\n" to stderr, exits 1.
-## Saves args across the three syscalls since a0..a3 are caller-saved.
+## fatal(a0=msg_ptr): writes "m1pp: <msg>\n" to stderr and exits 1.
+## Length is computed inline via a strlen loop (messages are NUL-terminated).
+## Reached by unconditional branch from any err_* stub, so no frame is required.
:fatal
- # stash msg/len so the first syscall doesn't clobber them
- la_a2 &err_saved_msg
- st_a0,a2,0
- la_a2 &err_saved_len
- st_a1,a2,0
+ # Stash msg_ptr; compute len inline into err_saved_len.
+ la_a1 &err_saved_msg
+ st_a0,a1,0
+ li_t0 %0 %0
+:fatal_strlen
+ add_t1,a0,t0
+ lb_t1,t1,0
+ la_br &fatal_strlen_done
+ beqz_t1
+ addi_t0,t0,1
+ la_br &fatal_strlen
+ b
+:fatal_strlen_done
+ la_a1 &err_saved_len
+ st_t0,a1,0
- # write(2, "m1pp: ", 5)
+ # write(2, "m1pp:", 5)
li_a0 sys_write
li_a1 %2 %0
la_a2 &msg_prefix
@@ -5965,31 +5846,91 @@ DEFINE OFF_expr_frames 0049410000000000
## Nibble-to-hex lookup table for emit_hex_value.
:hex_chars "0123456789ABCDEF"
+## 256-byte char-class table for lex_loop / lex_word_scan. Indexed by the
+## source byte `c`; value is the class code dispatched by lex_loop:
+## 0 WORD (default; word_scan continues through this byte)
+## 1 SKIP (non-newline whitespace: 0x09 tab, 0x0B-0x0D vt/ff/cr, 0x20 sp)
+## 2 NEWLINE (0x0A)
+## 3 STRING (0x22 ", 0x27 ')
+## 4 HASH (0x23 #)
+## 5 COMMENT (0x3B ;)
+## 6 LPAREN (0x28 ()
+## 7 RPAREN (0x29 ))
+## 8 COMMA (0x2C ,)
+## 9 LBRACE (0x7B {)
+## 10 RBRACE (0x7D })
+## 11 NUL (0x00 — lex_loop fall-through to lex_done)
+:lex_char_class
+## bytes 0x00-0x1F: NUL=11, \t=1, \n=2, \v/\f/\r=1, rest=0
+'0B000000000000000001020101010000'
+'00000000000000000000000000000000'
+## bytes 0x20-0x3F: sp=1, "=3, #=4, '=3, (=6, )=7, ,=8, ;=5
+'01000304000000030607000008000000'
+'00000000000000000000000500000000'
+## bytes 0x40-0x7F: {=9 (0x7B), }=10 (0x7D)
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'000000000000000000000009000A0000'
+## bytes 0x80-0xFF: all 0 (word)
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+'00000000000000000000000000000000'
+
+## BSS pointer-slot init table (for p1_main's bss_init_loop).
+## Each entry: 8-byte slot ptr (&label + 4 pad) + 8-byte OFF_* constant.
+## Walked linearly; order is irrelevant.
+:bss_init_tbl
+&paste_scratch_ptr ZERO4 OFF_paste_scratch
+&local_label_scratch_ptr ZERO4 OFF_local_label_scratch
+&scope_stack_ptr ZERO4 OFF_scope_stack
+&df_name_scratch_ptr ZERO4 OFF_df_name_scratch
+&ebc_str_scratch_ptr ZERO4 OFF_ebc_str_scratch
+&arg_starts_ptr ZERO4 OFF_arg_starts
+&arg_ends_ptr ZERO4 OFF_arg_ends
+&input_buf_ptr ZERO4 OFF_input_buf
+&output_buf_ptr ZERO4 OFF_output_buf
+&text_buf_ptr ZERO4 OFF_text_buf
+&source_tokens_ptr ZERO4 OFF_source_tokens
+¯os_ptr ZERO4 OFF_macros
+¯o_body_tokens_ptr ZERO4 OFF_macro_body_tokens
+&streams_ptr ZERO4 OFF_streams
+&expand_pool_ptr ZERO4 OFF_expand_pool
+&expr_frames_ptr ZERO4 OFF_expr_frames
+:bss_init_tbl_end
+
:msg_prefix "m1pp: "
:msg_newline "
"
-:msg_usage "usage: m1pp input.M1 output.M1"
-:msg_open_input "failed to open input file"
-:msg_read "failed to read input"
-:msg_input_too_big "input file too large"
-:msg_open_output "failed to open output file"
-:msg_write "failed to write output"
-:msg_text_overflow "text buffer overflow"
-:msg_token_overflow "token buffer overflow"
-:msg_output_overflow "output buffer overflow"
-:msg_unterminated_macro "unterminated %macro definition"
-:msg_bad_macro_header "bad macro header"
-:msg_too_many_macros "too many macros"
-:msg_macro_body_overflow "macro body overflow"
-:msg_not_implemented "not implemented"
-:msg_unbalanced_braces "unbalanced braces"
-:msg_bad_directive "bad %struct/%enum directive"
-:msg_unterminated_directive "unterminated %struct/%enum directive"
-:msg_bad_scope_header "bad scope header"
-:msg_scope_depth_overflow "scope depth overflow"
-:msg_scope_underflow "scope underflow"
-:msg_scope_not_closed "scope not closed"
-:msg_bad_scope_label "bad scope label"
+## All err_* messages below are NUL-terminated (trailing '00'); fatal uses an
+## inline strlen loop rather than a caller-supplied length.
+:msg_usage "usage: m1pp input.M1 output.M1" '00'
+:msg_open_input "failed to open input file" '00'
+:msg_read "failed to read input" '00'
+:msg_input_too_big "input file too large" '00'
+:msg_open_output "failed to open output file" '00'
+:msg_write "failed to write output" '00'
+:msg_text_overflow "text buffer overflow" '00'
+:msg_token_overflow "token buffer overflow" '00'
+:msg_output_overflow "output buffer overflow" '00'
+:msg_unterminated_macro "unterminated %macro definition" '00'
+:msg_bad_macro_header "bad macro header" '00'
+:msg_too_many_macros "too many macros" '00'
+:msg_macro_body_overflow "macro body overflow" '00'
+:msg_not_implemented "not implemented" '00'
+:msg_unbalanced_braces "unbalanced braces" '00'
+:msg_bad_directive "bad %struct/%enum directive" '00'
+:msg_unterminated_directive "unterminated %struct/%enum directive" '00'
+:msg_bad_scope_header "bad scope header" '00'
+:msg_scope_depth_overflow "scope depth overflow" '00'
+:msg_scope_underflow "scope underflow" '00'
+:msg_scope_not_closed "scope not closed" '00'
+:msg_bad_scope_label "bad scope label" '00'
## --- BSS ---------------------------------------------------------------------
## Placed before :ELF_end so filesz/memsz (which this ELF header sets equal)
@@ -6027,6 +5968,8 @@ ZERO8
ZERO8
:lex_quote
ZERO8
+:lex_punct_kind
+ZERO8
:proc_pos
ZERO8
:proc_line_start
diff --git a/P1/P1-aarch64.M1 b/P1/P1-aarch64.M1
@@ -22,6 +22,7 @@ DEFINE la_t2 4B00001802000014
DEFINE la_br 5100001802000014
## ---- Moves
+DEFINE mov_a0,a1 E00301AA
DEFINE mov_a0,a3 E00303AA
DEFINE mov_a0,t0 E00309AA
DEFINE mov_a0,t1 E0030AAA
@@ -93,6 +94,7 @@ DEFINE add_t0,t0,a0 2901008B
DEFINE add_t0,t0,a1 2901018B
DEFINE add_t0,t0,a3 2901038B
DEFINE add_t0,t0,t1 29010A8B
+DEFINE add_t1,a0,t0 0A00098B
DEFINE add_t1,t0,t1 2A010A8B
DEFINE add_t1,t1,a0 4A01008B
DEFINE add_t1,t1,a1 4A01018B
@@ -221,6 +223,7 @@ DEFINE ld_a0,a2,0 400040F9
DEFINE ld_a0,a3,0 600040F9
DEFINE ld_a0,a3,8 600440F9
DEFINE ld_a0,a3,16 600840F9
+DEFINE ld_a0,t0,0 200140F9
DEFINE ld_a0,sp,0 E00B40F9
DEFINE ld_a0,sp,8 E00F40F9
DEFINE ld_a0,sp,24 E01740F9
@@ -246,6 +249,7 @@ DEFINE ld_a2,t0,0 220140F9
DEFINE ld_a2,t0,8 220540F9
DEFINE ld_a2,t0,16 220940F9
DEFINE ld_a2,t1,neg24 42815EF8
+DEFINE ld_a2,t1,0 420140F9
DEFINE ld_a2,t2,0 620140F9
DEFINE ld_a2,sp,16 E21340F9
DEFINE ld_a3,a0,0 030040F9
@@ -258,6 +262,7 @@ DEFINE ld_a3,a3,0 630040F9
DEFINE ld_a3,t0,0 230140F9
DEFINE ld_a3,t0,8 230540F9
DEFINE ld_a3,t0,16 230940F9
+DEFINE ld_a3,t1,8 430540F9
DEFINE ld_t0,a0,0 090040F9
DEFINE ld_t0,a0,8 090440F9
DEFINE ld_t0,a0,16 090840F9
@@ -369,7 +374,6 @@ DEFINE st_t1,a3,8 6A0400F9
DEFINE st_t1,a3,16 6A0800F9
DEFINE st_t1,a3,24 6A0C00F9
DEFINE st_t1,t0,0 2A0100F9
-DEFINE st_t1,t2,0 6A0100F9
DEFINE st_t2,a0,0 0B0000F9
DEFINE st_t2,a1,0 2B0000F9
DEFINE st_t2,a2,0 4B0000F9
@@ -385,6 +389,7 @@ DEFINE lb_a1,t0,0 21014039
DEFINE lb_a1,t0,1 21054039
DEFINE lb_a2,a1,0 22004039
DEFINE lb_a2,a2,0 42004039
+DEFINE lb_a2,t0,0 22014039
DEFINE lb_a3,a1,0 23004039
DEFINE lb_a3,a2,0 43004039
DEFINE lb_a3,a3,0 63004039
@@ -392,6 +397,7 @@ DEFINE lb_t0,a3,0 69004039
DEFINE lb_t0,a3,1 69044039
DEFINE lb_t0,a3,2 69084039
DEFINE lb_t0,t0,0 29014039
+DEFINE lb_t1,t1,0 4A014039
DEFINE lb_t2,t0,0 2B014039
DEFINE lb_t2,t2,0 6B014039
DEFINE sb_a0,a1,0 20000039
@@ -420,6 +426,7 @@ DEFINE beq_a0,a1 1F0001EB4100005420021FD6
DEFINE beq_a0,t0 1F0009EB4100005420021FD6
DEFINE beq_a0,t1 1F000AEB4100005420021FD6
DEFINE beq_a1,a2 3F0002EB4100005420021FD6
+DEFINE beq_a2,a1 5F0001EB4100005420021FD6
DEFINE beq_a2,a3 5F0003EB4100005420021FD6
DEFINE beq_a3,a2 7F0002EB4100005420021FD6
DEFINE beq_a3,t0 7F0009EB4100005420021FD6
diff --git a/P1/P1-amd64.M1 b/P1/P1-amd64.M1
@@ -22,6 +22,7 @@ DEFINE la_t2 41B8
DEFINE la_br 41BF
## ---- Moves
+DEFINE mov_a0,a1 4889F7
DEFINE mov_a0,a3 4889CF
DEFINE mov_a0,t0 4C89D7
DEFINE mov_a0,t1 4C89DF
@@ -93,6 +94,7 @@ DEFINE add_t0,t0,a0 4D89D24901FA
DEFINE add_t0,t0,a1 4D89D24901F2
DEFINE add_t0,t0,a3 4D89D24901CA
DEFINE add_t0,t0,t1 4D89D24D01DA
+DEFINE add_t1,a0,t0 4989FB4D01D3
DEFINE add_t1,t0,t1 4D89D94D89D34D01CB
DEFINE add_t1,t1,a0 4D89DB4901FB
DEFINE add_t1,t1,a1 4D89DB4901F3
@@ -221,6 +223,7 @@ DEFINE ld_a0,a2,0 488B7A00
DEFINE ld_a0,a3,0 488B7900
DEFINE ld_a0,a3,8 488B7908
DEFINE ld_a0,a3,16 488B7910
+DEFINE ld_a0,t0,0 498B7A00
DEFINE ld_a0,sp,0 488B7C2410
DEFINE ld_a0,sp,8 488B7C2418
DEFINE ld_a0,sp,24 488B7C2428
@@ -246,6 +249,7 @@ DEFINE ld_a2,t0,0 498B5200
DEFINE ld_a2,t0,8 498B5208
DEFINE ld_a2,t0,16 498B5210
DEFINE ld_a2,t1,neg24 498B53E8
+DEFINE ld_a2,t1,0 498B5300
DEFINE ld_a2,t2,0 498B5000
DEFINE ld_a2,sp,16 488B542420
DEFINE ld_a3,a0,0 488B4F00
@@ -258,6 +262,7 @@ DEFINE ld_a3,a3,0 488B4900
DEFINE ld_a3,t0,0 498B4A00
DEFINE ld_a3,t0,8 498B4A08
DEFINE ld_a3,t0,16 498B4A10
+DEFINE ld_a3,t1,8 498B4B08
DEFINE ld_t0,a0,0 4C8B5700
DEFINE ld_t0,a0,8 4C8B5708
DEFINE ld_t0,a0,16 4C8B5710
@@ -369,7 +374,6 @@ DEFINE st_t1,a3,8 4C895908
DEFINE st_t1,a3,16 4C895910
DEFINE st_t1,a3,24 4C895918
DEFINE st_t1,t0,0 4D895A00
-DEFINE st_t1,t2,0 4D895800
DEFINE st_t2,a0,0 4C894700
DEFINE st_t2,a1,0 4C894600
DEFINE st_t2,a2,0 4C894200
@@ -385,6 +389,7 @@ DEFINE lb_a1,t0,0 490FB67200
DEFINE lb_a1,t0,1 490FB67201
DEFINE lb_a2,a1,0 480FB65600
DEFINE lb_a2,a2,0 480FB65200
+DEFINE lb_a2,t0,0 490FB65200
DEFINE lb_a3,a1,0 480FB64E00
DEFINE lb_a3,a2,0 480FB64A00
DEFINE lb_a3,a3,0 480FB64900
@@ -392,6 +397,7 @@ DEFINE lb_t0,a3,0 4C0FB65100
DEFINE lb_t0,a3,1 4C0FB65101
DEFINE lb_t0,a3,2 4C0FB65102
DEFINE lb_t0,t0,0 4D0FB65200
+DEFINE lb_t1,t1,0 4D0FB65B00
DEFINE lb_t2,t0,0 4D0FB64200
DEFINE lb_t2,t2,0 4D0FB64000
DEFINE sb_a0,a1,0 48887E00
@@ -420,6 +426,7 @@ DEFINE beq_a0,a1 4839F7750341FFE7
DEFINE beq_a0,t0 4C39D7750341FFE7
DEFINE beq_a0,t1 4C39DF750341FFE7
DEFINE beq_a1,a2 4839D6750341FFE7
+DEFINE beq_a2,a1 4839F2750341FFE7
DEFINE beq_a2,a3 4839CA750341FFE7
DEFINE beq_a3,a2 4839D1750341FFE7
DEFINE beq_a3,t0 4C39D1750341FFE7
diff --git a/P1/P1-riscv64.M1 b/P1/P1-riscv64.M1
@@ -22,6 +22,7 @@ DEFINE la_t2 9703000083E3C3006F008000
DEFINE la_br 970F000083EFCF006F008000
## ---- Moves
+DEFINE mov_a0,a1 13850500
DEFINE mov_a0,a3 13850600
DEFINE mov_a0,t0 13850200
DEFINE mov_a0,t1 13050300
@@ -93,6 +94,7 @@ DEFINE add_t0,t0,a0 B382A200
DEFINE add_t0,t0,a1 B382B200
DEFINE add_t0,t0,a3 B382D200
DEFINE add_t0,t0,t1 B3826200
+DEFINE add_t1,a0,t0 33035500
DEFINE add_t1,t0,t1 33836200
DEFINE add_t1,t1,a0 3303A300
DEFINE add_t1,t1,a1 3303B300
@@ -221,6 +223,7 @@ DEFINE ld_a0,a2,0 03350600
DEFINE ld_a0,a3,0 03B50600
DEFINE ld_a0,a3,8 03B58600
DEFINE ld_a0,a3,16 03B50601
+DEFINE ld_a0,t0,0 03B50200
DEFINE ld_a0,sp,0 03350101
DEFINE ld_a0,sp,8 03358101
DEFINE ld_a0,sp,24 03358102
@@ -246,6 +249,7 @@ DEFINE ld_a2,t0,0 03B60200
DEFINE ld_a2,t0,8 03B68200
DEFINE ld_a2,t0,16 03B60201
DEFINE ld_a2,t1,neg24 033683FE
+DEFINE ld_a2,t1,0 03360300
DEFINE ld_a2,t2,0 03B60300
DEFINE ld_a2,sp,16 03360102
DEFINE ld_a3,a0,0 83360500
@@ -258,6 +262,7 @@ DEFINE ld_a3,a3,0 83B60600
DEFINE ld_a3,t0,0 83B60200
DEFINE ld_a3,t0,8 83B68200
DEFINE ld_a3,t0,16 83B60201
+DEFINE ld_a3,t1,8 83368300
DEFINE ld_t0,a0,0 83320500
DEFINE ld_t0,a0,8 83328500
DEFINE ld_t0,a0,16 83320501
@@ -369,7 +374,6 @@ DEFINE st_t1,a3,8 23B46600
DEFINE st_t1,a3,16 23B86600
DEFINE st_t1,a3,24 23BC6600
DEFINE st_t1,t0,0 23B06200
-DEFINE st_t1,t2,0 23B06300
DEFINE st_t2,a0,0 23307500
DEFINE st_t2,a1,0 23B07500
DEFINE st_t2,a2,0 23307600
@@ -385,6 +389,7 @@ DEFINE lb_a1,t0,0 83C50200
DEFINE lb_a1,t0,1 83C51200
DEFINE lb_a2,a1,0 03C60500
DEFINE lb_a2,a2,0 03460600
+DEFINE lb_a2,t0,0 03C60200
DEFINE lb_a3,a1,0 83C60500
DEFINE lb_a3,a2,0 83460600
DEFINE lb_a3,a3,0 83C60600
@@ -392,6 +397,7 @@ DEFINE lb_t0,a3,0 83C20600
DEFINE lb_t0,a3,1 83C21600
DEFINE lb_t0,a3,2 83C22600
DEFINE lb_t0,t0,0 83C20200
+DEFINE lb_t1,t1,0 03430300
DEFINE lb_t2,t0,0 83C30200
DEFINE lb_t2,t2,0 83C30300
DEFINE sb_a0,a1,0 2380A500
@@ -420,6 +426,7 @@ DEFINE beq_a0,a1 6314B50067800F00
DEFINE beq_a0,t0 6314550067800F00
DEFINE beq_a0,t1 6314650067800F00
DEFINE beq_a1,a2 6394C50067800F00
+DEFINE beq_a2,a1 6314B60067800F00
DEFINE beq_a2,a3 6314D60067800F00
DEFINE beq_a3,a2 6394C60067800F00
DEFINE beq_a3,t0 6394560067800F00