News:

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

Struct array

Started by ragdog, November 14, 2011, 08:19:37 AM

Previous topic - Next topic

ragdog

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,

MichaelW

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]

eschew obfuscation

ragdog

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

ToutEnMasm


Put this in a c++ project.
ADD option  /FA  in the c++ command line nd .... you have it translate in a .asm

ragdog

Thanks for this tip  :U