0

I am building a bootloader in nasm, I have been able to detect tab, enter, and backspace keys, but arrow keys won't work no matter what hex scan values I try.

I've tried the values here: What are the scan codes for keyboard arrows? (right,left,down,up) as well as many other google results (none of them matching each other), but it won't work, all it prints is a space, the code that should be running after it detects left arrow isn't running at all.

BITS 16

mov ah, 0h
int 10h
mov ah, 2h
mov dl, 0
mov dh, 0
int 10h
mov bl, 2 ; color
pop ds

global _start

_start:
jmp .character_read


.character_read:
  mov ah,00h ;remeber set the value to "ah" now you are going to read a keyboard input
  int 16h ;this interrupt is given to control keystrokes of keyboard
  cmp al, 0x08 ; if key is backspace
  je _backspace ; go to the section controling removing characters
  cmp al, 0x0D
  je _enter
  cmp al, 0x4B ; where it should detect left arrow
  je _back_cursor
  jmp .print_input



.print_input:
  mov ah,9h ;set the value to "ah" to print one character to std out
  mov cx,1 ;set the value how many time the character in "al" should be print
  int 10h
  jmp _forward_cursor
_backspace:
  mov ah, 2h
  dec dl
  int 10h
  mov ah, 9h
  mov cx, 1
  mov al, ""
  int 10h
  jmp _start
_enter:
  jmp _inc_col
_back_cursor:
  mov ah, 2h
  dec dl
  int 10h
  jmp _start
_forward_cursor:
  mov ah, 2h
  inc dl
  int 10h
  cmp dl, 80
  je _inc_col
  jne _start
_home:
  mov ah, 2h
  xor dl, dl
  int 10h
  jmp _start
_inc_col:
  mov ah, 2h
  xor dl, dl
  inc dh
  int 10h
  jmp _start
TIMES 510 - ($-$$) db 0
dw 0aa55h

I am on an HP Probook 6470b, with kali OS and qemu 7.1.0 as my emulator. Is this a problem with my code? or qemu?

E_net4
  • 27,810
  • 13
  • 101
  • 139
KaliMachine
  • 191
  • 9
  • 6
    Function 0 of int 16h returns key code in `al` and scan code in `ah`. Don't confuse key code with scan code. – dimich Oct 25 '22 at 18:48

0 Answers0