Adds eprintf (printf but print to stderr)
This commit is contained in:
@@ -16,6 +16,7 @@ section .text
|
|||||||
global print
|
global print
|
||||||
global puts
|
global puts
|
||||||
global printf
|
global printf
|
||||||
|
global eprintf
|
||||||
|
|
||||||
;----- print(*str[]) -----;
|
;----- print(*str[]) -----;
|
||||||
; Prints given string to the console to stdout
|
; Prints given string to the console to stdout
|
||||||
@@ -101,6 +102,12 @@ printf:
|
|||||||
mov rax, FD_stdout
|
mov rax, FD_stdout
|
||||||
jmp __INTERNAL_fmt
|
jmp __INTERNAL_fmt
|
||||||
|
|
||||||
|
;----- eprintf(*format[], ...) -----;
|
||||||
|
; Same as printf, except prints to stderr
|
||||||
|
eprintf:
|
||||||
|
mov rax, FD_stderr
|
||||||
|
jmp __INTERNAL_fmt
|
||||||
|
|
||||||
;----- __INTERNAL_fmt(*format[], ...) -----;
|
;----- __INTERNAL_fmt(*format[], ...) -----;
|
||||||
; See printf description above, +
|
; See printf description above, +
|
||||||
; 1) Return value can be amount of printed characters or -errno (eg if bad FD was passed, -EBADF is returned)
|
; 1) Return value can be amount of printed characters or -errno (eg if bad FD was passed, -EBADF is returned)
|
||||||
|
@@ -73,6 +73,7 @@ extern umask_get
|
|||||||
extern print
|
extern print
|
||||||
extern puts
|
extern puts
|
||||||
extern printf
|
extern printf
|
||||||
|
extern eprintf
|
||||||
;string.asm
|
;string.asm
|
||||||
extern strlen
|
extern strlen
|
||||||
extern strcpy
|
extern strcpy
|
||||||
@@ -114,6 +115,7 @@ section .rodata
|
|||||||
TEST_print equ 1
|
TEST_print equ 1
|
||||||
TEST_puts equ 1
|
TEST_puts equ 1
|
||||||
TEST_printf equ 1
|
TEST_printf equ 1
|
||||||
|
TEST_eprintf equ 1
|
||||||
;string.asm_
|
;string.asm_
|
||||||
TEST_strlen equ 1
|
TEST_strlen equ 1
|
||||||
TEST_strcpy equ 1
|
TEST_strcpy equ 1
|
||||||
@@ -249,6 +251,10 @@ section .rodata
|
|||||||
printfStr3 db "%p | %16p | %016p | %#16p | %#016p\n%p | %016p | %16p | %#016p | %#16p\n",EOS
|
printfStr3 db "%p | %16p | %016p | %#16p | %#016p\n%p | %016p | %16p | %#016p | %#16p\n",EOS
|
||||||
addTest(printf_null, "printf(''NULL pointer (%%s): %s\n'', itoa(128, 9, 0, 0))")
|
addTest(printf_null, "printf(''NULL pointer (%%s): %s\n'', itoa(128, 9, 0, 0))")
|
||||||
printfStr4 db "NULL pointer (%%s): %s\n",EOS
|
printfStr4 db "NULL pointer (%%s): %s\n",EOS
|
||||||
|
;eprintf()
|
||||||
|
addTestHeader(_eprintf, "eprintf")
|
||||||
|
addTest(eprintf1, "eprintf(''This is not an error :-)\n'')")
|
||||||
|
eprintfStr1 db "This is not an error :-)\n",EOS
|
||||||
; STRINGS FOR USE IN STRING FUNCTIOns
|
; STRINGS FOR USE IN STRING FUNCTIOns
|
||||||
str1 db "Hello, World!",EOS;13
|
str1 db "Hello, World!",EOS;13
|
||||||
str2 db "Hello, world!",EOS;13
|
str2 db "Hello, world!",EOS;13
|
||||||
@@ -826,6 +832,16 @@ _start:
|
|||||||
assert_eq(26)
|
assert_eq(26)
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
;--- eprintf()
|
||||||
|
%if TEST_eprintf
|
||||||
|
printTestHeader(_eprintf)
|
||||||
|
|
||||||
|
printTest(eprintf1)
|
||||||
|
lea rdi, [rel eprintfStr1]
|
||||||
|
call eprintf
|
||||||
|
assert_eq(25)
|
||||||
|
%endif
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; STRINGS FOR STRING FUNCTIONS
|
;;; STRINGS FOR STRING FUNCTIONS
|
||||||
;;;
|
;;;
|
||||||
|
Reference in New Issue
Block a user