Keyboard Input System
Using only the system interrupt generated when a key on the
keyboard is pressed, implement a simple but usable user-level
input system.
You should implement at least a readint() function
that could be used in this program (which of course you would
have to code in assembly language):
void main(void)
{ int x=readint();
int y=readint();
printf("%d + %d = %d\n", x, y, x+y); }
Being able to add two numbers together is not such a great
thing, but being able to write a correctly functioning
readint() demonstrates that you have got the input system
working properly.
Characters received by the interrupt service routine that
you write will have to be stored in a buffer somewhere, and
user-level functions (like readint()) will have to be made
to wait until there is a whole line in the buffer before
they are allowed to take any characters from it.
Hint: first implement a readchar() function, whose
job is to wait until there is a whole line in the buffer,
then retrieve the first/next character from that buffer.
Just like C's getchar(). All other user-level
functions should make use of readchar() so they do not
have to be concerned with the buffer or with waiting
in any way.
You should also allow the user to currect simple mistakes
by using the backspace or delete key. This is not difficult,
and can cause a big improvement in the usability of a system.