The IBM PC MC6800, MC6801, MC6802, MC6808, MC68HC11 cross assembler
brief description
Actually this is cross assembler for MC68HC11. Because other processors
are subset of MC68HC11 (and generated code is same) you could use this
one to compile programs for all of them (avoid using instructions that
do not belong to particular processor).
Config file
By default _68 searches for MC68HC11.CFG in current directory
and if such file was not found then in start up directory.
If @ parameter is specified on command line
then searches only for specified file.
This file could contain parameters one at a line. Specifiy your
favorite parameters here.
For example:
******* MC68HC11.CFG *******
/l
/e
/dTEST
******* end of file *******
means that compiler will always generate listing and error
files. And symbol TEST for conditional compilation is defined.
Expressions:
Expressions may consist of symbols, constants or the character '*'
(denoting the current value of the program counter) joined together
by one of the operators: + - * / % & | ^ ~ ! \ <, >, <=, >=, =, <>, !=.
The operators are
Priority 1
() parenthesis
Priority 2
~ bitwise not (xor with $ffffffff)
! same as above (equals to ~)
Priority 3
* multiply
/ divide
% remainder after division
\ remainder after division (for compatibility reasons)
& bitwise and
Priority 4
+ add
- subtract
^ bitwise exclusive-or
| bitwise or
Priority 5
relations: <, >, <=, >=, =, <>, != (<> is equivalent to !=)
result is 0 = false, $ffffffff = true
Expressions are evaluated according to priority. Arithmetic is carried
out in signed twos-complement long integer precision (32 bits on the IBM PC).
In all numerical constants underscore could be used and compiler ignores it.
Constants are constructed with the following syntax:
Examples
Decimals
digits (optionally followed by '.') 123 2345. 65_536
Hexadecimal
Motorola style: preceded by '$' $1b $ffff_ffff
Intel style: followed by 'H' 1bH 0ffff_ffffh
C style: preceded by '0x' 0x1b 0xffffffff
Binary
Motorola style: preceded by '%' %101 %1011_1100
pseudo C style: preceded by '0i' 0i101 0i10111100
pseudo Intel: followed by 'I' 1i 1011_1100i
* Intel style: followed by 'B' 1b 1011_1100b
because this style is dangerous (one could forget $ sign
for example 1b instead of $1b) if you want to use this
style you should enable it by using "intelbin" pseudo-op.
Octal
Motorola Style: preceded by "@" @123 @232 @021
pseudo C style: preceded by "0o" or "0Q" 0o123 0q232 0Q021
Intel style: followed by O or Q 123q 0232Q 21o
! C style: not supported (0123 is not octal)
String & ASCII char
Pascal style but surrounded by ' or " 'ab''cd' "abcd" '--"--'
Identifiers: A string of characters with an initial non-digit.
The string of characters may be from the set:
[a-z][A-Z]_[0-9]
(_ count as non-digit). Only first 15 chars of identifier
are significant. Identifiers are case insensitive.
Label: A symbol starting in the first column is a label.
If it is followed by ':' then this is a global label.
Operand: Follows mnemonic, separated by at least one
whitespace character. The contents of the operand
field is interpreted by each instruction.
Whitespace: A blank or a tab
Comment: Any text that starts with ';' up to the end of line
Differences:
assembly instructions BSET, BCLR has the following syntax
BSET op1 #op2
BCLR op1 #op2
assembly instructions BrSET, BrCLR has the following syntax
BrSET op1 #op2, op3
BrCLR op1 #op2, op3
Note ',' separates op2 & op3. If you want to separate them only
with space (as is in as11) then first enable this feature by using
as11 pseudo op
following mnemonics could be used instead of standard one (see MC68HC11.prn)
CPA CPB CPD
LDA LDB LDD
ORA ORB
PHA PHB
PLA PLB
STA STB STD
XORA XORB
PHX PHY
PLX PLY
Indexed address mode. Any of following syntax could be used:
x, expression
expression, x
x
x+expression
x.expression
x[expression]
Conditional compilation
Implemented using pseudo-ops if/ifdef/ifndef/else/endif
.ifdef/ifndef xxxx
.else
.endif
or
.if expression
.else
.endif
.define XXX
.undef XXX
Include files
Implemented using pseudo-op INCLUDE
.include filename
Pseudo-OPs
Every pseudo-op could be preceded optionally by '.'. (Conditional
compilation too - you could use or could not use '.').
Following pseudo ops are implemented
PROC/ENDP - procedure definition
syntax:
label PROC
...
[label] ENDP
All labels from procedure's body are local, except that defined
using EQU, or labels followed by ':'.
It is not allowed to have local & global labels with same names.
example: see SECTION example 2. There are two local labels that
could be used again in other procedures.
SECTION/ENDS
Dummy section. Compiler does not generate code.
example 1:
section WorkArea
wrk_b db 0 ; work cell (byte)
wrk_w dw 0 ; work cell (word)
wrk_b1 ds 1 ; work cell (byte)
wrk_w2 ds 2 ; work cell (word)
; do not exceed WorkArea
error *-WorkArea > WorkAreaSize
ends
example 2:
section 0
next dw 0
id_number dw 0
data2 ds 123
ends
*************************************************
* import: X reg points to beginning of linked list
* D reg contains id_number to search
* export: X reg = 0 (if error) or
* contains ptr (if ok)
*
SearchNum proc
cpx #0
beq quit
loop
cmpd x.id_number
beq quit
ldx x.next
bne loop
quit rts
SearchNum endp
DB, DW, DD - define byte, word or double word
example: db 'This is example', 10, 0
dw 12*12 [22] ; 22 times 144
dd [22] 12*12 ; same as above but double words
DS - define space
example: DS 24 ; allocates 24 bytes of memory
DS 22, 144 ; 22 bytes of memory filled with 144
EQU - standard behaviour. Defines global symbol
= - equivalent to EQU
== - same as = but defines local symbol
ORG - standard behaviour
ERROR expression - user defined error if expression != 0
example: see SECTION example 1.
LIST on/off
TRUNC on/off - truncate long lines (try with listing on and DB '........')
INTELBIN on/off - enable (disable) usage of Intel style format bin constants
Other pseudo-ops
LSB (= DB), MSB, DWP (= DW), DWN, DDP (= DD), DDN, CHECKSUM
as11 compatibility
FCC (= DB), FCB (= DB), FDB (= DW), RMB (= DS)
AS11 on/off (enable space as separator in BrSET, BrCLR mnemo)