.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

include \masm32\Macros\Macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.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 OFFSET strText0,OFFSET strText1,OFFSET strText2,OFFSET strText3,OFFSET strText4,\
  OFFSET strText5,OFFSET strText6,OFFSET strText7,OFFSET strText8,OFFSET strText9
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code

start:
mov edi, 11
loop1:
mov ebx,
invoke lstrcmp, offset TARGETWORD1,ebx ;here is it to be crash. 
test eax, eax
jz loop2
dec edi
.if edi==0
invoke MessageBox,NULL,chr$("NO found a match!!"),chr$("results"), MB_OK
jmp qexit
.endif
jmp loop1
loop2:

invoke MessageBox,NULL,chr$("We found a match!!"),chr$("results"), MB_OK
jmp loop1
qexit:
invoke ExitProcess,NULL
end start
Posted on 2005-03-26 02:34:10 by dcskm4200
By putting 11 in edi you are trying to access invalid memory location (11*4 = 44, and size of mySourceArray?is 40 bytes).
Start with edi = 10.
Posted on 2005-03-26 03:45:45 by arafel
hey, arafel.

Thanks you.

it is still crashed.
I debuged the proc. showed follow:
;=======================
mov ebx, dword ptr ds.
push ebx            ; ebx=66204F4E, should ebx=00403044
push 00403049 ;"Beer"
;========================

regards.
Posted on 2005-03-26 05:10:13 by dcskm4200
Here is another trick with the notation in MASM.


.data ?
  array dd strText0,strText1,strText2,strText3, etc ....


The name IS the address.

Load the address of "array" and start from a zero based index up to the maximum number of members. Note that there are two levels of indirection here, the address of the array and for each member the address of the member.
Posted on 2005-03-26 05:19:03 by hutch--
Hey,hutch--

ok.
Thanks you very much.

regards.
Posted on 2005-03-26 05:38:40 by dcskm4200
That's what happens when you try to think about women, beer and difficult problems at the same time.
It's kind of difficult to explain. I hope these pages will shed some light on the subject.
http://www.priorywoods.middlesbrough.sch.uk/kidsonly/findout/counting/bugz.htm
http://www.teachrkids.com/fronts/number_recognition1.htm
Posted on 2005-03-26 05:52:52 by Sephiroth3
Hey,Sephiroth3

it isn't really .
I'm too old to hardly think about women, beer and difficult problems. besides I study some simple problems. But I will accept your suggestions which only you have experience. I will try.

regards.

Posted on 2005-03-26 06:09:00 by dcskm4200
hey, All

here is the question of replacing string.
how do I replace "=" and "*" in buffer1 to "|" and "#" in buffer2 ?


= to |
* to #

;================================
buffer1:
66.150.127.8=00:C0:9F:33:7F:99*66.150.127.4=00:06:5B:4B:DF:0A*66.150.127.3=00:02:55:FC:6E:92*66.150.127.21

=00:05:5D:00:35:9D*66.150.127.1=00:06:29:55:83:4B*66.150.127.18=00:11:43:08:49:54*66.150.127.65=00:07:E9:B

C:89:3B*66.150.127.66=00:07:E9:B4:8D:F5*66.150.127.85=00:A0:D1:D6:D7:C6*66.150.127.156=00:20:ED:AA:72:D

D*66.150.127.150=00:30:F1:5E:F4:99*66.150.127.137=00:20:ED:AA:69:8D*66.150.127.136=00:0C:76:FA:A2:14*66.

150.127.104=00:E0:4F:BF:65:AB*66.150.127.175=00:10:5C:BE:5F:D3*66.150.127.173=00:20:ED:AA:7C:BC*66.150.

127.172=00:10:5C:BE:6A:4F*66.150.127.125=00:10:5C:BE:68:4F*66.150.127.170=00:20:ED:AA:7E:63*66.150.127.2

07=00:11:43:08:23:4D*66.150.127.195=00:01:03:06:31:F0*66.150.127.179=00:0C:76:FB:64:F2*66.150.127.230=00:2

0:ED:AA:7C:91*66.150.127.226=00:00:48:AE:1C:44*66.150.127.197=00:07:E9:BC:96:2D*66.150.127.221=00:C0:4F:

CC:D2:7D*66.150.127.239=00:E0:4C:78:18:82*66.150.127.249=00:0D:56:66:48:E7*66.150.127.254=00:07:84:E6:A0:

0A*66.150.127.222=00:10:5C:BE:60:26*66.150.127.253=00:02:FD:6F:52:00*
;==============================================================================
buffer2:
66.150.127.8|00:C0:9F:33:7F:99#66.150.127.4|00:06:5B:4B:DF:0A#66.150.127.3|00:02:55:FC:6E:92#66.150.127.21|

00:05:5D:00:35:9D#66.150.127.1|00:06:29:55:83:4B#66.150.127.18|00:11:43:08:49:54#66.150.127.65|00:07:E9:BC:

