Re: A86: Re: #define (Assembly)


[Prev][Next][Index][Thread]

Re: A86: Re: #define (Assembly)




this is from the documentation for tasm, but hopefully asm studio is the
same (or uses tasm)

-josh


DEFINE. The DEFINE directive  is one of the  most powerful of the 
directives
and allows string substitution with optional arguments (macros).  The 
format
is as follows:

    #DEFINE  macro_label[(arg_list)]  [macro_definition]

    macro_label := string to be expanded when found in the source file.
                  
    arg_list    := optional argument list for variable substitution
                  
    macro_def   := string to replace the occurrences of macro_label in
                            the source file.

The simplest form of the DEFINE directive might look like this:

        #DEFINE         MLABEL

Notice that  no  substitutionary string  is  specified.   The  purpose 
of  a
statement like this would typically be to  define a label for the purpose
 of
controlling some subsequent conditional assembly (IFDEF or IFNDEF).

A more complicated example, performing  simple substitution, might look 
like
this:

        #DEFINE         VAR1_LO         (VAR1 & 255)

This statement would cause all occurrences of  the  string  'VAR1_LO' in 
the
source to be substituted with '(VAR1 & 255)'.

As   a   more   complicated   example,    using   the   argument   
expansion
capability, consider this:

        #DEFINE         ADD(xx,yy)      clc\ lda xx\ adc yy\ sta xx

If the source file then contained a line like this:

        ADD(VARX,VARY)

It would be expanded to:

        clc\ lda VARX\ adc VARY\ sta VARX

The above  example shows  the use  of the  backslash ('\')  character  
as  a
multiple   instruction    statement  delimiter.   This  approach  allows 
the
definition of fairly  powerful,   multiple statement   macros.   The 
example
shown generates 6502 instructions to add one memory location to another.

Some rules associated with the argument list:

1.  Use a maximum of 10 arguments.

2.  Each argument should be a maximum of 15 characters.

Note that macros can be defined on the TASM command line, also, with the
'-d'
option flag.

DEFCONT. This directive can be used to  add to the last macro started
with  a
DEFINE directive.   This  provides a  convenient way  to define  long 
macros
without running off the edge of the page. The ADD macro shown above could
 be
defined as follows:

        #DEFINE         ADD(xx,yy)     clc
        #DEFCONT                     \ lda xx
        #DEFCONT                     \ adc yy
        #DEFCONT                     \ sta xx


On Wed, 21 Apr 1999 21:41:24 -0400 Chris Magill <v8r@juno.com> writes:
> Where can I get more information on exactly what you can do with a
>#define directive....
>
>Thanks,
>
>Chris
>
>
___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]


Follow-Ups: