commit 4eba962ec4bb1f6874f10d0ebd5f62371b1a1b7a
parent bf0cbf2005df3b5c84d48c4efa206567563dfa3a
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Fri, 24 Apr 2026 08:09:32 -0700
Add argc_exit and double P1 test fixtures
argc_exit: bare %ret() returns argc as the process exit status via
the backend entry stub.
double: calls a :double helper through LA_BR + CALL with an ENTER/LEAVE
frame in p1_main, exercising the non-leaf path the spec now requires.
Diffstat:
4 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/tests/p1/argc_exit.P1 b/tests/p1/argc_exit.P1
@@ -0,0 +1,10 @@
+# tests/p1/argc_exit.P1 — return argc as the process exit status.
+#
+# The backend-owned `:_start` stub calls `p1_main` with `a0` = argc,
+# `a1` = argv. Since `a0` is also the one-word return register, a bare
+# `%ret()` returns argc unchanged, and the stub hands that to sys_exit.
+
+:p1_main
+ %ret()
+
+:ELF_end
diff --git a/tests/p1/argc_exit.expected b/tests/p1/argc_exit.expected
diff --git a/tests/p1/double.P1 b/tests/p1/double.P1
@@ -0,0 +1,20 @@
+# tests/p1/double.P1 — call a helper that doubles argc, return that.
+#
+# `:double` is a leaf function that shifts its one-word argument left by
+# one and returns. `:p1_main` is not a leaf (it calls `double`), so it
+# establishes a standard frame with %enter/%leave to preserve the hidden
+# return-address state across the call. argc arrives in a0, is handed to
+# double unchanged, and the doubled result comes back in a0.
+
+:double
+ %shli(a0, a0, 1)
+ %ret()
+
+:p1_main
+ %enter(0)
+ %la_br() &double
+ %call()
+ %leave()
+ %ret()
+
+:ELF_end
diff --git a/tests/p1/double.expected b/tests/p1/double.expected