kvisc/ka/crt/fmt/printf.k

57 lines
640 B
Plaintext

; The OS/K Team licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
;
; int putc(int ch)
;
putc:
prn ax0
xor rax, rax
ret
;
; int printf(const char *fmt, ...)
;
printf:
enter 0
mov ax2, ax0
mov ax0, putc
mov ax1, STRLEN_MAX
lea ax3, b[rbp+16]
call _doprnt
leave
ret
;
; Print a string
;
print:
mov rcx, STRLEN_MAX
.1:
test b[ax0], b[ax0]
jmp.z .2
prn b[ax0]
inc ax0
loop .1
.2:
ret
;
; Print exactly ax1 characters
;
print_n:
mov rcx, ax1
.1:
prn b[ax0]
inc ax0
loop .1
ret