28.11.2012 Views

Table of Contents - TG Drives

Table of Contents - TG Drives

Table of Contents - TG Drives

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

38<br />

Multiline Macro<br />

MACRO DEFINITION<br />

PL2 NATIVE POSITION LANGUAGE<br />

A macro definition needs information regarding the type <strong>of</strong> the argument, with an<br />

arg-specifier placed after each argument.<br />

Format:<br />

.MACRO<br />

.MACRO foo [,sym:arg-specifier] [,nn:as] [; Comment]<br />

[lab:] [macro body]<br />

.ENDMACRO [; Comment]<br />

The macro body specifies what operation the “new instruction” will perform when<br />

invoked (macro expansion). Standard native instructions or other macros can be<br />

used and the nesting depth <strong>of</strong> a macro calling another macro is limited only by the<br />

amount <strong>of</strong> available memory. Macro recursion is not allowed and generates an<br />

error message.<br />

Names <strong>of</strong> labels within the macro body can be used freely. Each macro maintains<br />

its own symbol table. This means that symbols defined in the program scope are<br />

not accessible within a macro definition.<br />

Example:<br />

.DEFINE foo = 4711 ; The symbol has program scope<br />

.MACRO bar, foobar:v<br />

LET r0, foo ; This will generate an error, foo is undefined<br />

.ENDMACRO<br />

In the list file, any label used within a macro definition ends with the ($) symbol<br />

instead <strong>of</strong> the standard colon (:) symbol.<br />

NOTE: It is possible to use the absolute label format in a macro definition, but there<br />

can only be one within the macro. For a second occurrence within the macro, the<br />

compiler generates a “previous line overwritten” error message.<br />

MACRO ARG SPECIFIERS<br />

Arg specifiers are divided into 8 categories<br />

No Symbol Description NOTE<br />

1 r General register type, Reg, XReg, or IRreg.<br />

2 v General value type, i32 or i16.<br />

3 lrf General line reference.<br />

4 i32 Long value.<br />

5 i16 Short value. Not impl.<br />

6 reg Ordinarily register.<br />

7 ireg Index register.<br />

8 xreg Extended register.<br />

Valid arg-specifiers for DMC 2 compilers are all those that are implemented.<br />

User's Manual 5.1 Inmotion Technologies AB<br />

Doc. No.9032 0027 01 (B), Rev. 11.07.2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!