Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle keyboard in real mode through BIOS interrupts?

I have to code for a operating system on which I can run a calculater.It is like a desktop calculater. For this I am reading the brokenthorn operating development series I have completed the second stage of bootloader The bootloader is in real mode. After this the author is explaining the protected mode. I don't want to use the protected mode. I don't have time for that. So I want to write the calculater in real mode by using bios interrupts. Is it possible? I think it can be written on the second stage of the bootloader(I am not sure.) Means I don't have to use a kernel(I am not sure). I don't know how to use BIOS interrupts to handle the keyboard. Can anybody provide me a link which will help me in this? And If anything wrong in whatevet I assumed above is wrong, please correct me.Thanks in advance.

like image 321
narayanpatra Avatar asked Nov 06 '10 13:11

narayanpatra


People also ask

What is real mode interrupt?

In the real mode, the Pentium follows the interrupt mechanism used by the 8086 processor. In this mode, the IDT is located at base address 0. Each vector takes only four bytes as opposed to eight bytes in the protected mode.

Is keyboard an interrupt?

In computing, keyboard interrupt may refer to: A special case of signal (computing), a condition (often implemented as an exception) usually generated by the keyboard in the text user interface. A hardware interrupt generated when a key is pressed or released, see keyboard controller (computing)

What is the interrupt key on the keyboard?

The attention interrupt key often is labeled PA1 . Sometimes it is called an escape key and is labeled Esc .


2 Answers

If you want to use high-level BIOS keyboard services, rather than handling the keyboard interrupts yourself, then INT 16h is what you want.

INT 16h with AH=00h or 10h will block waiting for a keypress (returns ASCII result in AL); use AH=01h or 11h to query whether a keypress is available first if you want to avoid blocking (returns immediately with ZF clear if a key is available, or set if not). See e.g. here, or here (or Google "INT 16h" for more).

like image 137
Matthew Slattery Avatar answered Sep 28 '22 10:09

Matthew Slattery


You can handle IRQ 1 (mapped to interrupt 9 by the x86 controller) and read the keys from port 60h.

See http://inglorion.net/documents/tutorials/x86ostut/keyboard/.

like image 40
Frédéric Hamidi Avatar answered Sep 28 '22 10:09

Frédéric Hamidi