Kaustav Majumder
Kaustav Majumder

Reputation: 351

What is wrong with this assembly code intended to emulate a loop?

This code is supposed to say Hello World five times!

org 100h

string db 'Hello World',0Dh,0Ah,'$'
mov dx,string
mov bl,0

check:
cmp bl,5
jb print
ja term

print:
mov ah,9
int 21h
mov ah,04Ch
int 21h
inc bl
jmp check

term:
ret

I'm getting only one Hello World as the output! Am I missing something?

Upvotes: 0

Views: 104

Answers (1)

hmakholm left over Monica
hmakholm left over Monica

Reputation: 23342

You're explicitly exiting the program (by INT 21h with AH=4Ch) after printing your string once!

It also looks like you're trying to execute the "Hello World" string as if it was code (sinc you're putting it at address 100h where the OS will start executing the program). Why that does not crash your program before it gets to print anything must be a case of pure luck.

Upvotes: 2

Related Questions