Write Your Own Operating System Tutorial (5)

zhaozj2021-02-08  241

Lesson 5: Let's Make it ITERACTIVE

All of this printing stuff to the screen is fun, but no operating system would be any good at all if it did not provide any interactivity. Let's make it read input from the keyboard. Again we will be using calls to a function in BIOS to Read the keyboard.

We are going to be used function 0, interrupt 0x16. This Is Done Easily with The Following TWO Instructions.

XOR AH, AH; WE WANT Function Zero

INT 0x16; Wait for a keypress

This function causes the computer to pause and does not return until a key is pressed. This can be used in a "Press any key to continue" situation, or also if you want to get input from the user. The scan code of the key Pressed Will Be Returned In Register Ah, And The Ascii Code Is Returned in Al.

Your assignment for this lesson is to write a simple boot program that demonstrates a bit of interactivity. Perhaps it could print a message each time a key is pressed. Or maybe allow the user to type at the keyboard and echo each character to the screen as IT is type.

If you get stuck, here is an example of my owne. But it's no fair peeking unsil you've tried by yourself!

.

转载请注明原文地址:https://www.9cbs.com/read-3193.html

New Post(0)