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

Edited 5 Years Ago by Phillamon: n/a

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!

This question has already been answered. Start a new discussion instead.