org 100h
.model small
.stack 100h
.data
c db ?
value db '0';
red db "Red$"
green db "Green$"
blue db "Blue$"
w db 0ah,0dh,"Wrong Choice$"
nl db 0ah,0dh,"$"
.code
main proc
mov dx,@data
mov ds,dx
;this code will behave like do while loop
level:
;c=getchar();
mov ah,7
int 21h
mov c,al
;if(c=='r') printf("Red")
cmp c,'r' ;if
je printredR
cmp c,'g'
je printredG ;else if
cmp c,'b'
je printredB ;else if
jmp wrong ;else
;blocks
printredR:
lea dx,red
add value,1
mov ah,9
int 21h
jmp exit
printredG:
lea dx,green
add value,1
mov ah,9
int 21h
jmp exit
printredB:
lea dx,blue
add value,1
mov ah,9
int 21h
jmp exit
wrong:
lea dx,w
mov ah,9
int 21h
mov ah,9
lea dx,nl
int 21h
cmp value,'2'
jmp level
exit:
mov ah,4ch
int 21h
endp
end main
Output
Wrong Choice
Red
Add your comment