0

In this assembly program code, I'd like to keep entering 'Y'/Yes in the input, and after atleast 3 times of Yes/Y, the program will terminate itself or will jump to endmain, how do I do it?

I'd want this display:

Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
*then the program stops after 3tries*

not this

Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
Do you want to try again?: Y
infinity++
*x_x*

.

.model small
.stack
.data
a db 10, 13, "Do you want to Try again? Y/N $"


.code
org 0100h
main:

mov ax, @data
mov ds, ax

dsply:
mov ah, 9
lea dx, a
int 21h
mov ah, 1
int 21h
mov cl, al

cmp cl, 'Y'
je dsply
cmp cl, 'N'
je endmain


endmain:
mov ah, 4ch
int 21h
end main

Any suggestions?

stevenjake
  • 23
  • 6
  • 2
    Use an unused register (BX looks okay) to keep track of the current retry count (3) and exit the loop if it has been reached. You could set EBX to 3 and decrease it by 1 and check if it is zero. If it becomes zero you exit otherwise you loop back. – Michael Petch Aug 29 '17 at 02:01
  • In my last comment I meant _BX_ where I said _EBX_. – Michael Petch Aug 29 '17 at 04:31

0 Answers0