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?
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
this is only for stupid C-compilers, which cannot do this:
in assembler it will be no problem :)
int x; x = (DWORD) "ABCD";
mov eax, "ABCD"
Or a macro would make the code look nice:
...use it like this...
mov4c2d MACRO mREG, mCHAR1, mCHAR2, mCHAR3, mCHAR4 mov mREG, (mCHAR1+(mCHAR2*0100h)+(mCHAR3*010000h)+(mCHAR4*01000000h)) ENDM
...of course, all the values have to be assemble time constants.
mov4c2d eax, "D", "C", "B", "A"
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))) )