rdos/bdos/syscall.asm

97 lines
1.1 KiB
NASM
Raw Normal View History

cpm_syscall:
cmp cl, 0
je init
cmp cl, 1
jne console_input.chain
console_input.loop:
call idle
2019-10-08 21:53:41 +02:00
console_input:
push dx
mov dl, 0xFF
call console_io
pop dx
jz console_input.loop
2019-10-08 21:53:41 +02:00
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
2019-10-08 21:53:41 +02:00
console_output:
cmp dl, 0xFF
je .end
call console_io
.end:
2019-10-08 21:53:41 +02:00
ret
.chain:
cmp cl, 9
jne print_string.chain
2019-10-08 21:53:41 +02:00
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
2019-10-08 21:53:41 +02:00
read_buffer:
2019-10-20 21:45:55 +02:00
push ax
push dx
2019-10-08 21:53:41 +02:00
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
2019-10-08 21:53:41 +02:00
pop si
pop bx
pop dx
2019-10-20 21:45:55 +02:00
pop ax
2019-10-08 21:53:41 +02:00
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