added ewrite_buf and eputs

This commit is contained in:
IgorCielniak
2026-01-08 18:44:48 +01:00
parent e37f5ae5e4
commit 39ed504d88
4 changed files with 24 additions and 0 deletions

View File

@@ -282,6 +282,19 @@
}
;
# : ewrite_buf ( addr len -- )
:asm ewrite_buf {
; data_start (trigger string_mode in compile-time VM)
mov rdx, [r12] ; len
mov rsi, [r12 + 8] ; addr
add r12, 16 ; pop len + addr
mov rax, 1 ; syscall: write
mov rdi, 2 ; fd = stderr
syscall
ret
}
;
# : putc ( char -- )
:asm putc {
mov rax, [r12]
@@ -346,3 +359,5 @@
word cr 10 putc end
word puts write_buf cr end
word eputs ewrite_buf cr end

1
tests/eputs.expected Normal file
View File

@@ -0,0 +1 @@
hello stderr

7
tests/eputs.sl Normal file
View File

@@ -0,0 +1,7 @@
import ../stdlib/stdlib.sl
import ../stdlib/io.sl
word main
"hello stderr" eputs
0
end

1
tests/eputs.test Normal file
View File

@@ -0,0 +1 @@
python main.py tests/eputs.sl -o /tmp/eputs > /dev/null && /tmp/eputs 2>&1