[ << ] [ >> ]           [] [] [] [ ? ]

4 Mot Syntax Module

This chapter describes the Motorola syntax module, mostly used for the M68k and ColdFire families of CPUs, which is available with the extension mot.


4.1 Legal

This module is written in 2002-2024 by Frank Wille and is covered by the vasm copyright without modifications.


4.2 Additional options for this module

This syntax module provides the following additional options:

-align

Enables natural alignment for data (e.g. dc, ds) and offset directives (rs, so, fo).

-allmp

Makes all 35 macro arguments available. Default are 9 arguments (\1 to \9). More arguments can be accessed through \a to \z, which may conflict with escape characters or named arguments, therefore they are not enabled by default.

-cnop=<code>

Sets the two-byte code used for alignment padding with cnop in code sections. Defaults to 0x4e71 on M68k.

-devpac

Devpac-compatibility mode. Only directives known to Devpac are recognized.

-ldots

Allow dots (.) within all identifiers.

-localu

Local symbols are prefixed by '_' instead of '.'. For Devpac compatibility, which offers a similar option.

-nolocpfx

Disables local symbols to be recognized by their prefix (usually '.'). This allows global symbols to be defined with it. The '$' suffix for local symbols still works.

-phxass

PhxAss-compatibility mode. Only directives known to PhxAss are recognized.

-spaces

Allow whitespace characters in the operand field. Otherwise a whitespace would start the comment field there.

-warncomm

Warn about all lines, which have comments in the operand field, introduced by a whitespace character. For example in: dc.w 1 + 2.


4.3 General Syntax

Labels must either start at the first column of a line or have to be terminated by a colon (:). In the first case the mnemonic has to be separated from the label by whitespace (not required in any case, e.g. with the = directive). A double colon (::) automatically makes the label externally visible (refer to directive xdef).

Local labels are either prefixed by ’.’ or suffixed by ’$’. For the rest, any alphanumeric character including ’_’ is allowed. Local labels are valid between two global label definitions.

Otherwise dots (.) are not allowed within a label by default, unless the option ‘-ldots’ or ‘-devpac’ was specified. Even then, labels ending on .b, .w or .l can’t be defined.

It is possible to refer to any local symbol in the source by preceding its name with the name of the last previously defined global symbol: global_name\local_name. This is for PhxAss compatibility only, and is no recommended style. Does not work in a macro, as it conflicts with macro arguments.

Make sure that you don’t define a label on the same line as a directive for conditional assembly (if, else, endif)! This is not supported and leads to undefined behaviour.

Qualifiers are appended to the mnemonic, separated by a dot (if the CPU-module supports qualifiers). The operands are separated from the mnemonic by whitespace. Multiple operands are separated by comma (,).

In this syntax module, the operand field must not contain any whitespace characters, as long as the option ‘-spaces’ was not specified.

Comments can be introduced everywhere by the characters ; or *. The rest of the line will be ignored. Also everything following the operand field, separated by a whitespace, will be regarded as comment (unless ‘-spaces’ was given). Be careful with *, which is either recognized as the "current pc symbol" or as a multiplication operation in any operand expression

Example:

mylabel inst.q op1,op2,op3  ;comment

In expressions, numbers starting with $ are hexadecimal (e.g. $fb2c). % introduces binary numbers (e.g. %1100101). Numbers starting with @ are assumed to be octal numbers, e.g. @237. All numbers starting with a digit are decimal, e.g. 1239.


4.4 Directives

The following directives are supported by this syntax module (provided the CPU- and output-module support them):

<symbol> = <expression>

Equivalent to <symbol> equ <expression>.

<symbol> =.s <expression>

Equivalent to <symbol> fequ.s <expression>. PhxAss compatibility.

<symbol> =.d <expression>

Equivalent to <symbol> fequ.d <expression>. PhxAss compatibility.

<symbol> =.x <expression>

Equivalent to <symbol> fequ.x <expression>. PhxAss compatibility.

<symbol> =.p <expression>

