6X Assemblers

Cross-assembler
Configuration
Command line options
File extensions
Example
Assembler language
Elements of the language
Program structure
Declarations of constants
Declarations of data (strings, translate tables, arrays, memory space)
Multifile support
Exporting symbols
Listing directives
Addressations
Addressations for MC6805 microcontroller
Forced extended addresation
Cross-Reference generator
HEX Convertor
Return codes

Cross-assembler
 
Configuration
IBM PC with 640k RAM, MS-DOS, 1MB free disk space
Command line options
Command line
6805 [options...] input files [options]
Options and input files can be mixed on command line. All options must be preceded with or -.
Input files

All program files use 8.3 file naming convention. Allowable extensions are .ASM, .S or .I The last one is provided because several C preprocessors output .I files. A file name preceded with @ is a file list with names of source files. Each line of this file has following format:

filename[,list option]
where list option is one of list, nolist. Lines which begin with * or ; or ! are comments.

Output files
-Foassembled file name - gives the name of the output file with compiled program and additional information (BNR file). If ommited the output file gets the name of first source file but with BNR extension.
-Fs[source listing file] - causes source listing to be generated. If no file name is given the name of first source file is used but LST extension is applied.
-Fx[CRF-cross-reference file] - generates cross reference file (not human readable). If no file name is given the name of
first source file is used but the extension is CRF.
HREF utility is needed to convert it to ASCII format REF file.
-FX - generates human readable cross-reference file. The file name is always the name of first source file but with REF extension.

Optimization
-Ob - disable branch optiomization. Disables relative jumps optimization and jmp <--> bra replacements
-Oe - optimize instructions with ,e

Language
-Zc - case insensitive keywords & instructions (normal these are lowcase)
-Ze - extern directive ingnored
-Zg - generate define/extern files
-Zi - generate symbolic debugging information in BNR file
-Zr - enable exporting
-Zs - syntax check only

Source listing
-Sc - case insensitive sorting of map tables
-Sf - disable form-feed in listing
-Slcolumns - set line width (default 86)
-Sn - no page headers
-Sp - set page length (default 63)
-Su - unreferenced identifiers at the end
-Sv - symbol sorting by value (default by name)
-Sx - no symbol sorting
-s - silent assembling (no screen output)
-Vlevel - level of detailed listing (level = 0,1,2; default is 1)

Miscelaneous
-Aaddress - highest memory address
-H,-h,-? - command line help
-k - keep temporary files
-nologo - suppress logo screen
-Wlevel - warning level (level = 0,1,2,3; default is 1)

top

File Extensions
ASM, S, I - source files
BNR - compiled file, that contains assembled program and additional information
DEF - global definition file
EXT - external definition file
DTF - absolute code, converted to ASCII format S19, S28 or binary image
D?? - absolute code, section by section
CRF - compressed cros-reference file
REF - ASCII text cross-reference file
 

Assembler language
 
Elements of the language
Symbols
Small and CAPITAL latin letters, digits 0 - 9, ( ) _ ; , : $ # " @ ' + - * / % < > = ! & ^ ~
Numbers
Four systems are allowable, the default one is decimal and there is not directive to set another default radix. Maximal value of a number depends on context.
System Prefix Digits Comment
binary 0b 0 1  
octal 0o 0 1 2 3 4 5 6 7  
octal no prefix 0 1 2 3 4 5 6 7 must begin with 0
decimal no prefix 0 1 2 3 4 5 6 7 8 9 must not begin with 0
hexadecimal 0x 0 1 2 3 4 5 6 7 8 9 A B C D E F  
Strings
These are sequences of symbols enclosed with ". Everyone symbol can be placed between quotes with ASCII code from 1 to 255. Several special control symbols are coded as follows:
Symbol ASCII Code Symbol ASCII Code
" 34 \" CR 13 \r
\ 92 \\ TAB 9 \t
BELL 7 \a VT 11 \v
FF 12 \f anyone - \xnn
LF 10 \n
 
Identifiers
Identifiers consist from latin letters, decimal digits and _. They should begin with a letter. 6X assembler is case sensitive
so alpha and Alpha are not the same identifier. Maximal length of an identifier is 15 symbols. The symbols after 15th one are truncated.

Reserved names
These are names of the instructions and assembler directives. By default they are lowercase. One can use uppercase
instructions & directives with -Zc option. Assembler directives are listed in following table:
ascii asciz at base data1 data2 data4 define double dsect e equ
export extern fcb fcc fdb float global include list message nolist noxlat
page public rmb sect segment set space title x xlat =  

Special strings
Special strings have names and they are replaced with its contents in assembly time. The names must be spelled in uppercase and should be preceded with @. The special strings can be used in context where usual strings may have place.
Example:

tmstamp: asciz @TIMESTAMP

String Replaced with...
DATE Date of assemling (month, day, year)
DAY Day of assembly time
FILE Full name of source file with path
FILEL Full name of source file with path and current line
(example: this file.asm(45))
LINE Current line
MCODE Microprocessor code (for 6805 - 1)
MNAME Microprocessor name (for 6805 - "6805")
MONTH Current month
SECT Current section in source file
TIME Current time
TIMESTAMP Current time and date
TITLE Title of the listing (the argument of title directive)
VERSION Current version of 6X assembler
YEAR Current year

