1
0
mirror of https://gitlab.os-k.eu/os-k-team/kvisc.git synced 2023-08-25 14:05:46 +02:00
kvisc/ka/crt/fmt/printf.k

51 lines
592 B
Plaintext
Raw Normal View History

2019-05-30 12:44:56 +02:00
; The OS/K Team licenses this file to you under the MIT license.
2019-05-29 19:05:06 +02:00
; See the LICENSE file in the project root for more information.
2019-05-22 18:39:46 +02:00
2019-05-29 18:26:28 +02:00
;
2019-06-17 20:59:30 +02:00
; int putc(int ch)
2019-05-29 18:26:28 +02:00
;
2019-06-17 20:59:30 +02:00
putc:
prn ax0
xor rax, rax
ret
;
; int printf(const char *fmt, ...)
;
printf:
mov ax2, ax0
mov ax0, putc
mov ax1, STRLEN_MAX
2019-06-18 12:58:26 +02:00
lea ax3, b[rsp+8]
2019-06-19 13:50:53 +02:00
jmp doprnt
2019-05-29 18:26:28 +02:00
;
; Print a string
;
2019-05-29 16:57:22 +02:00
print:
2019-06-17 20:59:30 +02:00
mov rcx, STRLEN_MAX
2019-05-29 16:57:22 +02:00
2019-05-30 11:19:16 +02:00
.1:
2019-06-28 19:18:53 +02:00
cmp b[ax0], 0
ret.z
2019-05-30 21:46:00 +02:00
2019-05-29 18:26:28 +02:00
prn b[ax0]
inc ax0
2019-05-30 11:19:16 +02:00
loop .1
2019-05-29 16:57:22 +02:00
ret
2019-05-29 18:26:28 +02:00
;
; Print exactly ax1 characters
;
print_n:
2019-05-30 12:19:38 +02:00
mov rcx, ax1
2019-05-29 18:26:28 +02:00
2019-05-30 11:19:16 +02:00
.1:
2019-05-29 16:57:22 +02:00
prn b[ax0]
inc ax0
2019-05-30 11:19:16 +02:00
loop .1
2019-05-29 18:26:28 +02:00
2019-05-22 18:39:46 +02:00
ret