mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Finally made backspace work
This commit is contained in:
+23
-5
@@ -26,20 +26,38 @@ input:
|
|||||||
.loop:
|
.loop:
|
||||||
xor ax, ax ; Clear ax
|
xor ax, ax ; Clear ax
|
||||||
int 0x16 ; Get a character
|
int 0x16 ; Get a character
|
||||||
mov ah, 0x0e ; Echo back input
|
|
||||||
mov bh, 0
|
|
||||||
int 0x10
|
|
||||||
|
|
||||||
cmp al, 0x0d ; Compare with CR
|
cmp al, 0x0d ; Compare with CR
|
||||||
je .enter
|
je .enter
|
||||||
|
cmp al, 0x08 ; Compare with BS
|
||||||
|
je .backspace
|
||||||
|
|
||||||
|
mov ah, 0x0e ; Echo back input
|
||||||
|
mov bh, 0
|
||||||
|
int 0x10
|
||||||
|
|
||||||
mov [si], al ; Add the input to userInput
|
mov [si], al ; Add the input to userInput
|
||||||
inc cx
|
inc cx
|
||||||
inc si
|
inc si
|
||||||
jmp .loop
|
jmp .loop
|
||||||
.enter:
|
.backspace:
|
||||||
mov al, 0x0a ; Print LF
|
cmp cx, 0 ; Check if we can backspace
|
||||||
|
je .loop
|
||||||
|
mov byte [si], 0
|
||||||
|
dec si
|
||||||
|
dec cx
|
||||||
|
mov al, 0x08
|
||||||
int 0x10
|
int 0x10
|
||||||
|
mov al, ' '
|
||||||
|
int 0x10
|
||||||
|
mov al, 0x08
|
||||||
|
int 0x10
|
||||||
|
jmp .loop
|
||||||
|
.enter:
|
||||||
|
push si
|
||||||
|
mov si, newline
|
||||||
|
call print
|
||||||
|
pop si
|
||||||
mov byte [si], 0 ; NULL terminate userInput (Replaces CR)
|
mov byte [si], 0 ; NULL terminate userInput (Replaces CR)
|
||||||
mov byte [inputLen], cl
|
mov byte [inputLen], cl
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user