I have an array of strings. I want to find an element of array How do I do that? Here is what I tried, it should print out anything but its still does.

.model small
.stack
.data
goldenboard db      "1$","2$","3$","4$","5$","6$","7$","8$","9$","A$","B$","C$","D$","E$","F$","_$"
var db "1$"
.code
mov al,[goldenboard]
mov bl,[var]
cmp al,bl	
je quit	
 
mov cx,0
ny: mov dx,OFFSET goldenboard
add dx,cx
mov ax,SEG goldenboard	
       cmp dl,"-"
       je quit
       mov ds, ax
       mov ah,09h             
       int 21h
       inc cx
       cmp cx,32
       je quit
       jne ny
quit:	mov ax,4C02h            ;end program with an errorlevel =2 
       int 21h 
end

I am not sure exactly what you are trying to do with the last section of code but if you want to search for a string you need to use the esi register. You have an array of bytes, in other word a string. If you use lea to load the address of goldenboard into the esi register you can then increment esi to look at elements of the string. As you move through the string you can move each element out to al to do a comparison for the element you are looking for. At least that is the way I am used to doing it. Hope this helps

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.