[SOLUTION]: it has nothing to do with the interrupt, I setup my own version of scrolling the VGA text buffer when the y position of the cursor went beyond 25 rows, and forgot to clear the last row after shifting the buffer up. That was the main issue as to why it appeared to be printing twice, when in reality it printed and shifted the cells up, but didn't clear the last row.
[ORIGINAL POST]
One issue that I'm running into is that after a few key presses, a single key press results in the scan code being printed twice, for instance if I hit key A, 001E is printed twice rather than once. The first few key presses work fine and only print once though. I am aware that two interrupts are usually fired on a key press, one for the key going down and one for it being released, but I've added a condition in my interrupt handler to skip the print for key releases.
My interrupt handler is identical to the code provided in the tutorial as shown below:
Code: Select all
keyhandler:
inb $0x60, %al # Get key data
mov %al, %bl # Save it
mov %al, port60
inb $0x61, %al # Keyboard control byte
mov %al, %ah
or $0x80, %al # Disable bit 7
outb %al, $0x61 # Send it back
xchgb %al, %ah # Get the original value and send it back
outb %al, $0x61
mov $0x20, %al # Send the EOI (End of Interrupt signal) for the master controller
outb %al, $0x20
and $0x80, %bl # Skip any scan codes indicating a key release
jnz done
# Print out the scan code in hexadecimal
mov port60, %ax
mov %ax, reg16
call printreg16
done:
iret
port60: .word 0
This is also the github link: https://github.com/BrickSigma/ChippyOS. It might be work noting that I'm building this in Linux using my system's installation of AS and LD for compiling the code, and I'll be switching to a cross compiler once I start programming it in C.
Thanks in advance and have a great day.