Saturday, July 14, 2012

Simple Loop using Assembly Language


[BITS 16]
ORG 0x7C00

MOV AL,65
CALL PrintCharacter
JMP $

PrintCharacter:
MOV ECX,15
loop_st:

MOV AH,0x0E
MOV BH,0x00
MOV BL,0x00

INT 0x10
INC AL
LOOP loop_st
RET

TIMES 510-($-$$) db 0
DW 0xAA55


Copy and paste this code in a file and save it as "Looop.asm". Then you can follow from Step 2


                                                        OR


Go to this Link. Download Looop.asm File

Step 1: Download Looop.asm from the above link

Step 2: Go to your terminal and then direct to where you've saved the file. 

Step 3: Run this code on Terminal 

                nasm Looop.asm -f bin -o Looop.bin 

Step 4: Then this code 

                dd if=Looop.bin bs=512 of=myhd.img 

Step 5: At last run this code 

                qemu myhd.img 


 This Loop will print first 15 letters of English alphabet.

No comments:

Post a Comment