ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Write Your Own Operating System Tutorial(5) (转)

Write Your Own Operating System Tutorial(5) (转)

原创 Linux操作系统 作者:gugu99 时间:2007-12-02 14:40:13 0 删除 编辑
Write Your Own Operating System Tutorial(5) (转)[@more@]

Lesson 5: Let’s Make It Interactive

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 using function 0, interrupt 0x16.  This is done easily with the following two instructions.

  xor  ah, ah  ; we want function zeroXML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />

  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 typed.

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

In the next lesson we will learn how to make our operating system larger than the single sector of the Boot Record.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-987395/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3122
  • 访问量
    2226099