From f76ef276e9285b0b7ba6bd5041ec776d9c96f54d Mon Sep 17 00:00:00 2001 From: IgorCielniak Date: Thu, 25 Dec 2025 21:30:11 +0100 Subject: [PATCH] created stdlib/debug.sl and moved int3 there as well as an improved version of debug thats now called dump --- stdlib/debug.sl | 22 ++++++++++++++++++++++ stdlib/stdlib.sl | 15 ++------------- 2 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 stdlib/debug.sl diff --git a/stdlib/debug.sl b/stdlib/debug.sl new file mode 100644 index 0000000..8429b5c --- /dev/null +++ b/stdlib/debug.sl @@ -0,0 +1,22 @@ +# : dump ( n -- ) + +# dump takes the firts element from the stack +# and prints that much consequent elements +# from the stack while not modifying it + +: dump + 1 swap + for + dup pick + puti cr + 1 + + next + drop +; + +# : int3 ( -- ) +:asm int3 { + int3 +} +; + diff --git a/stdlib/stdlib.sl b/stdlib/stdlib.sl index fe3ca5e..6a70154 100644 --- a/stdlib/stdlib.sl +++ b/stdlib/stdlib.sl @@ -1,16 +1,3 @@ -: debug - for - puti cr - next - exit -; - -# : int3 ( -- ) -:asm int3 { - int3 -} -; - # : c@ ( addr -- byte ) :asm c@ { mov rax, [r12] ; get address from stack @@ -304,6 +291,7 @@ mov rdi, [r12] ; addr mov rax, 9 ; syscall: mmap syscall + sub r12, 8 mov [r12], rax ; return addr } ; @@ -315,6 +303,7 @@ mov rdi, [r12] ; addr mov rax, 11 ; syscall: munmap syscall + sub r12, 8 mov [r12], rax ; return value } ;