The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on November 14, 2011, 08:19:37 AM

Title: Struct array
Post by: ragdog on November 14, 2011, 08:19:37 AM
Hi

I try to translate this from C to Masm32
and i think it is a Struct array and this read out in a while or?

for (i = pBuffer->StructXyz.FirstItem; i <= pBuffer->StructXyz.LastItem + 1; i++) {
int index = i - pBuffer->StructXyz.FirstItem;
      if (i <= pBuffer->StructXyz.LastItem) {

         pBuffer->StructXyz.pData[index].Address[1]
        pBuffer->StructXyz.pData[index].Address[2]
        pBuffer->StructXyz.pData[index].Address[3]
     }
}

Can any please post an example in masm32

Greets,
Title: Re: Struct array
Post by: MichaelW on November 14, 2011, 10:33:08 AM
It looks like a structure that contains an array of structures, used as a template to access a buffer. I think you are going to need the structure definition to do anything with this. And the following lines are not complete statements:

pBuffer->StructXyz.pData[index].Address[1]
pBuffer->StructXyz.pData[index].Address[2]
pBuffer->StructXyz.pData[index].Address[3]

Title: Re: Struct array
Post by: ragdog on November 14, 2011, 11:58:40 AM
Here is this with structur definition



typedef struct _p_DATA {
  UCHAR Reserved;
  UCHAR Control  :4;
  UCHAR Adr  :4;
  UCHAR Number;
  UCHAR Reserved1;
  UCHAR Address[4];
} p_DATA, *Pp_DATA;

typedef struct _StructXyz {
  UCHAR Length[2];
  UCHAR FirstItem;
  UCHAR LasttItem;
  p_DATA pData[MAXIMUM_NUMBER];
} StructXyz, *PStructXyz;



StructXyz pBuffer;


for (i = xyz->pBuffer.FirstItem; i <= xyz->pBuffer.LasttItem + 1; i++) {
     int index = i - xyz->pBuffer.FirstItem;
     if (i <= xyz->pBuffer.LasttItem) {
           ;wsprintf for this items "  %02d  %02d  %02d\n",
                     xyz->pBuffer.pData[index].Address[1],
                     xyz->pBuffer.pData[index].Address[2],
                     xyz->pBuffer.pData[index].Address[3]);


         }
}


I hope its better
Title: Re: Struct array
Post by: ToutEnMasm on November 14, 2011, 02:54:11 PM

Put this in a c++ project.
ADD option  /FA  in the c++ command line nd .... you have it translate in a .asm
Title: Re: Struct array
Post by: ragdog on November 14, 2011, 05:24:01 PM
Thanks for this tip  :U