How to use the assembler A3

From the command line     a3 inputfile
will generate two files :  file.lst  listing and file.s  S-format object code.

The assembler is a two-pass  assembler.   The input file consists of 5 "commands" in the following format :

.s
symbol value
 ...
.a address
.b sym sym ...
.c
:label opcode operand
 ...
.e
operand = #sym sym +sym
sym = numeric symbol label
numeric begins with 0..9
symbol  found in the symbol table

.s  start the symbol defining section.  A symbol is associated with its numerical value.  When the assembler encounters a symbol in the input file it will substitute that symbol with its value.
.a  set the address.  It is used to define a location.
.b  define constant in the memory.  It is useful when building a table of value or to assemble a sequence of values even inside code segment.
.c  code segment.
.e the last line of program

The addressing modes are specified with prefix :
  #  immediate
  +  index
without any prefix the symbolic operand is considered to be direct address.

.s .a .b .c  can occur in any sequence.  Input scanning is case insensitive.  Internally all symbols are converted into uppercase and stored in the symbol table.  No comment fields are allowed.  You can implement one easily using another program to "filter" out all the comments.  For example, a  comment can be defined as anything after  ;; or // until the end of line.

Example

.s
print 1000
stop 1001
half  100
temp  101
temp2  102
base 2
.a  0
.c
 lda #15
 sta half
 cla
 add #1
 com
 and half
 ora #128
 sta temp
 xor temp
 lda half
 cla
 jz next
 jmp next
:next  ldx #257
 inx
 dex
 stx temp2
 adc +3
 ora +base
 jsr  print
 jsr  stop
:data
.b 1 2 3
.e
The output S-format file that is ready to be used to write into a EEPROM is :

S11300001D0F220064180101080E006411802200F3
S1130010651600651E0064183A001E46001E550150
S1130020015C605A0066070313024A03E84A03E9C5
S1060030010203C3
S9030000FC

The main objective of this implementation of a3 assembler is to make it as simple as possible.  The source code is only 200 lines long.  It is a two passes assembler.  The first pass collects all the symbol and counts the address.   The second pass does the actual generation of machine code.   As this is the first release, it is not yet robust.   Please report any bug found to  prabhas@chula.ac.th

2 October 1999
Prabhas Chongstitvatana