mirror of
https://gitlab.os-k.eu/os-k-team/kvisc.git
synced 2023-08-25 14:05:46 +02:00
62 lines
750 B
Plaintext
62 lines
750 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
|
|
nul rax
|
|
ret
|
|
|
|
;
|
|
; int printf(const char *fmt, ...)
|
|
;
|
|
printf:
|
|
mov ax2, ax0
|
|
mov ax0, putc
|
|
mov ax1, STRLEN_MAX
|
|
add ax3, rsp, 8
|
|
jmp doprnt
|
|
|
|
;
|
|
; int nprintf(const char *fmt, int n, ...)
|
|
;
|
|
nprintf:
|
|
mov ax2, ax0
|
|
mov ax0, putc
|
|
add ax3, rsp, 8
|
|
jmp doprnt
|
|
|
|
;
|
|
; Print a string
|
|
; Guaranteed to only affect rcx and ax0
|
|
;
|
|
print:
|
|
.l:
|
|
movzx rax, b[ax0]
|
|
jraxz .r
|
|
|
|
prn rax
|
|
inc ax0
|
|
|
|
jmp .l
|
|
|
|
.r:
|
|
ret
|
|
|
|
;
|
|
; Print exactly ax1 characters
|
|
;
|
|
nprint:
|
|
mov rcx, ax1
|
|
jrcxz .r
|
|
|
|
.l:
|
|
prn b[ax0]
|
|
inc ax0
|
|
loop .l
|
|
.r:
|
|
ret
|
|
|