In MASM manuals I can see that subj is possible
(I assume it should work as exitm %value in regard of
usage the retvalue generated by macro)
yet I failed to make any use of it.
ml doens't mind if I write something like

endm %statement
yet I can not use the return from it in any expression.
Could someone help me out and show if
it's possible to use such a construction in an example?
Posted on 2003-07-26 20:46:48 by The Svin
Are you shure? I couldn't find such syntax in masm docs. Only endm without param.
Posted on 2003-07-27 03:05:16 by Four-F
Yes, here is qoute:
name MACRO []]]...

statements

ENDM []
Posted on 2003-07-27 03:36:37 by The Svin
I see. I'm sure it's erratum.
Posted on 2003-07-27 08:46:25 by Four-F
The why ml doesn't inform me of the error
when I type something after endm?
somemac macro par1
echo par1
endm par1

Echo works OK, so the macro works and no error about
about endm par1?
Posted on 2003-07-27 13:51:23 by The Svin
I use ml.exe 6.15.8803 and the doc was supplied with it.
Might be it can help somehow?
Posted on 2003-07-27 15:41:40 by The Svin
It appears MASM ignores everything after the ENDM until the end of line. Same as the multi-line COMMENT directive:
COMMENT ~


~ MASM ignores this text until the end of the line...
I wouldn't be surprised to find similar "holes" in the syntax. In the case of ENDM [] the manual is in error. Similarly, MASM ignores line of text after EXITM:
MyMACRO MACRO

EXITM

maybe type some documentation here?

ENDM
MASM is funny like this. :)
Posted on 2004-01-23 18:30:48 by bitRAKE
Yes it's funny :)
Last two things I noticed was:
1. It doesn't differ base and index in pointer and
always codes and with as base.
That's 1 byte longer compare with case when ebp placed in index field.
Solution is to write DS: in the case it places reg code for ebp in index field of SIB wich results in 1 byte shorter instruction.
But the method doesn't work with lea - no matter whether you wrote lea eax, or lea eax,DS: - masm always places code for ebp in base field and makes it 1 byte longer.
It forced to write macro wich places code for ebp in index field with lea.
2. $ operator returns invalid counter when reffers to labels inside code used "invoke" "proc" etc.
Posted on 2004-01-24 00:10:35 by The Svin
The Svin,
You won't get very far with ENDM <var> . Try EXITM <var> instead. You are defining a MACRO FUNCTION instead of a plain MACRO. See example in ZIP file. Ratch
Posted on 2004-01-24 10:47:45 by Ratch
The Svin,

Last two things I noticed was:
1. It doesn't differ base and index in pointer and
always codes and with as base.
That's 1 byte longer compare with case when ebp placed in index field.


Could you post an example of the correct code and the incorrect code so I can understand what the problem is? Thanks, Ratch
Posted on 2004-01-24 11:09:15 by Ratch
The Svin,
OK, now I understand what you are saying. Easy solution. Always code the index with 1*REG. This tells MASM explicitly what the index register is. Ratch.



00000000 8D 44 0D 00 LEA EAX,[ECX+EBP]
00000004 8D 04 29 LEA EAX,[EBP+ECX]
00000007 8D 04 29 LEA EAX,[ECX+1*EBP]
0000000A 8D 44 0D 00 LEA EAX,[EBP+1*ECX]
0000000E 8D 04 69 LEA EAX,[ECX+2*EBP]
00000011 8D 44 4D 00 LEA EAX,[EBP+2*ECX]
00000015 8D 04 69 LEA EAX,[2*EBP+ECX]
00000018 8D 44 4D 00 LEA EAX,[2*ECX+EBP]
Posted on 2004-01-24 11:41:24 by Ratch
Thanks. That's easier than using macro.
Posted on 2004-01-24 23:51:47 by The Svin

The Svin,
You won't get very far with ENDM <var> . Try EXITM <var> instead. You are defining a MACRO FUNCTION instead of a plain MACRO. See example in ZIP file. Ratch

I know about EXITM and heavily use it.
Orignal question was about MASM docs where incorrectly stated that the same method can be used with ENDM <value>
Posted on 2004-01-24 23:54:37 by The Svin