top

Operations
The operations are used with identifiers and constants to make expressions, calculated in assembly time.

Operations ordered by priority
( )
not, unary minus (-), ~, hi, whi, lo, wlo
*, /, %
+, -
<<, >>
<, <=, >=, >
==, /=
&
^
|
&&
||

Most of operations have same meaning as in C language. Exceptions are:
not - logical NOT (! is reserved as comment mark)
hi - return high byte or word argument
whi - return high word of double word agrument
lo - return low byte of word argument
wlo - return low word of double word agrument
/= - logical NOT EQUAL

Some of operations have synonims: <<, shl; >>, shr; ==, eq; /=, ne; <, lt; <=, le; >, gt; >=, ge.

Comments
The comment is any text preceded with ; or !.

Program line
The program line has following common syntax:
[identifier:][reserved name [expression]][; comment]
The maximal length of the line is 254 symbols.

top


Program structure
The source text of a program is written in one or more pure ASCII text files. Each line must terminate with CR-LF. The program itself is a collection of sections (defined with sect and dsect). Each section has unique name and can be given start address by base directive (absolute & float sections). If a section is not given a start address it follows previous section - absolute or float. A section defined with dsect does not generate code. It is used for RAM memory mapping. There is a special case - when program code is copied from EPROM to RAM in runtime and executed in RAM - dsect will help. See an example for MC6805 processor.

Directives:

sect - defines program section, base - defines section start address
Syntax:
sect name [base address]
or
sect name
base address
name is the name of the section. Optional base directive may be placed in the section definition to make it absolute (with fixed start address). A section may appear many times in one or more source files. If it is absoulte, base directive must occur in anyone of sect directives (may be not first one) but one time only. Synonim of sect is segment, and for base - at.
top

Declarations of constants
There is two directives for costants declarations: equ and set. equ generates constant which cannot be changed later. set declares assembly-time variable. Synonim of equ is =.

Syntax:
identifier equ value
identifier set value
Declarations of data
While the microprocessor instructions generate the program's code, assembler directives are used to generate data. There is directives for constants - integer and float numbers and strings - ASCII sequences.

String declarations. There is two directives: ascii, and asciz. Both generate ASCII string but second one puts additional '\0' at the end, effectively this is so called C-string (as used in C language). Synonim of ascii is fcc. The special strings may be used as arguments of string directives.

Syntax:
[identifier[:]] ascii string
[identifier[:]] asciz string

Translate tables. Without translate tables, ascii and asciz generate ASCII coded strings only. With translate table it is possible to convert ASCII code to another code, par example code for LED indicators. The directive xlat imports translate table at the point of its occurence. One can import more than one tables in any point of program text. The translate tables can overlap and last loaded translation codes override previous ones. A special directive, noxlat, cancels all tables and restores ASCII coding loaded. noxlat has no arguments.

Syntax:
xlat translate_table_file_name

Format of translate table file:
number_of_translate_entries
ASCII_code=replacement_code
ASCII_code=replacement_code
..............
ASCII_code=replacement_code

The number_of_translate_entries must be decimal number. Other codes can be decimal or hexadecimal numbers from 0 to 255.
Example:
3
0x41=0xfc
0x42=0x38
0x43=0x76

Example: Let above table is writtent in a file named led.xlt.
asciz "ABC" ; this will generate 0x41,0x42,0x43
xlat led.xlt
asciz "ABC" ; this will generate 0xfc,0x38,0x76
noxlat
asciz "ABC" ; this will generate 0x41,0x42,0x43
 
top

Declaring array of numbers. It is possible to declare array of byte, word and doubleword integer values, float (single
precision 4 bytes), double (double precision 8 bytes) real numbers.

Syntax:
[identifier[:]] data1 byte_values_list
[identifier[:]] data2 word_values_list
[identifier[:]] integer word_values_list ; 6502 specific
[identifier[:]] data4 dword_values_list
[identifier[:]] float float_values_list
[identifier[:]] double double_values_list

data2 and data4 generate multibyte values with most-significant byte first (at lowest address).
data1, data2, data4 accept strings as arguments but use first one, two or four bytes only.
fcb is synonim of data1, fdb is synonim of data2.

Note: integer directive is available in 6502 assembler only. It acts like data2 but places the two bytes of the argument in reverse order. data2 will place most significant byte at the lower address, while integer will place least significant byte at lower address.
Examples:
positives: data1 1,2,3,4,5,6,7,8,9,10
words: data2 0xaa55,67,89,0x3456
switchtable: data2 func1, func2, func3
.....
func1:
.....
func2:
......
func3:
......

Memory space reservation. One can reserve memory space with space directive (synonim - rmb).

Syntax:
[identifier[:]] space bufferSise[, value]

This reserves bufferSise bytes, filled with value or with zero if value is omitted. Mainly used with dsect sections.

