News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

C to Masm part 2

Started by digelo, July 28, 2012, 10:07:06 PM

Previous topic - Next topic

digelo

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] ) );
}

qWord

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...).
MREAL macros - when you need floating point arithmetic while assembling!