Basic Loop in Assembly
Ola!
I'm still kind of new with the whole assembly language and just need some help with this program i'm writing.
What I want it to do is to ask a question -like for a number and then store that inserted number in a variable. And then test whether its bigger than 14 which I declared as a variable already as shown below-and then there is a loop to ask again what is the number. So I want the loop to run as many time the number the user entered.
output db 10,13, "Enter your number: $"
asq dw 10,13, "$" ; ascii values for a new line
stilltoimplement db 10,13, "Do calculations later on $"
.code
jmp start
number db ?
max db 14 ;max number
start:
mov ax,@data
mov ds,ax
mov ah,09 ;prints new line
mov dx, offset output
int 21h
mov ah, 01 ;checks for key
int 21h
mov number, al
cmp max,number
jg start
jl part2
part2:
mov ah,09
mov dx,offset stilltoimplement
int 21h
ending:
mov ah,4ch
mov al,00
int 21h ;End the program
END
It gives me an error in where I try to compare the two variables and says Illegal memory reference. Prob just something small
Any help will be appreciated!
Thanks
Phillamon
Junior Poster in Training
65 posts since Oct 2010
Reputation Points: 36
Solved Threads: 5
If the user enters 14, will it ask 14 times or will that be a different question to ask?
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
I just wanted to test the cmp value. The Loop is actually for something else I just couldn't understand why it doesn't compare.
Thanks diwakar wagle it makes sense to me now!
And yes that is correct AceStryker!
Thanks for the help guys! After a day of searching I got myself a nice assembly online tutor which helped me alot!
Phillamon
Junior Poster in Training
65 posts since Oct 2010
Reputation Points: 36
Solved Threads: 5