Multiple source files support
Following direvtives support multiple source files programs.
define (synonim global and public) - defines global symbols
extern - declares symbols, defined in another file
One should declare an identifier as global in the file where is allocated if he want to use it in another file. This identifier
should be declared as external in second file otherwise it cannot be seen there. If there is local symbol with identical name
as global one (but defined in another file) visible one is local. The option -Ze makes global symbols automatically visible in all files. One limitiation arises in this case: no local symbols identical to global ones are allowed.

Syntax:
define identifier[,identifier...]
extern identifier[,identifier...]

include - includes source file at the point of its occurence. It acts as if the text in included file is in including file. Nested inclusions are allowable.The limit of the level of inclusions is put by the operating system - how many opened files in same time is allowed.

Syntax:
include defines.inc

-Zg option (define & extern files). This options automates program development. It causes 6X Assembler to generate DEF and EXT files. The assembler looks for external references that have not global definitions for them in another files.
If it find that somewhere these symbols it supposes that they are the global symbols needed but the programmer has forgotten to define them global. Thus the forgotten definitions are in DEF file (the name is as the source where they should be). Moreover, if there is undefined symbol but the same is local somewhere else, the assembler will generate DEF file for the file containing symbol and EXT file for the source where it is referenced. As DEF, EXT file contain possibly forgotten extern declarations.
top
 
Exporting symbols
The directive export exports identifiers as constants in include file (with EXP extension of the name) . This can be used when another program wants to use addresses in first program (par example ROM based kernel or monitor can export addresses of its procedures so they may be called from a user program, written later). Note: export directive takes effect if 6X is started with -Zr option.

Syntax:
export
Example: If the file src.asm contains lines
alpha:
........
beta:
........
export alpha, beta

will produce src.ext with following content:
alpha equ address0
beta equ address1

Listing directives
list - enables source listing from next line on.
nolist - disables source listing from next line on.
page - causes source liting to move to the next page
title - defines title of source listing. The title appears at first line of each page. It is allowable to have multiple title directives in source file(s).
message - Embeds a message in source listing. This directive accepts one or more argumets. Each of them may be string constant or expression. The result of the expression is inserted in the output message as decimal value. When the expression is preceded by pound (#), it is converted to a hexadecimal number.
top

Addressations
 
Addressations for MC6805 microcontroller
 
Type Examples
internal (inherent) clc
direct lda #12
zero page lda 12
extended lda 0x0100
indexed lda x
indexed with
8-bit offset
lda 12,x
indexed with
16-bit offset
lda 0x100,x
relative bra 12
bit set/clear bset status,2
bit test and branch brset status,2,target

Addressations for MC6800 microprocessor
Type Examples
internal (inherent) clc
direct lda #12
zero page lda 12
extended lda 0x0100
indexed lda x
indexed with
16-bit offset
lda 0x100,x
relative bra 12

Addressations for MC68HC11microcontroller
Type Examples
internal (inherent) clc
direct ldaa #12
zero page lda 12
extended lda 0x0100
indexed X ldaa 12,x
indexed Y ldaa 12,y
relative bra 12
bit set/clear bset 12,6
bit set/clear indexed bset 12,x,6
bit test and branch brclr 12,6,target
bit test and branch indexed brclr 12,x,6,target

Forced extended addressation
There is cases when an instruction should be coded with extended addressation instead of direct where 6X assembler
generates direct by default. The addressation modificator e is used to do this. Example:
ldaa direct_page_address,e
top
Cross-Reference generator
This is a supplementary program (XREF.EXE) which is used to generate cross-reference listing. 6X assembler produces CRF file (non ASCII). XREF reads CRF file and outputs REF file which is user readable. XREF.EXE can be invloked from inside 6X assembler when putting -FX option in the command line. The result is two files - one CRF and another REF. The name of the files is the name of first source file in the command of 6X assembler.

HEX Convertor
BINHEX.EXE converts the output BNR file from 6X assembler to miscelaneous binary and ASCII formats files.
The command line is
binhex BNR-file [HEX-file] /format [/Aaa] [/Ddd] [/U] [/M] [=nn]
where
BNR-file is the output from 6X
HEX-file is converted output file
format is one of
-- BIN - absolute binary file. The length of this file is last_used_address - first_used_address + 1. The gaps between
sections are filled with zeros or with the value of = option (see below).
-- SECT - absolute binary files each section in separate file.
-- LSECT - as SECT, but first two bytes are length of the section.
-- FAIR - Fairchild fairbug.
-- INTEL - intel intellec 8/mds.
-- TEK - textronix hexadecimal.
-- EXORC - Motorola exorciser.
-- EXORM - Motorola exormax.
aa is displacement of section base addresses (hex number)
dd is bytes per line for INTEL and EXOR? formats
U - Unix text format for output file
M - MS-DOS text format for output file
nn - fill character between sections for BIN format

top


Return codes
These are return codes of 6X programs:

6X Assembler:
0: OK
1: error in assembler program
2: fatal error (i.e. "drive not ready", "disk full" e tc)
3: internal error of 6X
4: Ctrl-C pressed

BINHEX:
0: OK
1: error

XREF:
0:OK
1:error

1