Re: A86: Re: #define (Assembly)


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

Re: A86: Re: #define (Assembly)




Assembly Studio 86 uses it's own assembler, and in many ways it's better
than tasm.  It uses tasm's .tab files (not sure if it supports all modifier
strings for opcodes, though...probably just the z80 ones).  The
documentation for the #define for it is below, and hopefully a little more
TI-86 oriented :)

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

#define Directive


Usage:

#define identifier[(argument, ...)] [definition-string]

Defines a macro; that is a keyword that is substituted by a given string
throughout the source file. All subsequent occurrences of identifier will be
replaced with definition-string. The format and usage of the directive are
exactly the same as in C/C++.

A #define without a definition-string removes occurrences of identifier from
the source file. The identifier remains defined and can be tested using the
#ifdef and #ifndef directives .

The definition-string argument can consist of constants, instructions,
directives, or any other valid assembly language components. One or more
white-space characters must separate token-string from identifier. This
white space is not considered part of the substituted text, nor is any white
space following the last token of the text. Everything up to the end of the
line is considered part of the definition-string. To include multiple
instructions in definition-string, use the backslash (\) to separate each
instruction. When the macro is expanded, each backslash will be treated as
the beginning of a new line.

The #define directive accepts an optional list of parameters that must
appear in parentheses for the creation of function-like macros. References
to the identifier after the original definition replace each occurrence of
identifier(argument, ...) with a version of the definition-string argument
that has the actual arguments substituted for formal parameters.

Formal parameter names appear in definition-string to mark the places where
actual values are substituted. Each parameter name can appear more than once
in definition-string, and the names can appear in any order. The number of
arguments in the call must match the number of parameters in the macro
definition. Liberal use of parentheses ensures that complicated actual
arguments are interpreted correctly.

The formal parameters in the list are separated by commas. Each name in the
list must be unique, and the list must be enclosed in parentheses. No spaces
can separate identifier and the opening parenthesis.

Note: Nested macros are not supported; definition-string is not parsed for
macro identifiers itself. This means that using an existing macro in
definition-string directly, or as an argument when calling, it will not
work.

Examples:

#define FileIncluded
; defines an identifier for conditional assembly

#define LABEL1_LO (Label1 & 255)
; causes all occurences of 'LABEL1_LO' in the source
; to be replaced with '(Label1 & 255)'

#define ADDMEM(ADDR, VALUE) ld a,(ADDR)\ add a,VALUE\ ld (ADDR),a
; A macro to add VALUE to memory location ADDR
; This line in the source file:
;    ADDMEM( _curRow, 2)
; would expand to look like this:
;    ld a,(_curRow)\ add a,2\ ld (_curRow),a



References: