2019-10-20 21:11:44 +02:00
|
|
|
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:
|
2019-10-20 21:11:44 +02:00
|
|
|
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
|
2019-10-20 21:11:44 +02:00
|
|
|
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:
|
2019-10-20 21:11:44 +02:00
|
|
|
cmp dl, 0xFF
|
|
|
|
je .end
|
|
|
|
call console_io
|
|
|
|
.end:
|
2019-10-08 21:53:41 +02:00
|
|
|
ret
|
|
|
|
|
2019-10-20 21:11:44 +02:00
|
|
|
.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
|
|
|
|
|
2019-10-20 21:11:44 +02:00
|
|
|
.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
|
2019-10-20 21:11:44 +02:00
|
|
|
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
|
2019-10-20 21:11:44 +02:00
|
|
|
mov dl, 0x0A
|
|
|
|
call console_output
|
2019-10-08 21:53:41 +02:00
|
|
|
pop si
|
|
|
|
pop bx
|
2019-10-20 21:11:44 +02:00
|
|
|
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
|
2019-10-20 21:11:44 +02:00
|
|
|
|
|
|
|
.chain:
|
|
|
|
stc
|
|
|
|
ret
|