0

I'm using this code to get input from keyboard but i can't figure a way to get combination keys like "shift + a" = A

keypressed:
     in al,60h
     test al,80h
     jnz keypressed
     and al,7fh
     mov bx,table
     dec al
     xlat
     cmp al,0
     je key
         call put_char
key:
     in al,60h
     test al,80h
     jz key
     jmp keypressed 

table db 0x01,"1234567890-=",0X0E,0x0F,'qwertyuiop[]',0x1C,0,"asdfghjkl;'",0,0,0,"zxcvbnm,./",0,0,0," ",0

note - putchar is a procedure i made which prints anything in al.

HM2D
  • 1
  • 2
  • Do you get any meaningful data if you read addresses `0x417` and `0x418`? If so, you'd have the right and left shift key status in bits 0 and 1 of `0x417`. – Michael Jun 27 '14 at 08:44
  • You will first get a `shift pressed` scancode followed by an `a pressed`. You will have to remember the modifier key states yourself and use them as appropriate. – Jester Jun 27 '14 at 10:09
  • Whitout to use an ISR and without to check where the byte from the port 60h is comming from if we only are polling the port 60h, then it is possible that we get PS2-mouse bytes from the port 60h instead of a key from the keyboard. – Dirk Wolfgang Glomp Jun 27 '14 at 10:27

2 Answers2

0

You'll have to track shift key-down and key-up events and apply the shift state to the other key events as required. Or, just use the BIOS instead which will automatically do all that work for you.

Brian Knoblauch
  • 20,639
  • 15
  • 57
  • 92
-1

Example for polling the port for to get a key from the keyboard:

in al,64h       ; get the statusbyte from the keyboard
test al, 1      ; check if a byte is inside of the outputbuffer
jz short NOKEY
test al, 20h    ; check if the byte is coming from the PS2-mouse
jnz short NOKEY
in al, 60h      ; get the key from the outputbuffer
.....           ; <- place your code here
NOKEY:

Dirk