# Help! Urgent! Comparing Strings in Assembly Language



## ChipDale (Jun 5, 2008)

Hi,

i need to compare 2 strings in ASM... one of the string has been input in the buffer using DOS function codes..AH = 0Ah and Int 21h...

the following code asks the user to input a string and displays the entered string back to the user. Then, i need to compare the input string to a predefined string and jump to certain labels accordingly... ie if the input string is "HI", then print label should be executed else the program should terminate.

the problem is that even when the input string is HI, tthe print label is not getting executed.
i m using an emulator 8086 to run the code....

Kindly assist me...

org 100h

.data

OurBuff db 00h, 00h
FirstS db 13, 10, "Please Enter a String: $"
SecondS db 13, 10, "Entered String was: $"
Success db 13, 10, "Success!!$"

.code

mov ax, @DATA
mov ds, ax

mov dx, offset FirstS
mov ah, 09h
int 21h

mov bx, offset OurBuff
mov dx, bx
mov byte [bx], 33

mov ah, 0Ah
int 21h

mov dx, offset SecondS
mov ah, 09h
int 21h

;mov bx, offset OurBuff
mov al, [bx+1]
add al, 02h
xor ah, ah

mov si, ax
mov byte [bx+si], '$'

mov dx, offset OurBuff
add dx, 02h
mov ah, 09h
int 21h

mov ax, dx
cmp ax, "HI"
jne exit

print: 
mov dx, offset Success
mov ah, 09h
int 21h 
jmp exit

exit:
ret

thank you...


----------

