I have searched high and low for help on this, and the examples I was able to find were just too advanced.

I am trying to learn how to loop through a simple array, and do something with the data.

Here is what I have so far:




.data

strText0 db "Magic",0
strText1 db "Hello",0
strText2 db "Assembly",0
strText3 db "Computer",0
strText4 db "Broken",0
strText5 db "Beer",0
strText6 db "MoreBeer",0
strText7 db "HotWomen",0
strText8 db "Goodbye",0
strText9 db "Ciao",0

TARGETWORD1 db "Beer",0

mySourceArray dd strText0 ,strText1 ,strText2 ,strText3 ,strText4 ,strText5 ,strText6 ,strText7 ,strText8 ,strText9

.code

start:

; Loop through Array and look for TARGETWORD1

BEGIN LOOP

.IF TARGETWORD1 == (strText9) ; NEED HELP HERE

MessageBox, NULL, chr$("We found a match!!"), chr$("results"), MB_OK

.ENDIF

END LOOP

end start



I think I have to use ESI (EDI) somewhere?

A little nudge would be appreciated. Thank you.

Trope
Posted on 2004-11-17 06:48:52 by TropE




.data

strText0 db "Magic",0
strText1 db "Hello",0
strText2 db "Assembly",0
strText3 db "Computer",0
strText4 db "Broken",0
strText5 db "Beer",0
strText6 db "MoreBeer",0
strText7 db "HotWomen",0
strText8 db "Goodbye",0
strText9 db "Ciao",0

TARGETWORD1 db "Beer",0

mySourceArray dd strText0 ,strText1 ,strText2 ,strText3 ,strText4 ,strText5 ,strText6 ,strText7 ,strText8 ,strText9

.code

start:

mov edi, 11
@@:
mov eax, [mySourceArray+edi*4]
invoke strcmp, offset TARGETWORD1, eax
test eax, eax
jz @F
dec edi
jnz @B
notfound:
....
@@:

MessageBox, NULL, chr$("We found a match!!"), chr$("results"), MB_OK
end start


I am too lazy to code a strcmp. I think you can code it as a practice.
Posted on 2004-11-17 08:04:11 by roticv
Terrific . Thank you, and I will do the "homework" you suggested!

Trope
Posted on 2004-11-17 08:12:32 by TropE
the strcmp function is easy, compare the 2 strings byte by byte and stop after comparing null-byte.
tip: do not forget to compare the null-byte else:
"blaat"
"blaatblaat"

would also form a match, good luck (this is an easy code).

Micro$oft once had that code for remote login (forgot the win version) so brute forcing was easy :lol:
Posted on 2004-11-17 10:11:49 by Scorpie
TropE,

Use the library procedure "szCmp" to test if the array member string is the same as you target string.


.if FUNC(szCmp,pstr,chr$("Beer")) != 0 ; if match
fn MessageBox,hWnd,"Bingo, you found it",pstr,MB_OK
.endif
Posted on 2004-11-18 08:04:46 by hutch--