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/sys/tests.k
2019-07-18 22:49:31 +02:00

374 lines
4.9 KiB
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.
arith128_test:
call .test_add
call .test_sub
ret
.print_lq:
push rax
push rdx
mov ax0, .fmt
call printf
add rsp, rsp, 16
prn 10
ret
.fmt = "0x%x:%x"
.test_add:
mov ax0, 0x99AABBCCDDEEFF00
mov ax1, 0x1122334455667788
mov ax2, 0xFF
call add_lq_q
call .print_lq
mov ax0, 0xFFFFFFFFFFFFFFFF
mov ax1, zero
mov ax2, 5
call add_lq_q
call .print_lq
mov ax0, 0x5500660077008800
mov ax1, 0x1100220033004400
mov ax2, 0x00AA00BB00CC00DD
mov ax3, 0x009900CE00DF00AB
call add_lq_lq
call .print_lq
ret
.test_sub:
mov ax0, 0x99AABBCCDDEEFFFF
mov ax1, 0x1122334455667788
mov ax2, 0xFF
call sub_lq_q
call .print_lq
mov ax0, zero
mov ax1, zero
mov ax2, 2
call sub_lq_q
call .print_lq
ret
file_test:
.bufsize := 256
mov ax0, .fn
call DISK.OpenFile
push rax
mov ax0, rax
mov ax1, .buf
mov ax2, .bufsize
call DISK.ReadFile
mov rcx, .bufsize
mov rdx, .buf
prns.rep.nz rdx
pop rax
call DISK.CloseFile
hlt
ret
.fn = "doskrnl.sym"
.buf = [.bufsize]
movsx_test:
mov rcx, 0x1188FF
movsxb rx8, rcx
movsxw rx9, rcx
movsxl r10, rcx
hlt
ret
dir_test:
mov ax0, .buf
mov ax1, 128
call DISK.FindFirst
jmp .list
.next:
mov ax0, .buf
mov ax1, 128
call DISK.FindNext
.list:
test rax, rax
j.z .nothing
mov ax0, .fnd
call print
mov ax0, .buf
call print
prn 10
jmp .next
.nothing:
mov ax0, .err
call print
ret
.buf = [128]
.fnd = "File found: "
.err = "No more files found"
strtol_test:
mov ax0, .s1
mov ax1, 10
call strtol
mov nx0, rax
mov ax0, .s2
mov ax1, 16
call strtol
mov nx1, rax
mov ax0, .s3
mov ax1, 0
call strtol
mov nx2, rax
mov ax0, .s4
mov ax1, 10
call strtol
mov nx3, rax
ret
.s1 = "+065536"
.s2 = "0xABCD"
.s3 = "0b100000"
.s4 = "-1"
speed_test:
utime rx8
mov rcx, ax0
nop.rep
utime rx9
mov rax, rx9
sub rax, rx8
ret
putc_scroll_test:
mov rdx, 25
.1:
mov rcx, 79
prn.rep '+'
prn '!'
dec rdx
test rdx, rdx
j.nz .1
mov rcx, 80
prn.rep '&'
mov rcx, 80
prn.rep '%'
call showoff
ret
cpudev_test:
call RFS.GetLeastAvail
mov rbx, rax
call RFS.GetCurIdx
mov rcx, rax
call RFS.GetMaxIdx
mov rdx, rax
mov ax0, 1
call RFS.ActivateFrame
mov ax0, 1
mov ax1, $rip
mov ax2, trap0_test
call RFS.StoreReg
mov ax0, 256
mov ax1, 1
call IDT.AddHandler
ret
trap0_test:
mov rsp, 0x300000
mov nx7, rax
;mov ax0, .msg
;call print
mov ax0, nx7
call IDT.DoneHandling
iret
.msg = "Handling TRAP #0 !\n"
showoff:
call ramdev_test
call bswap_test
call itoa_test
prn 10
call str_test
call movzx_test
prn 10
call printf_test
ret
printf_test:
mov ax0, .fmt
sub rsp, 128
mov q[rsp+40], 0x7FE
mov q[rsp+32], -2
mov q[rsp+24], 666
mov q[rsp+16], 0x112233DDAA6677BB
mov q[rsp+8], 'K'
mov q[rsp], .str
call printf
add rsp, 128
ret
.fmt = "%% Hello World %s - %c - %p - %d - %d - %b"
.str = "(cc)"
strchr_test:
mov rax, 0
mov ax0, .str
mov ax1, 33
call strchr
prn b[rax]
ret
.str = "Hello World!"
bswap_test:
mov rdx, 0x1122334455667788
bswap rax, rdx
mov rsi, 0x1111222233334444
wswap rx9, rsi
mov ax3, 0x1111111122222222
dswap ax0, ax3
ret
ramdev_test:
call MEM.GetMemOff
mov rdx, rax
call MEM.GetMemSize
ret
movzx_test:
enter 1
mov q[rsp], 0xFABC1234CCCCDDDD
mov rax, b[rsp]
mov rbx, w[rsp]
mov rcx, l[rsp]
mov rdx, q[rsp]
movzx rsi, b[rsp]
movzx rdi, w[rsp]
movzx rx8, l[rsp]
movzx rx9, q[rsp]
leave
ret
itoa_test:
mov ax0, .buf
mov ax1, LONG_MIN
mov ax2, 10
call itoa
mov ax0, rax
call print
prn 10
mov ax0, .buf
mov ax1, 0xfff85ffffffffff4
mov ax2, 16
call itoa
mov ax0, rax
call print
ret
.buf = [32]
devtest:
mov ax0, .buf
devctl 0, 1
mov ax0, .buf
call print
iocall 0, 0
ret
.buf = [32]
str_test:
mov ax0, .msg
call print
mov ax0, .buf1
mov ax1, .msg
call strcpy
prn 10
mov ax0, .buf1
call print
mov ax0, .buf2
mov ax1, .msg
mov ax2, 8
call strnzcpy
prn 10
mov ax0, .buf2
mov ax1, 12
call print_n
mov ax0, .msg
mov ax1, .buf1
call strcmp
mov rbx, rax
mov ax0, .buf2
mov ax1, .msg
call strcmp
mov r13, rax
mov ax0, .buf2
call strlen
ret
.msg = "Hello World :)"
.buf1 = [32]
.buf2 = "!!!!!!!!!!!!!"