; AX = key pressed ; Waits until key is pressed before returning os_read_input: mov ah, 11h ; BIOS call to check for key int 16h ; Interrupt jnz .key_pressed ; Jump if input isn't 0 hlt jmp os_read_input .key_pressed: mov ah, 10h int 16h ret ; AX = key pressed ; Returns straight away keyboard_check_key: xor ax,ax mov ah, 11h ; BIOS call to check for key int 16h ; Interrupt jz .no_key .no_key: xor ax,ax ret ; ------------------------------------------- ; IN: ; AX = output address ; BX = max length keyboard_display_input: pusha mov di, ax mov ax, bx .check_key_pressed: call os_read_input cmp al, 08h je .backspace cmp al, 0Dh je .enter_key cmp al, 1Bh je .esc_key dec bx cmp bx, 0 je .enter_key ; Once the limit is reached just enter it ja .print_current_input ; Echo the user input back jmp .check_key_pressed .esc_key: call power_reboot .enter_key: mov al, 0 stosb popa ret ; Return to the parent function (whatever that may be) .backspace: cmp bx, 20 ; Cannot backspace if the cursor is at the start jb .move_cursor_back ; then .move_cursor_back jmp .check_key_pressed ; Else check the next key .move_cursor_back: mov ah, 0Eh mov al, 08h int 10h mov al, 20h int 10h mov al, 08h int 10h inc bx dec di jmp .check_key_pressed .print_current_input: ; Echo back that character and return the key inputing stosb mov ah, 0Eh int 10h jmp .check_key_pressed keyboard_get_cursor_pos: ret keyboard_wait_for_key: ret keyboard_show_cursor: ret keyboard_hide_cursor: ret keyboard_move_cursor: ret