Motorola Assembly Input Standards
Motorola Assembly Input Standards
Motorola Assembly Input Standards
PROPOSAL:
This specification proposes to define an assembly language input standard for Motorola 8- and
16-bit microcontrollers. In essence, this is a framework so that any compliant assembly language
tool that generates MCU machine code can assemble either compiler-generated code or human
developed code from any other compliant tool.
BACKGROUND:
The need for this specification arose from a meeting held at the November, 1998 Embedded
Systems Conference where a number of third-party suppliers asked Motorola to develop an
assembly language input standard. Currently each supplier follows a structure that each has
developed independent of the others.
IMPACT:
Given the number of years Motorola MCUs have been on the market and the number of
assemblers that are also on the market, changing the assemblers to meet the standard may incur
some engineering costs that the market may not bear. The technical impact may not be that great
but this depends on how close a supplier’s assembler is to the proposed specification.
Document #1001
Version 1.0
SPECIFICATION FOR
Motorola 8- and 16-Bit ASSEMBLY LANGUAGE INPUT
STANDARD
26 October, 1999
2. SCOPE................................................................................................................................................................ 5
3. LIMITATIONS.................................................................................................................................................. 5
4. REFERENCED DOCUMENTS....................................................................................................................... 6
5. TERMINOLOGY.............................................................................................................................................. 6
6. CONVENTIONS ............................................................................................................................................... 8
7. OVERVIEW ...................................................................................................................................................... 9
1. PURPOSE
This specification defines a standard source code format for assemblers of Motorola 8-bit and
16-bit microcontroller machine code. See the appendixes for the Motorola MCUs covered by
this specification. This source code format is intended for use with either human developed or
compiler generated assembly source code.
Motorola microcontroller software developers using this standard shall be able to substitute
compliant assemblers without modifying their code. This specification encompasses a complete
set of features necessary for a macro assembler. The assembly code shall, by default, be case
sensitive except where indicated since C compilers generate case-sensitive code.
2. SCOPE
This standard is a generalized format for assembly language source code. This standard is a
basic format, which encompasses the major functions of a macro assembler but does not prevent
individual suppliers from including enhanced features to suit unique customer needs. All code
written according to this standard shall assemble on any compliant assembler but all code that is
written for any given assembler need not comply with the standard.
3. LIMITATIONS
This standard applies to Motorola’s 8- and 16-bit microcontrollers See the appendixes for the
MCUs covered by this specification. It is intended that both software suppliers and developers
use this standard. Motorola invites suppliers to use the standard as a set of minimum
requirements for their assemblers. Motorola recommends that developers use this standard as a
guideline for writing code, which can be easily ported from one assembler to another.
3.1. EXTENSIONS
Suppliers may augment their assemblers with extensions. Extensions may require additional
directives or features not defined in this standard. These extensions may or may not be portable.
4. REFERENCED DOCUMENTS
[1] M68HC05 Applications Guide, M68HC05AG/AD 3.0, Motorola
[2] 68CPU08 Reference Manual, CPU08RM/AD 2.0, Motorola
[3] M68HC11 Reference Manual, M68HC11RM/D 3.0, Motorola
[4] 68HC12 CPU12 Reference Manual, CPU12RM/AD 1.0, Motorola
[5] 68CPU16 Reference Manual, CPU16RM/AD 1.0, Motorola
[6] ISO/IEC 14977: 1996(E)
5. TERMINOLOGY
5.7. DATA - binary information for a program generated from assembler directives.
5.8. DIRECTIVE – is a command placed in the assembly source file to tell the assembler
to take an action based on the content of the command.
5.9. EOL - end of line, in source files, a character or a sequence of characters that defines
the standard end-of-line sequence for the local operating system. Depending on the
system, the end-of-line sequence can be a return, a line feed, or return and a line feed.
5.10. INPUT STREAM - source code with include files inserted, macros expanded, and
conditional assembly paths determined.
5.13. LINKER – is a tool that accepts relocatable object files from a relocatable assembler.
This tool usually combines relocatable objects and resolves machine instruction addresses
into actual addresses to create the final binary executable code.
5.16. MACHINE CODE – is machine instructions and associated data contained in the
microcontroller memory.
5.19. NEWLINE - 1. [tech-speak, primarily UNIX] the ASCII LF character (0001010), used
under UNIX as a text line terminator. A bell-labs-ism rather than a Berkeley-ism;
interestingly (and unusually for UNIX jargon), it is said to have originally been an IBM
usage. (Though the term `newline' appears in ASCII standards, it never caught on in the
general computing world before UNIX). 2. More generally, any magic character,
character sequence, or operation (like Pascal's writeln procedure) required to terminate a
5.22. PORT - to make source code written for one assembler readable by another.
5.23. RELOCATABLE - all values are relative to the beginning of a code or data section.
5.27. SOURCE FILE - the file containing the source code for an assembler.
5.28. WHITESPACE - one or more blanks (ASCII code 32) ($20) or horizontal tabs
(ASCII code 9) ($09) in any order used to separate symbols, and to make programs easier
for humans to read.
6. CONVENTIONS
The syntax of the assembler is defined using Backus-Naur Form (BNF). The Backus-Naur Form
(BNF) is a convenient and widely accepted means for writing down the grammar of a context-
free language. Context-free grammars are frequently used to specify programming languages,
operating system commands, and other types of computer input. Numerous variants of BNF
have been introduced and practically every compiler-design textbook and programming-
language standard defines its own version.
6.3. OPERATORS
The table below summarizes the EBNF operators used in the grammar throughout this standard.
Expression Description
expr ::= expr1 Assignment, replace expr with expr1
on | off Alternative, on or off
(argl | arg2 | arg3) Select exactly one of the alternatives from within the parentheses
arg [,arg] Optional, items in the square brackets [ ] are optional
a-z Range, in the range from a to z
[space]+ Repeat, one or more space
6.4. KEYWORDS
Bold Italics indicates a directive keyword.
7. OVERVIEW
The remainder of this standard describes the language and functional requirements for a
compliant assembler. Section 1 describes the purpose of the standard. Section 8 details the
assembly language format for the standard. Section 9 outlines the instruction formats used for 8-
and 16-Bit Motorola Controllers. The appendixes outline the reserved identifiers used for
8.1. INTRODUCTION
This standard specifies a set of statement formats, macro formats, section requirements,
assembly language directives, and operators, which all compliant assemblers shall recognize.
8.2. INPUTS
This section outlines all the syntax and functionality of the assembler inputs. All compliant
assemblers must accept one or more input files. Refer to section 10 for further information about
the grammars included in the following sections.
NOTE: It is strongly recommended that each supplier make their assemblers recognize the
extended ASCII character set (decimals 0 - 255) to make more code portable.
8.2.3. Comments
A comment is text that is not assembled. It is merely for annotation of line or section of code for
human readability.
comment ::= [whitespace] [; text]
| [whitespace]
• A line containing only whitespace shall be treated as a comment.
• A line containing only an EOL shall be treated as a comment.
• Any text following a (;) shall be treated as a comment.
8.2.6. Sections
A section is an atomic contiguous unit representing a memory region in the Motorola
microcontroller architecture. Every assembly language source file, including those produced by
a compiler, defines one or more sections. See section 8.2.13.15 for BNF.
• Sections can be anonymous, with only an absolute start address, or can be named using
the section directive.
• Named sections can be absolute, that is, given an absolute start address, or relocatable.
• Relocatable sections shall be given an actual start address at link time.
• Sections are units of relocation.
• Sections in compiler source files shall have the characteristics outlined in this section.
8.2.7. Expressions
Expressions are equations consisting of symbols, constants and operators. A compliant
assembler is not required to support complex_relocatable_expression. However, they are
included here to help clarify the difference between the kind of expression. If there are
whitespace characters in expressions they are ignored. The whitespace is there only for
readability by humans.
expression ::= absolute_expression
| simple_relocatable_expression
| complex_relocatable_expression
• An expression shall evaluate to at least 32 significant bits.
• Signed arithmetic shall be used.
8.2.8. Symbols
A symbol is a tag for an expression. A label is a mechanism for defining symbols. Symbols only
have attributes such as their section number or they may be either external or static. Reserved
identifiers may not be used as symbols.
8.2.8.1. Labels
Labels are used to define symbols. Statement lines begin with a label field, which the
programmer may use to symbolically refer to the memory location of the instruction being
assembled. Labels must end with a colon character (the colon does not become part of the label).
8.2.9. Constants
Constants shall not vary from the point that they are first defined throughout the assembly
process.
8.2.10. Operators
Compliant source code may contain the following operators:
Description Associativity
() Parenthesis Right to Left
< Force direct address, index or immediate value to 8-bits Right to Left
> Force extended address, index or immediate value to 16- Right to Left
bits
page Access 8-bit page number from bits 16-23 of 24-bit value Right to Left
*/% Multiplication, Division, Modulus Left to Right
~+- One's Complement, Unary Plus, Unary Minus Right to Left
+- Binary Addition, Binary Subtraction Left to Right
<< Shift Left, Left to Right
>> Shift Right
== != Equal To, Not Equal To Left to Right
< <= Less Than, Less Than Equal, Left to Right
> >= Greater Than, Greater Than Equal Left to Right
& Bitwise And Left to Right
^ Bitwise Exclusive Or Left to Right
8.2.11. Instructions
Instructions for Motorola Microcontrollers shall conform to the formats given in their respective
Reference Manuals referenced in Section 4. All instruction formats are listed in section 9.
9. INSTRUCTION FORMATS
The format for machine instruction mnemonics is outlined below.
10.2. NOTATION
The grammar is implemented in Extended Backus Naur Form (EBNF). The notation used is
defined in paragraph 1.5.
10.4. GRAMMAR
characters ::= character
| character characters
statement ::= comment EOL
| [label] comment EOL
| [label | whitespace] instruction comment
| [label | whitespace] directive comment EOL
| label labeled_directive comment EOL
| [whitespace] unlabeled_directive comment EOL
whitespace ::= [space | tab]+
comment ::= [whitespace] [; text]
| [whitespace]
text ::= printable_character
| printable_character text
label ::= [whitespace] symbol: [whitespace]
unlabeled directive ::= if whitespace absolute_expression
| else
| elseif whitespace absolute_expression
| endif
| include whitespace string_constant