rdos/kernel/syscall.asm

97 lines
1.1 KiB
NASM

cpm_syscall:
cmp cl, 0
je init
cmp cl, 1
jne console_input.chain
console_input.loop:
call idle
console_input:
push dx
mov dl, 0xFF
call console_io
pop dx
jz console_input.loop
test al, al
jz console_input.loop
push dx
mov dl, al
call console_output
pop dx
ret
.chain:
cmp cl, 2
jne console_output.chain
console_output:
cmp dl, 0xFF
je .end
call console_io
.end:
ret
.chain:
cmp cl, 9
jne print_string.chain
print_string:
push si
mov si, dx
.loop:
mov dl, BYTE [si]
cmp dl, '$'
jz .end
call console_output
inc si
jmp .loop
.end:
pop si
ret
.chain:
cmp cl, 10
jne read_buffer.chain
read_buffer:
push ax
push dx
push bx
push si
xor bx, bx
mov si, dx
.loop:
call console_input
cmp al, 0x0D
je .end
cmp al, 8
je .bs
mov [si+bx+2], al
inc bx
cmp bl, [si]
jc .loop
.end:
mov byte [si+bx+2], 0x0D
mov [si+1], bl
mov dl, 0x0A
call console_output
pop si
pop bx
pop dx
pop ax
ret
.bs:
test bx, bx
jz .loop
mov dl, 0x20
call console_output
mov dl, 8
call console_output
dec bx
jmp .loop
.chain:
stc
ret