A16 Assembler v0.86 Documentation
Command line based assembler for the AiO A16 series of microprocessors.
See the included instruction set, or download the full documentaion at:
http://aioinc.ddns.net/HOST/docs.html
Execution syntax:
assembler.exe
Input file The assembly file to read from. Store as plaintext.
Output file Name of the file to be created. Includes extension.
Export Nonzero exports as a CROM formatted file
Zero exports as separated BIN files
Log Nonzero creates an assembly log
Warn Nonzero disables console warnings
If no input file is specified, you will receive an error message.
If no output file is specified, the assembler will use the default name of "OUTPUT.ROM"
If no export mode is specified, the output will be a CROM formatted file
If no log mode is specified, the assembler will automatically create a log
Software assembled into RAM regions WILL CLOBBER RAM and make it inaccessible!
Valid number formats:
% Binary
Decimal
$ Hexadecimal
' ASCII
Available directives:
; Comment / remark
Ignore the rest of the line
/ Label reference
Insert the address of a label at this position
\ Constant reference
Insert a constant at this position
c Define constant
Define the name and value of a constant
d Data
Insert a 16-bit number at this position
a ASCII character
Insert a single ASCII character at this position
z Zero-terminated string
Insert a string, followed by a 0 terminator
s Nonterminated string
Insert a string with no terminator character
org Set Origin
Move the origin pointer to a new address
rel Relative move
Move the pointer forward or back a specified number of positions
start Start of file
Start assembly at this address
end End of file
Stop assembly at this address
lim File size limit
Set a word limit to stop assembling at
out Set file name
Rename the output file
mess Display console message
Print the rest of the line to the console
addr Current address
Print the current address to the console
lfree Free bytes before word limit
Print the number of bytes free before the word limit is reached
free Free bytes before address limit
Print the number of bytes free before the address limit is reached
*general Enter general assembly mode
Switch to the general assembly interpreter
THIS ISN'T IMPLEMENTED AT ALL YET
literal Enter literal assembly mode
Switch to the literal assembly interpreter
binary Toggle output mode
Toggle between CROM and BIN output modes
nowarn Disable console warnings
Stop printing warning messages to the console
dowarn Enable console warnings
Print warning messages to the console
cstart Counter start
Start the word counter
cstop Counter stop
Stop the word counter
creset Counter reset
Reset the word counter to zero
cshow Counter show
Print the value of the counter
align Align address
Move to the next 16-base address
reset Set reset vector
Define reset vector as the current address
intn Set Interrupt vector "n"
Define interrupt vector "n" as the current address
novec Disable storing vectors
Don't allow defining and storing vectors automatically
dovec Enable storing vectors
Force defining and storing vectors automatically
break Stop emulator
Trigger an emulator breakpoint to stop execution and dump system status
nosym Suppress symbol file generation
Do not generate a symbol file after assembly. This is the default
dosym Generate symbol file
Generate a symbol definitions file after assembly has finished, for inclusion in other files.
symbols Symbol file to load
Name of a symbol definition file to load. Contains labels and constants to be used during assembly. It must be in the same directory.
outsym Symbole file name
Name of the symbols file to be generated
Pre-defined symbols:
LABEL AssembleAddress Current address of the assembler
CONST AssembleAddress Current address of the assembler
Possible errors, warnings, and messages:
ERROR "No input file specified, nothing to assemble!"
No input file was given.
WARN "No output file specified, using default!"
No output file was given
ERROR "Load error: No such file "" exists!"
The given input file does not exist or is inaccessible
WARN "Word limit reached, stopping assembly early"
The specified word limit was reached during assembly
ERROR "Out of memory or address out of range"
The current address exceeded available memory
ERROR "Invalid directive ""!"
A given directive could not be processed
MESSAGE "Stopped assembling at line ."
Encountered the END directive
ERROR "Unspecified address"
An origin directive was encountered with no address
WARN "Origin changed to address lower than current!"
An origin directive was encountered with a given address before the current address
ERROR "Unspecified relative"
A relative move directive was encountered with no direction or distance
ERROR "Invalid sign"
A relative move directive was encountered with a sign that was not +/-
ERROR "Filesize cannot be unlimited!"
Encountered a word limit directive with no specified value
ERROR "Unspecified filename"
Encountered a filename directive with no given name
MESSAGE "AASM: "
Encountered a console message directive
ERROR "Invalid instruction !"
Encountered an invalid instruction
ERROR "Number of constant name tokens is different from constant address tokens"
Internal error
ERROR "Undefined constant ""
Tried to insert a constant that was never created
WARN "Unused constant ""!"
A constant was defined but never used
ERROR "Undefined label """
Tried to insert a label that was never created
WARN "Unused label ""!"
A label was created but never used
ERROR "Couldn't create file ""!"
Could not create or access the specified output file
WARN "Origin changed to address normally in RAM!"
Software clobbers address space reserved for RAM ($1FFF)
WARN "BIN/CROM files cannot contain breakpoints!"
Breakpoints cannot exist in raw binaries (since they are an emulator feature) or CROM files (since this format does not support them)
WARN "Duplicate symbol loaded! Updating value from $ to $."
A symbol was loaded from a file which had the same name and was in the same table as an existing symbol.
Instruction set:
The A16 microprocessor supports 197 different instruction opcodes, listed below with their relevant information.
This includes the hexadecimal and decimal values, the cycle time, the assembler mnemonic, affected flags, and a general description
HEX DEC CYC INS FLAGS DESCRIPTION
00 000 1 NOP Do nothing
01 001 3 LDA Z LoaD Accumulator from address
02 002 3 LDB Z LoaD B from address
03 003 3 LDX Z LoaD index X from address
04 004 3 LDY Z LoaD index Y from address
05 005 2 LDAN Z LoaD Accumulator with Next word
06 006 2 LDBN Z LoaD B with Next word
07 007 2 LDXN Z LoaD index X with Next word
08 008 2 LDYN Z LoaD index Y with Next word
09 009 5 LDAI Z LoaD Accumulator with word at Indirect address
0A 010 5 LDBI Z LoaD B with word at Indirect address
0B 011 5 LDXI Z LoaD index X with word at Indirect address
0C 012 5 LDYI Z LoaD index Y with word at Indirect address
0D 013 3 STA STore Accumulator at address
0E 014 3 STB STore B at address
0F 015 3 STX STore index X at address
10 016 3 STY STore index Y at address
11 017 3 STS STore Status word at address
12 018 3 MOVA Z MOVe Accumulator to address
13 019 3 MOVB Z MOVe B to address
14 020 3 MOVX Z MOVe index X to address
15 021 3 MOVY Z MOVe index Y to address
16 022 4 SWA Z SWitch Accumualtor with word at address
17 023 4 SWB Z SWitch B with word at address
18 024 4 SWX Z SWitch index X with word at address
19 025 4 SWY Z SWitch index Y with word at address
1A 026 1 ADD ZC ADD b to accumulator
1B 027 1 SUB ZC SUBtract b from accumulator
1C 028 2 ADN ZC ADd Next word to accumulator
1D 029 2 SUN ZC SUbtract Next word from accumulator
1E 030 1 AND Z bitwise accumulator AND b
1F 031 1 OR Z bitwise accumulator OR b
20 032 1 NGT Z bitwise NeGaTe accumulator
21 033 1 XOR Z bitwise accumulator XOR b
22 034 1 SHL ZC bitwise SHift accumulator Left
23 035 1 SHR ZC bitwise SHift accumulator Right
24 036 1 ROL Z bitwise ROtate accumulator Left
25 037 1 RLC ZC bitwise Rotate accumulator Left through Carry flag
26 038 1 ROR Z bitwise ROtate accumulator Right
27 039 1 RRC ZC bitwise Rotate accumulator Right through Carry flag
28 040 1 TAB Transfer Accumulator to B
29 041 1 TBA Transfer B to Accumulator
2A 042 1 TAX Transfer Accumulator to index X
2B 043 1 TXA Transfer index X to Accumulator
2C 044 1 TAY Transfer Accumulator to index Y
2D 045 1 TYA Transfer index Y to Accumulator
2E 046 1 TSA Transfer Status word to Accumulator
2F 047 1 INC ZC INCrement accumulator
30 048 1 DEC ZC DECrement accumulator
31 049 1 INX C INcrement index X
32 050 1 DEX C DEcrement index X
33 051 1 INY C INcrement index Y
34 052 1 DEY C DEcrement index Y
35 053 1 CLC C CLear Carry flag
36 054 1 CLE ZE CLear Equals flag
37 055 1 CLR R CLear Return system
38 056 1 CLS S CLear Stack overflow flag
39 057 1 CID I Clear Interrupt Disable flag
3A 058 1 SID I Set Interrupt Disable flag
3B 059 2 JMP JuMP to address
3C 060 4 JTI Jump To Indirect address
3D 061 1 JTA Jump To address in Accumulator
3E 062 1 JTB Jump To address in B
3F 063 3 JAX Jump to address Adding index X
40 064 3 JSX Jump to address Subtracting index X
41 065 3 JAY Jump to address Adding index Y
42 066 3 JSY Jump to address Subtracting index Y
43 067 3 JIA Jump to Indirect address in Accumulator
44 068 3 JIB Jump to Indirect address in B
45 069 5 JIAX Jump to Indirect address Adding index X
46 070 5 JISX Jump to Indirect address Subtracting index X
47 071 5 JIAY Jump to Indirect address Adding index Y
48 072 5 JISY Jump to Indirect address Subtracting index Y
49 073 3 JSR R Jump to SubRoutine
4A 074 5 JSI R Jump to Subroutine at Indirect address
4B 075 2 CPAN ZE ComPare Accumulator with Next word
4C 076 2 CPBN ZE ComPare B with Next word
4D 077 2 CPXN ZE ComPare index X with Next word
4E 078 2 CPYN ZE ComPare index Y with Next word
4F 079 4 CPAI ZE ComPare Accumulator with word at Indirect address
50 080 4 CPBI ZE ComPare B with word at Indirect address
51 081 4 CPXI ZE ComPare index X with word at Indirect address
52 082 4 CPYI ZE ComPare index Y with word at Indirect address
53 083 1 CPB ZE ComPare accumulator with B
54 084 1 CPX ZE ComPare accumulator with index X
55 085 1 CPY ZE ComPare accumulator with index Y
56 086 1* BEQ Branch on EQual flag set
57 087 1* BNE Branch on Not Equal
58 088 1** BEI Branch on Equal flag set to Indirect address
59 089 1** BNI Branch on Not Equal to Indirect address
5A 090 1* BCS Branch on Carry flag Set
5B 091 1* BCC Branch on Carry flag Clear
5C 092 1* BSO Branch on Stack Overflow flag set
5D 093 1 RTS R ReTurn from Subroutine
5E 094 1 RTI I ReTurn from Interrupt routine
5F 095 2 PSH S PuSH accumulator to stack
60 096 2 POP Z S POP accumulator from stack
61 097 2 PSHRT RS PuSH ReTurn address to stack
62 098 2 POPRT RS POP ReTurn address from stack
63 099 2 PSHIR IS PuSH Interrupt Return address to stack
64 100 2 POPIR IS POP Interrupt Return address from stack
65 101 3 PSHN S PuSH Next word to stack
66 102 1 RESET ------- RESET the CPU
67 103 1*** WAIT WAIT for the system bus to become inactive
68 104 3 STAAX STore Accumulator at address Adding index X
69 105 3 STAAY STore Accumulator at address Adding index Y
6A 106 3 STBAX STore B at address Adding index X
6B 107 3 STBAY STore B at address Adding index Y
6C 108 3 STASX STore Accumulator at address Subtracting index X
6D 109 3 STASY STore Accumulator at address Subtracting index Y
6E 110 3 STBSX STore B at address Subtracting index X
6F 111 3 STBSY STore B at address Subtracting index Y
70 112 5 STAI STore Accumulator at Indirect address
71 113 5 STBI STore B at Indirect address
72 114 5 STXI STore index X at Indirect address
73 115 5 STYI STore index Y at Indirect address
74 116 5 STAIAX STore Accumulator at Indirect address Adding index X
75 117 5 STAIAY STore Accumulator at Indirect address Adding index Y
76 118 5 STBIAX STore B at Indirect address Adding index X
77 119 5 STBIAY STore B at Indirect address Adding index Y
78 120 5 STAISX STore Accumulator at Indirect address Subtracting index X
79 121 5 STAISY STore Accumulator at Indirect address Subtracting index Y
7A 122 5 STBISX STore B at Indirect address Subtracting index X
7B 123 5 STBISY STore B at Indirect address Subtracting index Y
7C 124 3 LDAAX Z LoaD Accumulator from address Adding index X
7D 125 3 LDAAY Z LoaD Accumulator from address Adding index Y
7E 126 3 LDBAX Z LoaD B from address Adding index X
7F 127 3 LDBAY Z LoaD B from address Adding index Y
80 128 3 LDASX Z LoaD Accumulator from address Subtracting index X
81 129 3 LDASY Z LoaD Accumulator from address Subtracting index Y
82 130 3 LDBSX Z LoaD B from address Subtracting index X
83 131 3 LDBSY Z LoaD B from address Subtracting index Y
84 132 4 LDAIAX Z LoaD Accumulator from Indirect address Adding index X
85 133 4 LDAIAY Z LoaD Accumulator from Indirect address Adding index Y
86 134 4 LDBIAX Z LoaD B from Indirect address Adding index X
87 135 4 LDBIAY Z LoaD B from Indirect address Adding index Y
88 136 4 LDAISX Z LoaD Accumulator from Indirect address Subtracting index X
89 137 4 LDAISY Z LoaD Accumulator from Indirect address Subtracting index Y
8A 138 4 LDBISX Z LoaD B from Indirect address Subtracting index X
8B 139 4 LDBISY Z LoaD B from Indirect address Subtracting index Y
8C 140 1* BGT Branch on Greater Than
8D 141 1* BGE Branch on Greater than or Equal to
8E 142 1* BLT Branch on Less Than
8F 143 1* BLE Branch on Less than or Equal to
90 144 1* BNL Branch on Not Less than
91 145 1* BZS Branch on Zero flag Set
92 146 1* BZC Branch on Zero flag Clear
93 147 1 CPXY ZE ComPare index X with index Y
94 148 2 SNDA SeND Accumulator to io port
95 149 2 SNDB SeND B to io port
96 150 2 SNDX SeND index X to io port
97 151 2 SNDY SeND index Y to io port
98 152 2 RCVA Z ReCeiVe Accumulator value from io port
99 153 2 RCVB Z ReCeiVe B value from io port
9A 154 2 RCVX Z ReCeiVe index X value from io port
9B 155 2 RCVY Z ReCeiVe index Y value from io port
9C 156 1 INB C INcrement B
9D 157 1 DEB C DEcrement B
9E 158 2 PSHB S PuSH B to stack
9F 159 2 POPB Z S POP B from stack
A0 160 2 PSHX S PuSH index X to stack
A1 161 2 POPX Z S POP index X from stack
A2 162 2 PSHY S PuSH index Y to stack
A3 163 2 POPY Z S POP index Y from stack
A4 164 1 JTX Jump To address in index X
A5 165 1 JTY Jump To address in index Y
A6 166 1 TBX Transfer B to index X
A7 167 1 TXB Transfer index X to B
A8 168 1 TBY Transfer B to index Y
A9 169 1 TYB Transfer index Y to B
AA 170 1 TXY Transfer index X to index Y
AB 171 1 TYX Trnasfer index Y to index X
AC 172 1 IN16 ZC INcrement accumulator by 16
AD 173 1 DE16 ZC DEcrement accumulator by 16
AE 174 4 INM ZC INcrement Memory value in place
AF 175 4 DEM ZC DEcrement Memory value in place
B0 176 1 RSP S Reset Stack Pointer
B1 177 1 RVD ReVerse Data in accumulator
B2 178 1 SWN SWap Nibbles in accumulator
B3 179 3 ADM ZC ADd Memory value to accumulator
B4 180 3 SUM ZC SUbtract Memory value from accumulator
B5 181 4 ADI ZC ADd Indirect value to accumulator
B6 182 4 SUI ZC SUbtract Indirect value from accumulator
B7 183 4 JSPH S Jump to Subroutine PusHing return address
B8 184 3 RSPOP S Return from Subroutine POPing return address
B9 185 1 SEC C SEt Carry flag
BA 186 1 SU1 1 Set User flag 1
BB 187 1 CU1 1 Clear User flag 1
BC 188 1 SU2 2 Set User flag 2
BD 189 1 CU2 2 Clear User flag 2
BE 190 1* B1S Branch on user flag 1 Set
BF 191 1* B1C Branch on user flag 1 Clear
C0 192 1* B2S Branch on user flag 2 Set
C1 193 1* B2C Branch on user flag 2 Clear
C2 194 1 PSHS S PuSH Status word onto stack
C3 195 3 SNDN SeND Next word to io port 0
FE 254 2 BRK I BReaK (trigger software interrupt)
FF 255 1**** HLT HaLT processor
* Add 2 cycles if branch condition is taken
** Add 3 cycles if branch condition is taken
*** 1 cycle ONLY if busy signal is already low
1 cycle before CPU waits and 1 cycle after busy signal goes low
**** HALT condition, the CPU will ignore the clock signal until a hard reset
File formats:
The CROM file format was originally designed for hand assembly and operation with the Batch emulator.
Thus, it's format is simple and is as follows:
Maaaa=dddd
Where "aaaa" is the hexadecimal memory address and "dddd" is the hexadecimal data which resides at that address.
Only one word can be stored per line, and no provisions for metadata exist.
The SYM file format is a new addition to the assembler, and it uses a CSV format as follows:
t,$vvvv,n
Where "t" is the type of symbol, L for labels and C for constants, "n" is the name of the symbol, and "$vvvv" is it's four-character hexadecimal value.
Only one symbol is stored per line for simplicity. No fields are allowed to be empty.
Only the first character of "type" is actually processed. Only three fields are stored per line.
Symbols with duplicate names will be replaced by the loaded symbols. This produces a warning.
Changelog:
0.70 First public release
0.75 Added binary file exporter
0.80 Added vector definition directives and changed default assembly start address to $2000
0.85 Added symbol import and export, breakpoints, ASCII conversion. Fixed nowarn bug, made comments appear in logs, deprecated PROMPT/PAUSE directives.
0.86 Made data types more robust, fixed a few bugs, made all errors and warnings report line numbers.
Credits:
Written by Joseph Rettler
(C)2019-2023 AiO Softworks