From bf4d11d313c909bc8136f0e66fcff5aa16f32ef2 Mon Sep 17 00:00:00 2001 From: IgorCielniak Date: Fri, 6 Feb 2026 10:46:48 +0100 Subject: [PATCH] added fdump and frdump for dumping the stack in the new format --- stdlib/debug.sl | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/stdlib/debug.sl b/stdlib/debug.sl index 6922374..be1e2a7 100644 --- a/stdlib/debug.sl +++ b/stdlib/debug.sl @@ -6,6 +6,7 @@ import io.sl # dump takes the firts element from the stack # and prints that much consequent elements # from the stack while not modifying it +# all variations have the same stack effect word dump 1 swap @@ -17,7 +18,7 @@ word dump drop end -# same but for return stack +# dump return stack word rdump 1 swap for @@ -28,6 +29,38 @@ word rdump drop end +word fdump + "[*, " write_buf + 1 swap 1 + + while dup 3 > do + dup pick + puti + 1 - + ", " write_buf + end + 1 - pick puti + " | " write_buf + 1 - pick puti + "]\n" write_buf +end + +word frdump + "[*, " write_buf + 1 swap 1 - + while dup 2 > do + dup rpick + puti + 1 - + ", " write_buf + end + rpick puti + ", " write_buf + rpick puti + " | " write_buf + rpick puti + "]\n" write_buf +end + #int3 [*] -> [*] :asm int3 { int3