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

66 lines
784 B
Plaintext
Raw Normal View History

2019-05-29 19:05:06 +02:00
; The OS/K Team licences this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
2019-05-22 18:39:46 +02:00
2019-05-29 16:57:22 +02:00
hw = 'Hello World'
2019-05-29 18:26:28 +02:00
;
; Entry point
;
2019-05-29 16:57:22 +02:00
main:
2019-05-29 19:00:13 +02:00
; Initializes the stack
2019-05-29 16:57:22 +02:00
mov rbp, 0x200000
mov rsp, rbp
mov ax0, hw
call print
2019-05-29 19:00:13 +02:00
; mov ax0, hw
; mov ax1, hw_len
; call print_n
2019-05-22 18:39:46 +02:00
stop
2019-05-29 18:26:28 +02:00
;
; Max amount of characters that print() will print
;
v_print_max := 0xFF
;
; void print(char *)
;
; Print a string
;
2019-05-29 16:57:22 +02:00
print:
enter
2019-05-29 18:26:28 +02:00
mov rcx, v_print_max
2019-05-29 16:57:22 +02:00
2019-05-29 18:26:28 +02:00
.p1:
test b[ax0], b[ax0]
jz .p2
prn b[ax0]
inc ax0
loop .p1
2019-05-29 16:57:22 +02:00
2019-05-29 18:26:28 +02:00
.p2:
2019-05-29 16:57:22 +02:00
leave
ret
2019-05-29 18:26:28 +02:00
;
; void print_n(char *, int)
;
; Print exactly ax1 characters
;
print_n:
enter
mov rcx, ax1
.pn1:
2019-05-29 16:57:22 +02:00
prn b[ax0]
inc ax0
2019-05-29 18:26:28 +02:00
loop .pn1
leave
2019-05-22 18:39:46 +02:00
ret