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

If the user enters 14, will it ask 14 times or will that be a different question to ask?

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

In line 24..
You can not use cmp with both operands being a memory variable. Instead use an immediate value

cmp number,14d  ;the immediate value must be the second operand

or you can also do

cmp al,max

Well, if i undersood corectly, you want to loop that the user puts how many times, so, you can use the register ECX to store how many times you want the loop and then use the LOOP procedure.

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!

MOV ECX, 10;number of times the loop will execute
LOOP INLINEFUNC
INLINEFUNC:
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.