I am trying to set the typematic rate of the keyboard because I've been used to the windows super-fast typematic speed, so the default one is extremely slow to me.
I just don't understand what I'm doing wrong, as I've looked at a lot of sources (including this website) and I'm doing exactly what is required (I think...).
Here's my code (I'm sorry to be one of those people to throw their code at you, but I simply don't have a clue really):
Code: Select all
keyboard_send_cmd: ;command in ah
cli
.wait_for_buffer_clear:
in al, 64H
test al, 2 ;we make sure byte 2 of al is CLEARED (to make sure that the keyboard is not caught up in other commands.
jnz .wait_for_buffer_clear ;fyi, test is basically a 'cmp' instruction except it ANDS the two values instead of subtracting them. the zero flag is set if the result of the 'ANDing' of the two is zero.
.send_cmd:
mov ah, al
out 60H, al
sti
ret
keyboard_controller_send_cmd: ;command in ah
cli
.wait_for_buffer_clear:
in al, 64H
test al, 2 ;we make sure byte 2 of al is CLEARED (to make sure that the keyboard is not caught up in other commands.
jnz .wait_for_buffer_clear ;fyi, test is basically a 'cmp' instruction except it ANDS the two values instead of subtracting them. the zero flag is set if the result of the and is zero.
.send_cmd:
mov ah, al ;we transfer cmd byte to al because in and out instructions needs byte to be in al, not ah (just way its wired).
out 64H, al
sti
ret
keyboard_read_out: ;for future reference, if we need to read the output of a command sent to ps2 controller.
cli
.wait:
in al, 64H
test al, 1 ;is input filled (cmd done)?
jz .wait ;no == jump until complete
.get_val:
in al, 60H ;yes: al == output
sti
ret
keyboard_setup:
mov ah, 0ADH ;disable keyboard
call keyboard_controller_send_cmd
mov ah, 0F3H ;set typematic rate command
call keyboard_send_cmd
mov ah, 20H ;the operand of the previous command
call keyboard_send_cmd
mov ah, 0AEH ;re-enable keyboard
call keyboard_controller_send_cmd
ret
Thanks for your input.