I am trying to figure out why my answer still wrong even though I type the cucumber...

   .model small
    .stack 100h
    data segment

str1 db "Enter Your answer: $"
after db "Your answer is: $"
answer db "Cucumber$"
input db 20 dup("$")
newline db 10,13, "$"
correct db "Your Answer is correct$"
wrong db "Your Answer is wrong$"

data ends

code segment
assume ds:data,cs:code
start:
mov ax,data
mov ds,ax

lea si, input
lea di, answer
;get input
mov ah,09h
lea dx,str1
int 21h

mov ah,0ah
mov dx,si
int 21h

mov ah,09h
lea dx, newline
int 21h

;print string

mov ah,09h
lea dx, after
int 21h

mov ah,09h
lea dx, input+2
int 21h

mov ah,09h
lea dx, newline
int 21h

;this is the answer
mov ah,09h
lea dx, answer
int 21h

mov ah,09h
lea dx, newline
int 21h

;string comparison
    mov bx, 00

mov bl,input+1
mov bh,answer+1

cmp bl,bh
jne l1

add si,2
add di,2
l2:
mov bl,byte ptr[si]
cmp byte ptr[di],bl
jne l1
inc si
inc di 
cmp byte ptr[di],"$"
jne l2

mov ah,09h
lea dx, correct
int 21h

jmp l5

 L1:
mov ah,09h
lea dx, wrong
int 21h
L5:
mov ah,09h
lea dx,newline
int 21h

mov ah,4ch
int 21h

CODE ENDS
END START

I found no cucumber and this is a fine example what happens when folk write code without comments.

commented: The answer is in the line 7 +0
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.