this night i was sitting and translated this RGB macro in C++ to assembler:
well, i'm sure about that there are some better (smaller and faster) macro for this but hey, its my first own macro that do something good and is useful for me :tongue:
#define RGB(r, g ,b) ((DWORD) (((BYTE) (r) | \
((WORD) (g) << 8)) | \
(((DWORD) (BYTE) (b)) << 16)))
mRGB MACRO R,G,B
mov eax,R
mov ecx,G
shl ecx,8
or eax,ecx
mov ecx,B
shl ecx,16
or eax,ecx
endm
well, i'm sure about that there are some better (smaller and faster) macro for this but hey, its my first own macro that do something good and is useful for me :tongue:
That macro would need a lot of work to be as flexible as the C macro... anyway, how often are you going to use it with non-constant arguments? If you only need constant arguments, it can be made as efficient as the C macro.
Bitrake posted this constant-only macro in another thread:
I think I saw one funky RGB macro that did checks on the argument to generate code if necessary, but I couldn't find it. This macro should be just fine though, unless you want the macro to work with non-constant arguments.
Bitrake posted this constant-only macro in another thread:
RGB MACRO red,green,blue
EXITM %((blue SHL 16) OR (green SHL 8) OR (blue))
ENDM
I think I saw one funky RGB macro that did checks on the argument to generate code if necessary, but I couldn't find it. This macro should be just fine though, unless you want the macro to work with non-constant arguments.
i'm going use it like this:
and it works perfect. :)
mRGB 255,255,255
invoke CreateSolidBrush,eax
mov brush,eax
invoke GetClientRect,hWnd,addr rect
invoke FillRect,hhdc,addr rect,brush
and it works perfect. :)
If you're going to use it like this, the RGB macro from bitrake is a lot better...
With *no* code generation overhead, the RGB value is pushed directly.
invoke CreateSolidBrush, RGB(255,255,255)
With *no* code generation overhead, the RGB value is pushed directly.
well, i dont really understand his macro
What does the EXITM do?
how can i make a makro so i can call it like you do here:
invoke CreateSolidBrush, RGB(255,255,255)
with the () ??
What does the EXITM do?
how can i make a makro so i can call it like you do here:
invoke CreateSolidBrush, RGB(255,255,255)
with the () ??
EXITM will return the result in-line so you can use the macro in invoke statements etc...
BitRakes MACRO dosent work as it should.
RGB(0,0,255) does NOT be blue.
RGB(0,255,255) will be white
my macro works better :/
RGB(0,0,255) does NOT be blue.
RGB(0,255,255) will be white
my macro works better :/
:(
I remember that thread, there was a typo in the macro but I figured it was self-evident so I didn't comment on it...
It should be like this:
The error is so silly I didn't realize either until I actually had to use the macro.
I remember that thread, there was a typo in the macro but I figured it was self-evident so I didn't comment on it...
It should be like this:
RGB MACRO red,green,blue
EXITM %((blue SHL 16) OR (green SHL 8) OR ([COLOR=red]red[/COLOR]))
ENDM
The error is so silly I didn't realize either until I actually had to use the macro.
:mad: so stupid of me, of course it should be red there :(
heh, you didn't catch the obvious flaw ;)
RGB MACRO red,green,blue
EXITM %((blue SHL 16) OR (green SHL 8) OR ([b]red[/b]))
ENDM