Microsoft KB Archive/58864

= Using a Macro to Determine the Current Segment =

Article ID: 58864

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft Macro Assembler 5.1 Standard Edition
 * Microsoft Macro Assembler 5.1a

-



This article was previously published under Q58864



SUMMARY
The following macro can be used to determine the segment from which the macro is called during assembly of a source file.

In the following example, the &quot;findseg&quot; macro is called from within two individual segments named code1 and code2, respectively. The macro then uses IF statements to determine the segment. Then, depending upon the segment, any desired code can be assembled. findseg macro segname ifidn, ; if in segment code1 :               ; do what is desired endif

ifidn, ; if in segment code2 :               ; do what is desired endif endm                    ; end macro

findseg code1  ;macro call in segment code1 .                    .                     .          findseg code2   ;macro call in segment code2 Note that invoking the findseg macro with the @curseg equate as a macro argument will not yield a true condition for the ifidn expression. The value of &quot;segname&quot; is resolved to the string &quot;@curseg&quot; which, in the example, is identical to &quot;code1&quot;.

Additional query words: 5.10 5.10a

Keywords: KB58864

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.