The MASM Forum

General => The Campus => Topic started by: digelo on July 28, 2012, 10:07:06 PM

Title: C to Masm part 2
Post by: digelo on July 28, 2012, 10:07:06 PM
i tried to translate this codes to masm but i got unexpected errors that take long time to explain ...i don understand how to translate SetKK() from c to masm :|

typedef struct tagAKB_VIC
{
WORD wLowOffset;
WORD wHighOffset;
} AKB_VIC, *PAKB_VIC;


extern AKB_VIC OgKK[256];
extern PVOID    EtKK[256];



#define AKB_OFFSET_TO_DWORD( _akb ) \
_akb.wLowOffset | _akb.wHighOffset << 16



SetKK()
{
ULONG i;

for( i = 0; i < 256; i++ )
EtKK[i] = (PVOID)( (DWORD)AKB_OFFSET_TO_DWORD( OgKK[i] ) );
}
Title: Re: C to Masm part 2
Post by: qWord on July 28, 2012, 11:15:53 PM
It is a type casting operation: the structure AKB_VIC is converted to a pointer.
This is much simpler in MASM:
e.g.:
mov eax,PVOID ptr OgKK[ecx*SIZEOF AKB_VIC] ; SIZEOF AKB_VIC = 4
mov EtKK[ecx*SIZEOF PVOID],eax ; SIZEOF PVOID = 4

The second array is not really needed in assembler (and also in C...).