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

319 lines
4.1 KiB
Plaintext
Raw Normal View History

2019-06-18 23:04:55 +02:00
; The OS/K Team licenses this file to you under the MIT license.
; See the LICENSE file in the project root for more information.
2019-07-10 17:17:45 +02:00
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]
2019-07-04 20:33:49 +02:00
movsx_test:
mov rcx, 0x1188FF
movsxb rx8, rcx
movsxw rx9, rcx
movsxl r10, rcx
hlt
ret
2019-06-26 21:25:59 +02:00
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"
2019-06-23 20:56:04 +02:00
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"
2019-06-21 22:19:55 +02:00
speed_test:
2019-07-01 00:45:08 +02:00
utime rx8
2019-06-21 19:38:31 +02:00
2019-06-21 22:19:55 +02:00
mov rcx, ax0
nop.rep
2019-06-21 19:38:31 +02:00
2019-07-01 00:45:08 +02:00
utime rx9
2019-06-21 22:19:55 +02:00
2019-07-01 00:45:08 +02:00
mov rax, rx9
sub rax, rx8
2019-06-21 22:19:55 +02:00
2019-06-23 20:56:04 +02:00
ret
2019-06-21 19:38:31 +02:00
2019-06-20 18:13:06 +02:00
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
2019-06-18 23:04:55 +02:00
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
2019-06-21 22:19:55 +02:00
;mov ax0, .msg
;call print
2019-06-18 23:04:55 +02:00
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
2019-07-01 00:45:08 +02:00
mov rsi, 0x1111222233334444
wswap rx9, rsi
2019-06-18 23:04:55 +02:00
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]
2019-07-01 00:45:08 +02:00
movzx rsi, b[rsp]
movzx rdi, w[rsp]
movzx rx8, l[rsp]
movzx rx9, q[rsp]
2019-06-18 23:04:55 +02:00
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
2019-07-01 00:45:08 +02:00
mov r13, rax
2019-06-18 23:04:55 +02:00
mov ax0, .buf2
call strlen
ret
.msg = "Hello World :)"
.buf1 = [32]
.buf2 = "!!!!!!!!!!!!!"