created stdlib/debug.sl and moved int3 there as well as an improved version of debug thats now called dump
This commit is contained in:
22
stdlib/debug.sl
Normal file
22
stdlib/debug.sl
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
@@ -1,16 +1,3 @@
|
|||||||
: debug
|
|
||||||
for
|
|
||||||
puti cr
|
|
||||||
next
|
|
||||||
exit
|
|
||||||
;
|
|
||||||
|
|
||||||
# : int3 ( -- )
|
|
||||||
:asm int3 {
|
|
||||||
int3
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
# : c@ ( addr -- byte )
|
# : c@ ( addr -- byte )
|
||||||
:asm c@ {
|
:asm c@ {
|
||||||
mov rax, [r12] ; get address from stack
|
mov rax, [r12] ; get address from stack
|
||||||
@@ -304,6 +291,7 @@
|
|||||||
mov rdi, [r12] ; addr
|
mov rdi, [r12] ; addr
|
||||||
mov rax, 9 ; syscall: mmap
|
mov rax, 9 ; syscall: mmap
|
||||||
syscall
|
syscall
|
||||||
|
sub r12, 8
|
||||||
mov [r12], rax ; return addr
|
mov [r12], rax ; return addr
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -315,6 +303,7 @@
|
|||||||
mov rdi, [r12] ; addr
|
mov rdi, [r12] ; addr
|
||||||
mov rax, 11 ; syscall: munmap
|
mov rax, 11 ; syscall: munmap
|
||||||
syscall
|
syscall
|
||||||
|
sub r12, 8
|
||||||
mov [r12], rax ; return value
|
mov [r12], rax ; return value
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user