I am trying to use this macro from the API reference but am not quite sure how to. This macro looks like it creates a packed DWORD using four byte values. #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3)<<24 )); Would this work? mov al,ch0 shl eax,8 mov al,ch1 shl eax,8 mov al,ch2 shl eax,8 mov al,ch3 or do I start with ch3 and go the other way?
Posted on 2001-04-30 15:48:00 by brewmanchu
Yes it should be in reversed order. The way your code is now, ch3 is put in al at the end of your code, causing ch3 to be the lowest byte in eax, but according to the C macro, ch3 should be shifted left 24 times (being the highest byte). Thomas
Posted on 2001-04-30 17:30:00 by Thomas
this is only for stupid C-compilers, which cannot do this:

int x;

x = (DWORD) "ABCD";
in assembler it will be no problem :)

mov eax, "ABCD"
Posted on 2001-05-01 08:40:00 by beaster
Or a macro would make the code look nice:

mov4c2d MACRO mREG, mCHAR1, mCHAR2, mCHAR3, mCHAR4
    mov mREG, (mCHAR1+(mCHAR2*0100h)+(mCHAR3*010000h)+(mCHAR4*01000000h))
  ENDM
...use it like this...

  mov4c2d eax, "D", "C", "B", "A"
...of course, all the values have to be assemble time constants.
Posted on 2001-05-01 18:18:00 by bitRAKE

 Anyone know how to convert the following to asm?:

 #define 
 MAKE_SOMETHING(sev,fac,code) \
 ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
Posted on 2001-05-01 18:34:00 by disease_2000