Hey! I thought I should learn to use & write macros.

But were would one start to learn them.
Posted on 2003-09-25 12:24:53 by Tweak
Posted on 2003-09-25 12:28:31 by JimmyClif
thanks :alright:
Posted on 2003-09-25 12:41:35 by Tweak
Reinvent the wheel a couple of times to learn how it all comes together. Then move on to bigger stuf.

I will give you an early tip. You sometimes want to know whats going on with your macro code and need a way of outputing it states. Use the "echo" command.

Output text or text variable:

echo Text
%echo variable

To output a number from a macro variable is a little more complicated

temp TEXTEQU %numb_var
%echo temp

The way to see it in action is to use the compile. You will see their output as ml assembles everything.

Best of Luck (its a worth journey)
:NaN:
Posted on 2003-09-25 21:35:04 by NaN
I'm a little interested in this too.

The most complicated I got is some information dense textequ's.

The idea of abstraction in assem is very interesting to me. But I'm having trouble to understand how to apply macros to programming.

What can a macro do?(make types, make code)
What cant they do?

Where is a good place to use a macro?
Where is using a macro ineffecient(overkill)

I know some of this is learned by experience. Thank Nan for that tip. Any more appreciated.
Posted on 2003-09-26 02:15:44 by ThoughtCriminal
Most of my adventures stemmed from my desire for MASM Objects ;)

However, its definitely not limited here in uses.

Think of macros as little robot assembly coders. You write out a macro sript which directes them how to go about filling in the 'gaps' in you assembly source. They perform their function before the core of ML assembles the final source to binary.

Good example would be the $invoke() macro that I came up with eons ago. I visually wanted to make my source a little more readable from left to right (like HLL would). So i wipped this simple macro together:
$invoke MACRO args:REQ

invoke args
EXITM <eax>
ENDM


All it does is when it comes across this is breake the one line into two, doing the invoke first, and exit replacing the macro itself with the EAX register. Doing so makes things like this happen:

mov hDC, $invoke( GetDC, hWindow )

When automated, the macro will build:

invoke GetDC, hWindow
mov hDC, eax


Then when all macros are processed, it will pass this result to the core of ML.

I hope this helps :alright:
:NaN:
Posted on 2003-09-26 22:29:15 by NaN
Thanks. It does help.

A simple example of the thinking used to apply macros to a problem.

And a simple explantion of what the preprocessor does. I dont think the MASM manuals explain that part.
Posted on 2003-09-27 07:38:40 by ThoughtCriminal