added ewrite_buf and eputs
This commit is contained in:
15
stdlib/io.sl
15
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 -- )
|
# : putc ( char -- )
|
||||||
:asm putc {
|
:asm putc {
|
||||||
mov rax, [r12]
|
mov rax, [r12]
|
||||||
@@ -346,3 +359,5 @@
|
|||||||
word cr 10 putc end
|
word cr 10 putc end
|
||||||
|
|
||||||
word puts write_buf cr end
|
word puts write_buf cr end
|
||||||
|
|
||||||
|
word eputs ewrite_buf cr end
|
||||||
|
|||||||
1
tests/eputs.expected
Normal file
1
tests/eputs.expected
Normal file
@@ -0,0 +1 @@
|
|||||||
|
hello stderr
|
||||||
7
tests/eputs.sl
Normal file
7
tests/eputs.sl
Normal 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
1
tests/eputs.test
Normal file
@@ -0,0 +1 @@
|
|||||||
|
python main.py tests/eputs.sl -o /tmp/eputs > /dev/null && /tmp/eputs 2>&1
|
||||||
Reference in New Issue
Block a user