Equivalent to <symbol> fequ.p <expression>. PhxAss compatibility.

align <bitcount>

Insert as many zero bytes as required to reach an address where <bitcount> low order bits are zero. For example align 2 would make an alignment to the next 32-bit boundary.

assert <expression>[,<message>]

Display an error with the optional <message> when the expression is false.

blk.b <exp>[,<fill>]

Equivalent to dcb.b <exp>,<fill>.

blk.d <exp>[,<fill>]

Equivalent to dcb.d <exp>,<fill>.

blk.l <exp>[,<fill>]

Equivalent to dcb.l <exp>,<fill>.

blk.q <exp>[,<fill>]

Equivalent to dcb.q <exp>,<fill>.

blk.s <exp>[,<fill>]

Equivalent to dcb.s <exp>,<fill>.

blk.w <exp>[,<fill>]

Equivalent to dcb.w <exp>,<fill>.

blk.x <exp>[,<fill>]

Equivalent to dcb.x <exp>,<fill>.

bss

Equivalent to section bss,bss.

bss_c

Equivalent to section bss_c,bss,chip.

bss_f

Equivalent to section bss_f,bss,fast.

cargs [#<offset>,]<symbol1>[.<size1>][,<symbol2>[.<size2>]]...

Defines <symbol1> with the value of <offset>. Further symbols on the line, separated by comma, will be assigned the <offset> plus the size of the previous symbol. The size defaults to 2. Valid optional size extensions are: .b, .w, .l, where .l results in a size of 4, the others 2. The <offset> argument defaults to the target’s address size (4 for M68k) when omitted.

clrfo

Reset stack-frame offset counter to zero. See fo directive.

clrso

Reset structure offset counter to zero. See so directive.

cnop <offset>,<alignment>

Insert as many padding bytes as required to reach an address which can be divided by <alignment>. Then add <offset> padding bytes. May fill the alignment- and padding-bytes with no-operation instructions for certain cpus. See option ‘-cnop’.

code

Equivalent to section code,code.

code_c

Equivalent to section code_c,code,chip.

code_f

Equivalent to section code_f,code,fast.

comm <symbol>,<size>

Create a common symbol with the given size. The alignment is always 32 bits.

comment

Starting with the operand field everything is ignored and seen as a comment. There is only one exception, when the operand contains HEAD=. Then the following expression is passed to the TOS output module via the symbol ’ TOSFLAGS’, to define the Atari specific TOS flags.

cseg

Equivalent to section code,code.

data

Equivalent to section data,data.

data_c

Equivalent to section data_c,data,chip.

data_f

Equivalent to section data_f,data,fast.

db <exp1>[,<exp2>,"<string1>",'<string2>'...]

Equivalent to dc.b for ArgAsm, BAsm, HX68, Macro68, ProAsm, etc. compatibility. Does not exist in PhxAss- or Devpac-compatiblity mode.

dc.b <exp1>[,<exp2>,"<string1>",'<string2>'...]

Assign the integer or string constant operands into successive bytes of memory in the current section. Any combination of integer and character string constant operands is permitted.

dc.d <exp1>[,<exp2>...]

Assign the values of the operands into successive 64-bit words of memory in the current section, using the IEEE double precision format when specifying them as floating point constants.

dc.l <exp1>[,<exp2>...]

Assign the values of the operands into successive 32-bit words of memory in the current section.

dc.p <exp1>[,<exp2>...]

Assign the values of the operands into successive 96-bit words of memory in the current section, using the Packed Decimal format when specifying them as floating point constants.

dc.q <exp1>[,<exp2>...]

Assign the values of the operands into successive 64-bit words of memory in the current section.

dc.s <exp1>[,<exp2>...]

Assign the values of the operands into successive 32-bit words of memory in the current section, using the IEEE single precision format when specifying them as floating point constants.

dc.w <exp1>[,<exp2>...]

Assign the values of the operands into successive 16-bit words of memory in the current section.

dc.x <exp1>[,<exp2>...]

Assign the values of the operands into successive 96-bit words of memory in the current section, using the IEEE extended precision format when specifying them as floating point constants.

dcb.b <exp>[,<fill>]

Insert <exp> zero or <fill> bytes into the current section.

dcb.d <exp>[,<fill>]

Insert <exp> zero or <fill> 64-bit words into the current section. <fill> may also be a floating point constant which is then written in IEEE double precision format.

dcb.l <exp>[,<fill>]

Insert <exp> zero or <fill> 32-bit words into the current section.

dcb.q <exp>[,<fill>]

Insert <exp> zero or <fill> 64-bit words into the current section.

dcb.s <exp>[,<fill>]

Insert <exp> zero or <fill> 32-bit words into the current section. <fill> may also be a floating point constant which is then written in IEEE single precision format.

dcb.w <exp>[,<fill>]

Insert <exp> zero or <fill> 16-bit words into the current section.

dcb.x <exp>[,<fill>]

Insert <exp> zero or <fill> 96-bit words into the current section. <fill> may also be a floating point constant which is then written in IEEE extended precision format.

dl <exp1>[,<exp2>...]

Equivalent to dc.l for ArgAsm, BAsm, HX68, Macro68, ProAsm, etc. compatibility. Does not exist in PhxAss- or Devpac-compatiblity mode.

dr.b <exp1>[,<exp2>...]

Calculates <expN> - <current pc value> and stores it into successive bytes of memory in the current section.

dr.w <exp1>[,<exp2>...]

Calculates <expN> - <current pc value> and stores it into successive 16-bit words of memory in the current section.

dr.l <exp1>[,<exp2>...]

Calculates <expN> - <current pc value> and stores it into successive 32-bit words of memory in the current section.

ds.b <exp>

Equivalent to dcb.b <exp>,0.

ds.d <exp>

Equivalent to dcb.d <exp>,0.

ds.l <exp>

Equivalent to dcb.l <exp>,0.

ds.q <exp>

Equivalent to dcb.q <exp>,0.

ds.s <exp>

Equivalent to dcb.s <exp>,0.

ds.w <exp>

Equivalent to dcb.w <exp>,0.

ds.x <exp>

Equivalent to dcb.x <exp>,0.

dseg

Equivalent to section data,data.

dw <exp1>[,<exp2>...]

Equivalent to dc.w for ArgAsm, BAsm, HX68, Macro68, ProAsm, etc. compatibility. Does not exist in PhxAss- or Devpac-compatiblity mode.

dx.b <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.b <exp>,0.

dx.d <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.d <exp>,0.

dx.l <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.l <exp>,0.

dx.q <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.q <exp>,0.

dx.s <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.s <exp>,0.

dx.w <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.w <exp>,0.

dx.x <exp>

Tries to allocate space in the DataBss portion of a code or data section. Otherwise equivalent to dcb.x <exp>,0.

echo <"string"|exp>[,<"string"|exp>]...

Prints one or more strings or expressions to stdout, terminated by a newline. Strings are identified by single- or double-quotes. In PhxAss-comapatibility mode only a single string can be printed.

einline

End a block of isolated local labels, started by inline.

else

Assemble the following lines if the previous if condition was false.

elseif

Same as else, for compatibility!

elif <exp>

This is a real else-if directive! Not supported by Devpac. It’s the same as else followed by if, but without the need for a matching endif directive. Avoids nesting.

end

Assembly will terminate with this line. The subsequent source text is ignored.

endif

Ends a section of conditional assembly.

endm

Ends a macro definition.

endr

Ends a repetition block.

<symbol> equ <expression>

Define a new program symbol with the name <symbol> and assign to it the value of <expression>. Defining <symbol> twice will cause an error.

<symbol> equ.s <expression>

Equivalent to <symbol> fequ.s <expression>. PhxAss compatibility.

<symbol> equ.d <expression>

Equivalent to <symbol> fequ.d <expression>. PhxAss compatibility.

<symbol> equ.x <expression>

Equivalent to <symbol> fequ.x <expression>. PhxAss compatibility.

<symbol> equ.p <expression>

Equivalent to <symbol> fequ.p <expression>. PhxAss compatibility.

erem

Ends an outcommented block. Assembly will continue.

even

Aligns to an even address. Equivalent to cnop 0,2.

fail <message>

Show an error message including the <message> string. Do not generate an output file.

<symbol> fequ.s <expression>

Define a new program symbol with the name <symbol> and assign to it the floating point value of <expression>. Defining <symbol> twice will cause an error. The extension is for Devpac-compatibility, but will be ignored.

<symbol> fequ.d <expression>

Equivalent to <symbol> fequ.s <expression>.

<symbol> fequ.x <expression>

Equivalent to <symbol> fequ.s <expression>.

<symbol> fequ.p <expression>

Equivalent to <symbol> fequ.s <expression>.

<label> fo.<size> <expression>

Assigns the current value of the stack-frame offset counter to <label>. Afterwards the counter is decremented by the instruction’s <size> multiplied by <expression>. Any valid M68k size extension is allowed for <size>: b, w, l, q, s, d, x, p. The offset counter can also be referenced directly under the name __FO.

idnt <name>

Sets the file or module name in the generated object file to <name>, when the selected output module supports it. By default, the input filename passed on the command line is used.

if <expression>

Conditionally assemble the following lines if <expression> is non-zero.

if1

Just for compatibility. Not really supported, as vasm parses a source text only once. Always true.

if2

Just for compatibility. Not really supported, as vasm parses a source text only once. Always false.

ifeq <expression>

Conditionally assemble the following lines if <expression> is zero.

ifne <expression>

Conditionally assemble the following lines if <expression> is non-zero.

ifgt <expression>

Conditionally assemble the following lines if <expression> is greater than zero.

ifge <expression>

Conditionally assemble the following lines if <expression> is greater than zero or equal.

iflt <expression>

Conditionally assemble the following lines if <expression> is less than zero.

ifle <expression>

Conditionally assemble the following lines if <expression> is less than zero or equal.

ifb <operand>

Conditionally assemble the following lines when <operand> is completely blank, except for an optional comment.

ifnb <operand>

Conditionally assemble the following lines when <operand> is non-blank.

ifc <string1>,<string2>

Conditionally assemble the following lines if <string1> matches <string2>.

ifnc <string1>,<string2>

Conditionally assemble the following lines if <string1> does not match <string2>.

ifd <symbol>

Conditionally assemble the following lines if <symbol> is defined.

ifnd <symbol>

Conditionally assemble the following lines if <symbol> is undefined.

ifmacrod <macro>

Conditionally assemble the following line if <macro> is defined.

ifmacrond <macro>

Conditionally assemble the following line if <macro> is undefined.

ifp1

Just for compatibility. Equivalent to if1.

iif <expression> <statement>

Conditionally assemble the <statement> following <expression>. IIF stands for Immediate IF. If the value of <expression> is non-zero then <statement> is assembled. No ENDC must be used in conjunction with this directive. The <statement> cannot include a label, but a label may precede the IIF directive. For example:

foo IIF bar equ 42

The foo label will be assigned with 42 if bar evaluates to true, otherwise foo will be assigned with the current program counter. Assigning a value in the IIF <statement> using the equal (=) operator, while the option ‘-spaces’ was given, cannot work, because the equal operator will be evaluated as part of the expression. I.e. foo IIF 1+1 = 42 works, but foo IIF 1 + 1 = 42, when the option ‘-spaces’ was specified, won’t, as = 42 is evaluated as part of the expression.

incbin <filename>[,<offset>[,<length>]]

Inserts the binary contents of <filename> into the object code at this position. When <offset> is specified, then the given number of bytes will be skipped at the beginning of the file. The optional <length> argument specifies the maximum number of bytes to be read from that file.

incdir <path>

Add another path to search for include files to the list of known paths. Paths defined with ‘-I’ on the command line are searched first.

include <filename>

Include source text of <filename> at this position. When the file name specified has no absolute path, then search it in all defined paths in the order of occurrence, starting with the current work directory.

inline

Local labels in the following block are isolated from previous local labels and those after einline.

list

The following lines will appear in the listing file, if it was requested.

llen <len>

Set the line length in a listing file to a maximum of <len> characters. Currently without any effect.

local

Separates two blocks of local labels. Which means, local labels from above this directive may be reused.

macro <name>

Defines a macro which can be referenced by <name>. For compatibility, the <name> may alternatively appear on the left side of the macro directive, starting on the first column. Then the operand field is ignored. The macro definition is terminated by an endm directive. When calling a macro you may pass up to 9 arguments, separated by comma. These arguments are referenced within the macro context as \1 to \9. Parameter \0 is set to the macro’s first qualifier (mnemonic extension), when given. In Devpac- and PhxAss-compatibility mode, or with option ‘-allmp’, up to 35 arguments are accepted, where argument 10-35 can be referenced by \a to \z. In case you have a macro argument which contains commas or spaces you may enclose it between < and > characters. A > character may still be included by writing >>, or when embedded within a string. (Note that strings are ignored in Devpac compatibility mode.)

Special macro parameters:

\@

Insert a unique id, useful for defining labels. Every macro call gets its own unique id.

\@!

Push the current unique id onto a global id stack, then insert it.

\@?

Push the current unique id below the top element of the global id stack, then insert it.

\@@

Pull the top element from the global id stack and insert it. The macro’s current unique id is not affected by this operation.

\#

Insert the number of arguments that have been passed to this macro. Equivalent to the contents of the symbol NARG.

\?n

Insert the length of the n’th macro argument.

\.

Insert the argument which is selected by the current value of the CARG symbol (first argument, when CARG is 1).

\+

Works like \., but increments the value of CARG after that.

\-

Works like \., but decrements the value of CARG after that.

\<symbolname>

Inserts the current decimal value of the absolute symbol symbolname.

\<$symbolname>

Inserts the current hexadecimal value of the absolute symbol symbolname, without leading $.

mexit

Leave the current macro and continue with assembling the parent context. Note that this directive also resets the level of conditional assembly to a state before the macro was invoked; which means that it also works as a ’break’ command on all new if directives.

msource on/off

Enable or disable source level debugging within a macro context. It can be used before one or more macro definitions. When off, the debugger will show the invoking source text line instead. Defaults to on. Also numeric expressions like 0 or 1 are allowed. Note, that this directive currently only has a meaning when using the ‘-linedebug’ option with the hunk-format output module (‘-Fhunk’).

nolist

This line and the following lines will not be visible in a listing file.

nopage

Never start a new page in the listing file. This implementation will only prevent emitting the formfeed code.

nref <symbol>[,<symbol>...]

Flag <symbol> as externally defined, similar to xref, but also indicate that references can be optimized to base-relative addressing modes, when possible. This directive is only present in PhxAss-compatibility mode.

odd

Aligns to an odd address. Equivalent to cnop 1,2. Bugs: Note that this is not a real odd directive, as it wastes two bytes when the address is already odd.

offset [<expression>]

Switches to a special offset-section, similar to a section directive, although its contents is not included in the output. Its labels may be referenced as absolute offset symbols. Can be used to define structure offsets. The optional <expression> gives the start offset for this section. When missing, the last offset of the previous offset-section is used, or 0. <expression> must evaluate as a constant!

org <expression>

Sets the base address for the subsequent code. Note that it is allowed to embed such an absolute ORG block into a section. Return to relocatable mode with any new section directive. Although, in Devpac compatibility mode the previous section will stay absolute.

output <name>

Sets the output file name to <name> when no output name was given on the command line. A special case for Devpac-compatibility is when <name> starts with a '.' and an output name was already given. Then the current output name gets <name> appended as an extension. When an extension already exists, then it is replaced.

page

Start a new page in the listing file (not implemented). Make sure to start a new page when the maximum page length is reached.

plen <len>

Set the page length for a listing file to <len> lines. Currently ignored.

printt <string>[,<string>...]

Prints <string> to stdout. Every additional string into a new line. Quotes are optional.

printv <expression>[,<expression>...]

Evaluate <expression> and print it to stdout out in hexadecimal, decimal, ASCII and binary format.

public <symbol>[,<symbol>...]

Flag <symbol> as an external symbol, which means that <symbol> is visible to all modules in the linking process. It may be either defined or undefined.

popsection

Restore the top section from the internal section-stack and activate it. Also refer to pushsection.

pushsection

Pushes the current section onto an internal stack, where it may be restored from by the popsection directive.

rem

The assembler will ignore everything from encountering the rem directive until an erem directive was found.

rept <expression>

Repeats the assembly of the block between rept and endr <expression> number of times. <expression> should be positive. Negative values are regarded like 0. The internal symbol REPTN always holds the iteration counter of the inner repeat loop, starting with 0. REPTN is -1 outside of any repeat block.

rorg <expression>[,<fill>]

Sets the program counter to an offset relative to the start of the current section, as defined by <expression>. The new program counter (section offset) must not be smaller than the current one. Any space will be padded by the optional <fill> value, or zero.

<label> rs.<size> <expression>

Works like the so directive, with the only difference that the offset symbol is named __RS.

rseven

Align the structure offset counter (__RS) to an even count.

rsreset

Equivalent to clrso, but the symbol manipulated is __RS.

rsset <expression>

Sets the structure offset counter (__RS) to <expression>. See rs directive.

section <name>[,<sec_type>][,<mem_type>]

Starts a new section named <name> or reactivates an old one. <sec_type> defines the section type and may be code, text (same as code), data or bss. If the selected output format does not support section names (like "aout", "tos" or "xfile"), then a missing <sec_type> argument makes vasm interpret the first argument, <name>, as section type instead. Otherwise a missing <sec_type> defaults to a code section with the given name. The optional <mem_type> has currently only a meaning for the hunk-format output module and defines a 32-bit memory attribute which specifies where to load the section. <mem_type> is either a numerical constant or one of the keywords chip (for Chip-RAM) or fast (for Fast-RAM). Optionally it is also possible to attach the suffix _C, _F or _P to the <sec_type> argument for defining the memory type.

<symbol> set <expression>

Create a new symbol with the name <symbol> and assign the value of <expression>. If <symbol> is already assigned, it will contain a new value from now on.

setfo <expression>

Sets the structure offset counter (__FO) to <expression>. See fo directive.

setso <expression>

Sets the structure offset counter (__SO) to <expression>. See so directive.

showoffset [<text>]

Print current section offset (or absolute address) to the console, preceded by the optional <text> (may use quotes). PhxAss compatibility. Do not use in new code.

<label> so.<size> <expression>

Assigns the current value of the structure offset counter to <label>. Afterwards the counter is incremented by the instruction’s <size> multiplied by <expression>. Any valid M68k size extension is allowed for <size>: b, w, l, q, s, d, x, p. The offset counter can also be referenced directly under the name __SO.

spc <lines>

Output <lines> number of blank lines in the listing file. Currently without any effect.

text

Equivalent to section code,code.

ttl <name>

Devpac/PhxAss syntax. Set current page title for the listing file.

<name> ttl

Motorola syntax. Set current page title for the listing file.

weak <symbol>[,<symbol>...]

Flag <symbol> as a weak symbol, which means that <symbol> is visible to all modules in the linking process, but may be replaced by any global symbol with the same name. When a weak symbol remains undefined its value defaults to 0.

xdef <symbol>[,<symbol>...]

Flag <symbol> as a global symbol, which means that <symbol> is visible to all modules in the linking process. See also public.

xref <symbol>[,<symbol>...]

Flag <symbol> as externally defined, which means it has to be imported from another module into the linking process. See also public.


4.5 Known Problems

Some known problems of this module at the moment:


4.6 Error Messages

This module has the following error messages:


[ << ] [ >> ]           [] [] [] [ ? ]