rewritten 'sh' inside nob.sl from asm to l2 code, renamed strcpy to memcpy and put it in mem.sl

This commit is contained in:
IgorCielniak
2026-01-11 19:26:39 +01:00
parent 8139aa66d9
commit 77594f45f4
4 changed files with 151 additions and 165 deletions

View File

@@ -1,4 +1,5 @@
import stdlib/stdlib.sl
import stdlib/mem.sl
import stdlib/io.sl
word strconcat
@@ -9,11 +10,11 @@ word strconcat
alloc
r> r>
dup >r
strcpy
memcpy
swap
r> dup -rot +
r> r>
strcpy
memcpy
swap
3 pick
-
@@ -27,47 +28,6 @@ word strconcat
rdrop rdrop rdrop
end
word alloc
0 # addr hint (NULL)
swap # size
3 # prot (PROT_READ | PROT_WRITE)
34 # flags (MAP_PRIVATE | MAP_ANON)
-1 # fd
0 # offset
mmap
end
word free
munmap drop
end
word strcpy #(dst_addr src_addr len -- dst_addr len)
dup
>r
swap
dup c@
3 pick swap
c!
drop
swap
for
1 + dup
c@
swap
-rot
swap
1 +
dup
rot
c!
drop
swap
end
swap
nip
r> dup -rot - swap
end
word main
"hello world hello world hello " "world hello world hello world"
strconcat