flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Why isn't my keyboard handler working?

Author
Thread Post new topic Reply to topic
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian
I made my keyboard int handler put an 'A' on the screen whenever a key is pressed, but I'm not seeing an A... and I'm stumped. This is my first protected mode interrupt handler, so I could doing something wrong.

The whole file is less than 2 kb, but I didn't know if it would be annoying to post that much text, so I attached it.

Here's the keyboard int handler:
Code:
keyboardIntHandler:
   push eax
   push ebx
   push ds

   mov  eax, dataSel
   mov  ds, eax

   ; A grey-on-blue 'A' should appear at (1,0) on the
   ;   screen as soon as a key is pressed:
   mov  al, 'A'
   mov  ah, 0x17
   mov  [0xB8002], ax

   ; Update the key state map:
   xor  eax, eax
   mov  bl, 1
   in   al, 60h
   test al, 80h
   jz   byte @F
     and  al, 7Fh
     dec  bl
   @@:
   mov  [keyStateMap+eax], bl

   pop  ds
   pop  ebx
   pop  eax

   iretd    


Description:
Download
Filename: kernel.asm
Filesize: 1.67 KB
Downloaded: 247 Time(s)

Post 28 Feb 2004, 04:45
View user's profile Send private message Reply with quote
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph
Hi. You need to wait for input. Your routine will just grab whatever is currently in there and not actually wait for you to enter a key. Try something like this:
Code:
     .read_key:
           in    al,64h
           and   al,01h
           jz   .read_key
     in    al,60h
    

al will contain the scancode. In my keyboard driver I then just use xlat to convert to whatever ASCII key it is.
Post 28 Feb 2004, 05:45
View user's profile Send private message Reply with quote
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian
Thanks, that probably would have causes a lot of problems later.

But it's still acting like the interrupt is never being called...

EDIT: INT 9 gets called whenever a key is pressed, just like in real mode, right? Or do I have to poll for input?
Post 28 Feb 2004, 06:26
View user's profile Send private message Reply with quote
0x4e71



Joined: 25 Feb 2004
Posts: 50
0x4e71
Well, did you enable IRQ1 and did you enable interrupts? otherwise, when initializing, add something like :
Code:
  mov ax,$FFFd ; enable irq 1 only
    out $21,al
  mov al,ah
   out $A1,al
  sti
    

Also, at the bottom of your handler you have to tell the PIC you are done with IRQ1, so:
Code:
      mov al,$20
  out $20,al
    

Cheers,
-Luigi
Post 28 Feb 2004, 11:56
View user's profile Send private message Reply with quote
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian
Yey, it works! Now I wish I understood why it works: what's an IRQ?
Post 29 Feb 2004, 05:01
View user's profile Send private message Reply with quote
0x4e71



Joined: 25 Feb 2004
Posts: 50
0x4e71
sure.
read
http://www.osdever.net/tutorials/irqs.php?the_id=37

and many other tutorials at osdever.net
Post 29 Feb 2004, 11:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.