Home | x86 Assembly | <<< Previous | Next >>> |
;*KeyBoard character I/O* section .text org 100h jmp short start nop start cli mov dx, msg mov ah, 09h int 21h mov ah, 0h int 16h cmp al, 0 mov cx, 1 mov ah, 0ah int 10h mov ah, 4ch int 21h msg db 'enter a char', 0dh, 0ah, '$' end
|
This program requests an input and prints the
character you input
Its been designed to compile as a .COM file with NASM. A .COM file has the following properties: 1) It is a collection of machine level commands (numbers understood by the computer). 2) Its first instruction is a SHORT JMP. 3) The JMP is followed by a NOP (no operation). 4) The entire .COM program is usually smaller than 64kb In the program at left, we use interrupts 16h,10h,and 21h. INT 21h prints a string. To do this: DX must contain the starting offset of the string, and AH must be set to 09h.Now after setting these two registers, when INT 21h command is executed, the string is displayed. INT 16h gets a key stroke from the keyboard. For this, AH should be set to 00h. After executing the interrupt, you will be left with AH=BIOS scan code (of the key you pressed), and AL=ASCII character (of the key). INT 10h displays a character too. AH=0Ah, and AL=character to display |
Home | x86 Assembly | <<< Previous | Next >>> |