I've a small suggestion,

bitRAKE has released alot of extremely useful macros, as have many others. I find nearly all my current programs use them heavily to simplify coding, unfortunatly that would mean that any code I post would not compile first time for most people here without me making changes.

So why not put together a general file with a load of macros which we could all stick in our masm32\macros\ folder and make things nice and easy for everyone.

I've attached the file I use as an example, two specific things which may seem strange I'll explain quickly.

First theres these equates
pb equ byte ptr
pw equ word ptr
pd equ dword ptr
pq equ qword ptr
pt equ tbyte ptr

Simply I hate typing dword ptr with every fld/fst which uses a register as a pointer, worse again I hate read code full of them so I use these shorthand versions, eg

fld pd
fstp pq

They also work as overides,

buf db 32 dup (?)

mov pd buf,12345

Second is this silly inline macro
inline MACRO n,y:VARARG
&nbsp IFIDNI <y>,<>
&nbsp&nbsp n
&nbsp ELSE
&nbsp&nbsp n y
&nbsp ENDIF

I like this as it lets macros which are suppose to represent inline procedures meld nicely along side invoked procedures. So for example for my array lib you can now use this to make things looks nicer (if you want, I just like it)

inline NewAry,8,8,sizeof(obj)
invoke GlobalFree,eax

I'm sure others out there have many good ideas, I just think it would be nice to have a more uniform method to our marcos. After all if you use them in each project then a single files makes sense.
Posted on 2002-07-05 12:29:34 by Eóin
Very nice work there, although I do much prefer TASM's simple:
mov dword [esi], eax

as opposed to ptr. Maybe your macros will solve the problem. :D
Posted on 2002-07-05 12:40:35 by comrade

import MACRO libname ; Import a lib and include the corresponding inc
IFNDEF lib_&libname&
include &libname&.inc
lib_&libname& equ TRUE
includelib &libname&.lib

include windows.inc
import kernel32
import user32

Posted on 2002-07-05 12:46:53 by Qweerdy
Comrade, thats the method Fasm uses as well and I do like it, but seeing as we're all used to the shorthand versions for data, db, dd etc I just started using similarly named shorthand versions for pointers, ie "p" instead of "d" :) .
Posted on 2002-07-05 12:49:39 by Eóin
Does noone else have any suggestions :confused:

Come on bitRAKE, I know you use a general file with all your macros in it.
Posted on 2002-07-06 06:21:55 by Eóin
I use a bit :-) smarter, IMHO, $MAKEDWORD macro.

mov xxx, $MAKEDWORD(a, b)

Returns a | (b << 16) in eax.

a or/and b can be immediate constant, word/dword register, word/dword local or mem variable.
So, any possible combinations, i think. If i forgot something mail me, please.
Should also say it was while ago. Can't remember any error. But i used it couple of times and noticed no problems.
So, error found mail me also.

In att you find also a prog i used to test it.

And my $RGB.
Works with immediate ops or byte reg/mem.
Didn't have fun to implement all possible combinations of bytes/words/wdords, sorry ;-)

mov xxx, $RGB(255, 0, 255)
mov xxx, $RGB(dh, byVar, al)

And you should not mix immediate and reg/mem.
So, this doesn't work:

;mov xxx, $RGB(dh, byVar, 255)
Posted on 2002-07-06 06:25:03 by Four-F
E?in, there are several - it would be silly to put them all in one file. :grin:
Sorry, I have been really busy lately.
Posted on 2002-07-06 06:54:25 by bitRAKE
bitRAKE has posted some of his nice macros in the snippet library. Feel free to post yours in the macro section as well:


Posted on 2002-07-06 07:02:36 by Thomas
Have changed $IsByte & $RGB macros.
Now you can pass to $RGB any mixture of byte reg/mem and immediate ops.

So, this works fine:

mov xxx, $RGB(255, byVar, ah)

$RGB tryes to generate as possible optimized code.
Posted on 2002-07-07 09:02:06 by Four-F
I agree 100%. A dedicated macro file should be part of the MASM32 package. And it shoukd be "versioned" like windows.inc. Then posters can say "requires marcros.inc v7" or whatever. This way you can feel free to use your favorite macros when posting.

Also we will need to agree on some conventions - all upper/lower or mixed case etc. I like all lower case for macros. Hutch can choose (based on vote?) which ones to add to the file from time to time.
Posted on 2002-07-07 12:27:46 by gfalen