Reputation: 327
I'm writing a program for DOS and I want to get keyboard input. The thing is that I don't want to get that input using BIOS or DOS. What's the proper way to get keyboard input without using DOS or BIOS? I mean what's the way to get keyboard input in the lowest level of programming using I/O ports. Thanks!
Upvotes: 0
Views: 2713
Reputation: 23268
You need to do an inb
instruction on port 0x60 to read the scancode from the keyboard.
static inline uint8_t inportb(uint16_t port)
{
uint8_t ret;
asm volatile ("inb %1, %0" : "=a" (ret) : "dN" (port));
return ret;
}
scancode = inportb(0x60);
If you want to know when there's new input you need to setup an interrupt handler to listen for PS/2 interrupts or use USB polling depending on your keyboard.
Upvotes: 1