This is one of those examples where the more code just makes everything so much less clear...

Here is the code I'm using now that works... Within the PLAYERS struct is a pointer to the LOCATIONS struct to tell the player where he is on the map... This really isn't clear code...



;Player is moving 'EAST'
push edi
ASSUME edi:PTR PLAYERS
mov edi, pPlayer
push esi
ASSUME esi:PTR LOCATIONS
mov esi, [edi].location
mov esi, [esi].e
mov [edi].location, esi
ASSUME esi:nothing
pop esi
ASSUME edi:nothing
pop edi


Now what I want to do is something like this (if I can get rid of the other ASSUME this would be great too, but as it stands this doesn't work...)



;Player is moving 'EAST'
push esi
ASSUME esi:PTR LOCATIONS
mov esi, (PLAYERS PTR [pPlayer]).location
mov esi, [esi].e
mov (PLAYERS PTR [pPlayer]).location, esi
ASSUME esi:nothing
pop esi


Any help is appreciated..
Sliver
Posted on 2002-04-15 15:46:40 by Sliver
I prefer this notation:
            ;Player is moving 'EAST'

push esi
mov esi, [pPlayer].PLAYERS.location
mov esi, [esi].LOCATIONS.e
mov [pPlayer].PLAYERS.location, esi
pop esi
Edit: I don't believe this will work as pPlayer is a DWORD ptr and not a static structure in the data section. Therefor, you still need to load it into a register, unless this has changed from the first code posted above.
            ;Player is moving 'EAST'

mov esi, pPlayer

mov eax, [esi].PLAYERS.location

push [eax].LOCATIONS.e
pop [esi].PLAYERS.location
Posted on 2002-04-15 20:50:48 by bitRAKE
Thanks BitRake,

I tried the code (before the and was about to give up) because it didn't work and I started to think that masm compilers aren't all alike :)

But the code you added at the bottom is much clearer indeed :) and works liek a charm

Thanks again (now I have small code for my "pointers to structures" and "static structures"...

Thanks

Sliver
Posted on 2002-04-15 21:25:45 by Sliver
Your welcome. The first bit of code was a rushed reply from work. After having read your question more thoroughly, I realized my solution wasn't. In my haste, I read over the fact that the second code didn't work.
Posted on 2002-04-15 22:07:37 by bitRAKE
I would code this:


;Player is moving 'EAST'
push edi
ASSUME edi:PTR PLAYERS
mov edi, pPlayer
push esi
ASSUME esi:PTR LOCATIONS
mov esi, [edi].location
mov esi, [esi].e
mov [edi].location, esi
ASSUME esi:nothing
pop esi
ASSUME edi:nothing
pop edi


like this:


;Player is moving 'EAST'
push edi
mov edi, pPlayer
push esi
mov esi,[PLAYERS PTR [edi]].location
mov esi, [LOCATION PTR [esi]].e
mov [PLAYERS PTR [edi]].location, esi
pop esi
pop edi



But thats just my personal preference. Both Bitrakes and my method should work (if he says it does, I dont know I have never used it) its just up to you which one you like better.

You can write the outer square brackets using curved brackets like (STRUCT PTR ).item. However this causes a conflict when using masms .IF and .WHILE etc through.
Posted on 2002-04-18 03:04:09 by huh