Im playing with memory on windows. Im just creating a tiny block of memory allocation. When I use the index like this [edx+ecx*4] the program suddenly stop responding and I need to use window task manager to shut it down. I have checked it muliple time to make sure that was not my fault but the assembler did. Any idea how to make it runs normal?
I am moving this topic to the workshop as it will be read by more people. The MASM32 subforum is fo4r direct MASM32 project issues.
The notation,
[edx+ecx*4]
Is normal assembler notation so it will be a mistake in your code design, the notation directly translates to an opcode in the processor so its not the problem. Just make sure you understand the compex addressing modes in x86 hardware,
[eax+ebx*4+16]
eax = base address
ebx = index
*4 = scale
+16 = displacement
Quote from: Farabi on April 07, 2005, 11:38:15 AM
Im playing with memory on windows. Im just creating a tiny block of memory allocation. When I use the index like this [edx+ecx*4] the program suddenly stop responding and I need to use window task manager to shut it down. I have checked it muliple time to make sure that was not my fault but the assembler did. Any idea how to make it runs normal?
Seriously if you are using masm, the encoding for the instruction is correct. Post your code as I suspect it is really your mistake (forgot to handle some exception etc)
Hi,
This format is usually used when you have a table of addresses or offsets to some strings or something. So if edx is the OFFSET of the table of offsets :P and ecx is the index into it to get an string or whatever at the address pointed by that index you use [edx+ecx*4]. Hope I made myself clear. Will post an example tomorrow! :U
Thomas :U
A purely random guess, but are you trashing the contents of either/both of those registers before trying to use them?
Any calls to functions in between getting their values and using them will mess them up. Push-pop :toothy
Quote from: Tedd on April 08, 2005, 11:20:23 AM
A purely random guess, but are you trashing the contents of either/both of those registers before trying to use them?
Any calls to functions in between getting their values and using them will mess them up. Push-pop :toothy
Here's a way around that. Use ebx instead of ecx. All the API functions preserve those.(esi edi ebx) . You only have to preserve them in your own functions too.
Thomas :U
Okay, thanks. Im not use any local variable, but I use edi as the temporary memory. I have found the mistake, yes it was my mistake. Something is use the edx register and I forgot not use push-pop.
Here is the source, i put it in here.
http://www.masmforum.com/simple/index.php?topic=1218.0