diff --git a/stdlib/io.sl b/stdlib/io.sl index 1391177..2f9d9dc 100644 --- a/stdlib/io.sl +++ b/stdlib/io.sl @@ -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 diff --git a/tests/eputs.expected b/tests/eputs.expected new file mode 100644 index 0000000..7a3e760 --- /dev/null +++ b/tests/eputs.expected @@ -0,0 +1 @@ +hello stderr \ No newline at end of file diff --git a/tests/eputs.sl b/tests/eputs.sl new file mode 100644 index 0000000..69fd76a --- /dev/null +++ b/tests/eputs.sl @@ -0,0 +1,7 @@ +import ../stdlib/stdlib.sl +import ../stdlib/io.sl + +word main + "hello stderr" eputs + 0 +end diff --git a/tests/eputs.test b/tests/eputs.test new file mode 100644 index 0000000..115324a --- /dev/null +++ b/tests/eputs.test @@ -0,0 +1 @@ +python main.py tests/eputs.sl -o /tmp/eputs > /dev/null && /tmp/eputs 2>&1