News:

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

Structure problem

Started by RuiLoureiro, May 26, 2011, 08:25:46 PM

Previous topic - Next topic

RuiLoureiro

I have the following struct

MODE struct
   pAAA    dd ?
   pBBB    dd ?
   kData   db 256 dup (?)
   pCCC    dd ?
MODE ends

and the buffer is defined as:

LENX       equ sizeof MODE
Buffer     db LENX*1000 dup (?)

If ESI points to the Buffer somewhere
how do i get the entry point to kData (in ESI or in EDI,...)

Its all, thank you

jj2007

mov eax, 123 ; member #123
imul eax, eax, LENX
add eax, offset Buffer
mov [eax.MODE.kData], 123

qWord

lea edi,Buffer[N*SIZEOF MODE]    ; edi points to some element (MODE) in array
mov [edi].MODE.kData[0],1        ; set first byte of kData
lea esi,[edi].MODE.kData[0]      ; esi = pointer to first byte
FPU in a trice: SmplMath
It's that simple!

jj2007

... provided that N is an immediate - an unlikely case for an array with 1,000 members :wink

mineiro


mov eax,"seno"
lea esi, Buffer
assume esi:ptr MODE
lea edi, [esi].kData   ;entry point, index 0
stosd
lea edi, [esi].kData + 1 * sizeof MODE  ;index 1
stosd
assume esi:nothing



mov eax,"seno"
lea edi, Buffer.MODE.kData + 0 * sizeof MODE
stosd

RuiLoureiro

@@qWord: exactly what i want   :wink

@@jj:  :thumbu

@@mineiro: i assume i dont like to use ASSUME !  :green2

thanks all