Write Your Own Operating System Tutorial(5)

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值