annitaz -5 Light Poster

Write a program in PC assembly language to execute the following code:
b := 0;
a := 0;
read c (c must be between 5 and 9)
while ( (a+b) < c ) do
b := b+a;
a := a+1;

I wrote the followng but something is wrong

jmp 105 ;jump past data

;define a,b and c

db 00
db 00
db 0a

;program instructions start here

mov al,[102] ;AL = a
mov bl,[103] ;BL = b
mov cl,[104] ;CX = c

;start of while loop

cmp bl,cl ;is (a+b) < c?
jnl 11a ;if not then end of loop
add bl,al ;if yes then b:= b + a
inc al ;and a:= a + 1
jmp 110 ;end of while loop

;end of our program code

ret ;return to DOS

Can someone help?

Be a part of the DaniWeb community

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