Thursday, 7 April 2016

Key Press in your own assembly 16 bit operating system

Hi Readers ! Ok in before lessons you viewed and practiced for Booting and printing characters right?

But, Even if you press any key in the screen will not appear. Because this is your own operating system. So you should give command to your operating system to print the character.

Now I will tell you some commands to get character from keyboard and print the character in screen for 16 bit operating system.

 mov ax, 0x07c0
 mov ds, ax

keypr:  ; this command is label to come back here 

;''''''''' wait for a key stroke
 mov ah,00      ; BIOS keyboard input function
 int 16h

mov ah,0x0E ; Print and go to the next character
int 0x10

jmp keypr  ; again jump to keypr to get next key and print

   times 510-($-$$) db 0
   db 0x55

   db 0xAA  


See the above program . The green color statements already I explained in previous posts. Now you are going to understand the label and jmp statement and 00 function in interrupt 16h.

I used here keypr: (you should give with colon(:)) you can use any valid word for this label. It means this is starting of some statements. If you give jmp keypr (here you should not use (:)) anywhere in the program the compiler will jmp immediately without condition to keypr: label where you put.

Int 16h is a Keyboard interrupt. 00 is function for  wait a keystroke. The compiler will wait for user key stroke When the compiler executes this statements.  After get your key press the 
Ascii code of your key will store in AL register. 

So Now the AL is filled with ascii character of your key.

Then the command will go to 

mov ah,0x0E  
Int 10h 

You know already this statement. It is used print that character which is stored in Al register.

Here you can watch the video for demo

https://www.youtube.com/watch?v=T_atx-3H3Gk




No comments:

Post a Comment