89:3B#66.150.127.66|00:07:E9:B4:8D:F5#66.150.127.85|00:A0:D1:D6:D7:C6#66.150.127.156|00:20:ED:AA:72:DD#

66.150.127.150|00:30:F1:5E:F4:99#66.150.127.137|00:20:ED:AA:69:8D#66.150.127.136|00:0C:76:FA:A2:14#66.150

.127.104|00:E0:4F:BF:65:AB#66.150.127.175|00:10:5C:BE:5F:D3#66.150.127.173|00:20:ED:AA:7C:BC#66.150.127.

172|00:10:5C:BE:6A:4F#66.150.127.125|00:10:5C:BE:68:4F#66.150.127.170|00:20:ED:AA:7E:63#66.150.127.207|0

0:11:43:08:23:4D#66.150.127.195|00:01:03:06:31:F0#66.150.127.179|00:0C:76:FB:64:F2#66.150.127.230|00:20:ED:

AA:7C:91#66.150.127.226|00:00:48:AE:1C:44#66.150.127.197|00:07:E9:BC:96:2D#66.150.127.221|00:C0:4F:CC:D2

:7D#66.150.127.239|00:E0:4C:78:18:82#66.150.127.249|00:0D:56:66:48:E7#66.150.127.254|00:07:84:E6:A0:0A#66.

150.127.222|00:10:5C:BE:60:26#66.150.127.253|00:02:FD:6F:52:00#
Posted on 2005-03-26 08:40:02 by dcskm4200

mov ecx, offset buffer1;assuming masm code
mov edx, offset buffer2 - 1

@@:
dec edx
mov al,
inc ecx
mov , al
test al, al
jz done
cmp al, '='
jnz @F
mov byte ptr, '|'
@@:
cmp al, '*'
jnz @B
mov byte ptr, '#'
jmp @B

done:

Something like that I think
Posted on 2005-03-26 09:42:11 by roticv

That's what happens when you try to think about women, beer and difficult problems at the same time.
It's kind of difficult to explain. I hope these pages will shed some light on the subject.
http://www.priorywoods.middlesbrough.sch.uk/kidsonly/findout/counting/bugz.htm
http://www.teachrkids.com/fronts/number_recognition1.htm


hey, arafel.

Thanks you.

it is still crashed.
I debuged the proc. showed follow:
;=======================
mov ebx, dword ptr ds.
push ebx ; ebx=66204F4E, should ebx=00403044
push 00403049 ;"Beer"
;========================

regards.



I guess i'll need to spend some time on those sites... totaly forgot about zero based indexing.? :oops: :oops: :oops:
Posted on 2005-03-26 09:49:56 by arafel
Hey, roticv.

Thanks you.

it can't work. I modify some codes. but it still can't worked.

;======================
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include  \masm32\include\windows.inc
include  \masm32\include\kernel32.inc
include  \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

include  \masm32\Macros\Macros.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szbufFmt db "%s",0
buffer2 db 100 dup(0)
buffer1 db "66.150.127.8=00:C0:9F:33:7F:99*66.150.127.4=00:06:5B:4B:DF:0A*",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code

start:
mov ecx, offset buffer1 ;assuming masm code
mov edx, offset buffer2 ;- 1
invoke lstrlen,ecx
mov ebx,eax
L1:
dec ebx ; length of char. -1
.if ebx != 0  ; if go to last chr.
mov al, byte ptr
cmp al, '='
jnz L2
mov byte ptr, '|'
jmp L4
L2:
cmp al, '*'
jnz L3
mov byte ptr, '#'
jmp L4
L3:
mov byte ptr, al
L4:
inc edx
inc ecx
jmp L1
.endif

done:
invoke wsprintf,addr buffer1,addr szbufFmt,addr buffer1
invoke MessageBox,NULL,addr buffer1,chr$("Source"), MB_OK
invoke wsprintf,addr buffer2,addr szbufFmt,addr buffer2
invoke MessageBox,NULL,addr buffer2,chr$("Destion"), MB_OK
invoke ExitProcess,NULL
end start
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Posted on 2005-03-26 20:57:25 by dcskm4200
My mistake it should be

mov ecx, offset buffer1;assuming masm code
mov edx, offset buffer2 - 1

@@:
inc edx
mov al,
inc ecx
mov , al
test al, al
jz done
cmp al, '='
jnz @F
mov byte ptr, '|'
@@:
cmp al, '*'
jnz @B
mov byte ptr, '#'
jmp @B

done:


The values in register ecx, edx are most probably destroyed when you called lstrlen, so that is why it did not work.
Posted on 2005-03-27 03:16:51 by roticv
Hey, roticv.

it worked fine.
thanks you very much.


The values in register ecx, edx are most probably destroyed when you called lstrlen, so that is why it did not work.

full of TRUE.

thanks again.


Posted on 2005-03-27 05:27:57 by dcskm4200