News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

OK - I'm never going to get this

Started by Astro, September 09, 2009, 01:06:08 AM

Previous topic - Next topic

Astro

 :dazzled:

No doubt I'm trying something illegal here?

A related question: why do some things work some ways, yet when you copy/paste code but use it in a slightly different way (even though the erroring code is itself identical to the working version), it errors like crazy?

mov edx,ptrLIST_INFO
mov ecx,4
mov esi,[edx+16]
mov edi,offset string ; 16-bytes, zero-terminated
repz cmpsd


Best regards,
Astro.

2-Bit Chip

What is LIST_INFO? Can't find it on msdn.microsoft.com or in any of the MASM32 include files.

dedndave

ptrLIST_INFO and - what is at ptrLIST_INFO+16 - lol
show us the data structure
show us ptrLIST_INFO and how it gets initialized
i am guessing that you want "mov edx,offset ptrLIST_INFO"
but, i'm not sure - then i have no idea what "[edx+16]" will yield
when you make posts like this, Astro, read them back to yourself and see if you have provided enough info to fix it   :bg

Astro

Argghh... sorry.

ptrLIST_INFO is my own structure.

At offset 16 (ptrLIST_INFO+16) for 16 bytes is byte data (a zero-terminated string).

I want to compare these 16 bytes to another 16 byte string that is hard coded: string db "MyString",0,0,0,0,0,0,0,0 but want to check all 16 bytes.

Bizarrely my original code worked in a console .exe but now I'm running it as a service it doesn't want to run (memory access violation). I copy/pasted the code, too, so there should be no possibility of an error!!!

I'm going nuts over what I perceive to be simple errors.  :'(

Best regards,
Astro.

dedndave


Astro

I tried that, and it seems to have stopped crashing there  :U  but now I get another error so I'll have to let you know.

Best regards,
Astro.

Astro

Hi,

After much whacking my head off a wall trying to understand this, it is: mov edx, ptrLIST_INFO

Best regards,
Astro.

dedndave

we have no way of knowing, Astro, as you have not posted the defines for ptrLIST_INFO

Astro

The bigger problem was that I couldn't see how it was working, but I'm fairly sure I've got it now.  :thumbu

ptrLIST_INFO is a dword, and is a pointer to memory.

If ptrLIST_INFO is at 0x00000001 and contains 0x00005FA3:

0x00000001: 0x00005FA3
...
0x00005FA3: 0x12345678

mov edx,ptrLIST_INFO moves 0x00005FA3 into edx.

[edx] causes the contents of edx to be treated as memory, so when I:

mov dword ptr [edx], 5h

I change:

0x00005FA3: 0x12345678

to:

0x00005FA3: 0x00000005

Best regards,
Astro.

dedndave

QuoteIf ptrLIST_INFO is at 0x00000001 and contains 0x00005FA3
0x00000001 is protected memory
attempting to read that address will get you our friend Dr Watson with c0000005
at any rate - let us know what the solution was

Astro

Quoteat any rate - let us know what the solution was
I already did. :)

mov edx, ptrLIST_INFO

The address 0x00000001 was an example only.

Best regards,
Astro.

dedndave

ok - but that is what you showed in the first post
i.e. nothing changed and it fixed itself ?

Astro

 :cheekygreen:

Umm yeah...

I think my original question was actually to do with comparing the strings! :cheekygreen:

Is it correct for comparing 4 bytes in one go, 4 times, for a total of 16 bytes?

Best regards,
Astro.

FORTRANS

Quote from: Astro on September 10, 2009, 09:20:34 PM
I think my original question was actually to do with comparing the strings! :cheekygreen:

Is it correct for comparing 4 bytes in one go, 4 times, for a total of 16 bytes?

Hi Astro,

   Yes, that will work.

Steve

Astro

Great! Thanks!!  :U

Best regards,
Astro.