Version v0.3.0-alpha+DEV
Work in progress. This is already viable to assemble the source code of the CTS256A-AL2 chip from G.I. without error and without any difference wrt. the binary image (https://www.github.com/GmEsoft/CTS256A-AL2).
- Fields must be separated by a tab - no spaces allowed;
- Macros not supported;
- Conditional assembly not supported;
- No support for linkable object files;
- No full support for expressions in constants;
- Decimal and hexadecimal literals supported, but not binary literals;
- Generates only a binary core image file, no support yet for hexadecimal output files (Intel HEX, etc.);
- Symbols not allowed for registers
Rn
and portsPn
; - Code (mnemonics and pre-defined symbols) must be in upper case.;
- No support for
INCLUDE file
; - No support for functions;
- No support for functions with 2 or more args.
- new Macro class;
- new in-line macro REPT.
- new Parser class, supporting new operators, parentheses and user-defined functions;
- support operators
DUP
,>>
,<<
,&
,|
; - fix parsing of expressions
X-Y-Z
evaluatedX-(Y-Z)
; - new Help text;
- String arguments;
INCLUDE/COPY files
;- fix quote processing in
split()
; - new Log class for messages;
- added compatibility warnings for extensions wrt. to the original syntax;
- new option
-NC
: no compatibility warnings; - new option
-ND-
: enable debug messages; - new option
-NW
: no warnings; - symbols can be EQUated to
Rnn
andPnn
; - display total # of warnings;
- new
IF
/ELSE
/ENDIF
and synonyms; - user-defined functions
name FUNCTION/FUNC arg,expression
; - new
SAVE
/RESTORE
options; - new
LISTING ON/OFF
: enable/disable listing; - new
DB nn,'text',...
/DS nnnn
/DB nnnn DUP(nn)
/DW nnnn,...
- fix
NOP
op-code; - fix
DJNZ A/B,offset
wrong offset value; - fix
TRAP n
op-codes (reversed); - new
ERROR
/WARNING
/INFO
/DEBUG
messages; - new
ASSERT_EQUAL x,y
: raise an error ifx
is not equal toy
.
- allow white spaces in arguments field.
- display wrong arg types in
Bad arg(s)
error messages.
- convert tokens to uppercase taking quotes into account;
- parse binary strings;
- parse expressions containing + or - (todo: unary '-');
- parse char literals;
- ignore ':' after labels;
- allow symbols for regs and ports;
- allow 'H' and 'B' as suffixes for hex and binary literals;
- fix (B) handling (error in "%10" parsing);
- add "-NE" to disable error listing to stderr;
- allow space and ':' as field separators;
- synonym ORG = AORG;
- synonym DB = BYTE/TEXT (todo: DB "text");
- synonym DW = DATA;
- fix DJNZ.
- initial commit
With Microsoft Visual Studio, execute the following commands to produce the executable ASM7000.exe
:
call /path/to/vcvars32.bat
cl /EHsc ASM7000.cpp
Command syntax:
ASM7000 [options] -i:InputFile[.asm] -o:OutputFile[.cim] [-l:Listing[.lst]]
-I:inputfile[.asm[ input source file
-O:outputfile[.cim] output object file
-L:listing[.lst] listing file
Options: -NC no compatibility warning
-ND- enable debug output
-NE no output to stderr
-NH no header in listing
-NN no line numbers in listing
-NW no warning
'*' following a directive or synonym denotes an extension or a deviation to the original assembler syntax.
$IF condition
: Start of a conditional assembly block. Synonyms:IF
* andCOND
*.$ELSE
: Start of the ELSE clause in the conditional assembly block. Synonym:ELSE
*.$ENDIF
: End the conditional assembly block. Synonyms:ENDIF
* andENDC
*.COPY filename
: Insert the contents of the given filename. Synonyms:INCLUDE
* andGET
*.SAVE
*: Save the current values of the option flags.RESTORE
*: Restore the saved values of the option flags.CPU name
*: CPU type (ignored).PAGE ON/OFF
*: Page flag (currently unhandled).LISTING ON/OFF
*: Listing flag (currently unhandled).name FUNCTION [args,...],expr
* : Function definition. Formal arguments inargs,...
and the evaluated expression inexpr
. Synonym:FUNC
*.name MACRO [args,...]
*: Macro definition. Formal arguments inargs,...
(not yet handled).ENDM
*: End of macro definition. (not yet handled).REPT times
*: Repeated block macro definition.IRP #var,params
*: Parameters iterator block macro definition. (not yet handled).IRPC #str,times
*: String iterator block macro definition. (not yet handled).ERROR 'message'
*: Generates an error message.WARNING 'message'
*: Generates a warning message.INFO 'message'
*: Generates an informational message.DEBUG 'message'
*: Generates a debug message (printed only if-nd-
is specified in the command line).ASSERT_EQUAL x,y
: raises an error if x and y are not equal.
[lbl] AORG nnnn
: Set the location pointer tonnnn
. Synonym:ORG
*.lbl EQU expr
: Define the labellbl
equal to the value ofexpr
.[lbl] BYTE nn[,nn...]
: Define a block of bytesnn[,nn...]
.[lbl] DATA nnnn[,nnnn...]
: Define a block of 16-bit wordsnn[,nn...]
. MSB first. Synonym:DW
*.[lbl] TEXT [-]'text string'
: Define a text string. If-
precedes the string, the last value is negated (not yet handled).[lbl] DB nn[,nn...][,'text string'...]
*: Define a block of bytesnn[,nn...]
or text strings.[lbl] DB n DUP(byte)
*: Define a of bytesbyte
repeatedn
times.[lbl] DS n
*: Bump the location counter byn
bytes.
Rnn
: Processor registers. May be aliased using anEQU
pseudo-op:FLAGS EQU R10
;OR %>01,FLAGS
.Pnn
: Processor I/O ports. May be aliased using anEQU
pseudo-op:APORT EQU P4
;ANDP %>FE,APORT
.%nn
: Immediate values:MOVD %>F000,R3
. Can be an expression.@nn
: Direct long address:CALL @ENCODE
. Short relative jumps don't use that notation:JMP LOOP
. Can be an expression.@nn(B)
: Direct long address, indexed by B:LDA @SCT1TB(B)
. Can be an expression.*nn
: Indirect address via registers pair:LDA *RULPTR
. Can be an expression.*nn(B)
: Indirect address via registers pair, indexed by B:LDA *TABPTR(B)
. Can be an expression.
nnn
: Decimal value.>nn
: Hexadecimal value.'c'
: Character value.$
: The value of the location counter.nnH
*: Hexadecimal value.bbbbbbbbB
*: Binary value.DATE
*: The current date as aTEXT
/DB
stringMM/DD/YY
(or depending on a specified format, tbd).TIME
*: The current time as aTEXT
/DB
stringHH:MM:SS
(or depending on a specified format, tbd).
Operators are evaluated left to right unless a sub-expression is enclosed in parentheses.
nn + expr
: Addition.nn - expr
: Subtraction.nn & expr
*: Bitwise AND.nn | expr
*: Bitwise OR.nn << expr
*: Left shift.nn >> expr
*: Right shift.func(expr)
*: Evaluation of the user-defined functionfunc
on the parameter value ofexpr
.
(to be expanded)
Run the assembler on the source file CTS256A.asm
, creating the object binary file CTS256A.bin
and the listing file CTS256A.lst
:
ASM7000 -i:CTS256A.asm -o:CTS256A.cim -l:CTS256A.lst
** TMS-7000 tiny assembler - v0.1.0-alpha - (C) 2024 GmEsoft, All rights reserved. **
Pass: 1
Pass: 2
0 TOTAL ERROR(S)
Listing CTS256A.lst
:
** TMS-7000 tiny assembler - v0.1.0-alpha - (C) 2024 GmEsoft, All rights reserved. **
Sat Aug 17 20:34:55 2024
Assembly of : CTS256A.asm
Output file : CTS256A.cim
Listing file : CTS256A.lst
1: ;** TMS-7000(tm) DISASSEMBLER V1.10beta3 - (c) 2015-20 GmEsoft, All rights reserved. **
2: ;
3: ; Tue Dec 27 08:39:46 2022
4: ;
5: ; Disassembly of : CTS256A.BIN
6: ; Equates file : CTS256A.EQU
7: ; Screening file : CTS256A.SCR
8:
9:
10: ;==============================================================================
11:
12: F000 AORG >F000
13:
14: ;==============================================================================
15:
16: ; Main entry point
17: F000 523A CTS256 MOV %>3A,B
18: F002 0D LDSP ; Init stack pointer 3B-XX
19: F003 8820002D MOVD %SP0256,R45 ; R45 := $2000 - Memory-mapped parallel output to SP0256A-AL2
20: F007 A2AA00 MOVP %>AA,P0 ; P0 = IOCNT0 := 1010 1010
21: ; Full Expansion;
22: ; Clear INT1, INT2 and INT3 flags
23: F00A A20A10 MOVP %>0A,P16 ; P16 = IOCNT1 := 0000 1010
24: ; Clear INT4 and INT5 flags
25: F00D 9104 MOVP P4,B ; Read P4 = APORT
26: F00F 5307 AND %>07,B ; Get Serial mode
(...)
1500: ;==============================================================================
1501:
1502: ; Index of rules tables
1503: FFBC F78C TABRUL DATA RLPNCT
1504: FFBD TABRU1 EQU $-1
1505: FFBE F7CCF882 DATA RULESA,RULESB,RULESC,RULESD
F8CCF919
1506: FFC6 F976FA30 DATA RULESE,RULESF,RULESG,RULESH
FA44FA8A
1507: FFCE FAB4FB4C DATA RULESI,RULESJ,RULESK,RULESL
FB55FB66
1508: FFD6 FB87FB99 DATA RULESM,RULESN,RULESO,RULESP
FBDFFCE1
1509: FFDE FD0DFD29 DATA RULESQ,RULESR,RULESS,RULEST
FD3DFDC2
1510: FFE6 FE8EFECF DATA RULESU,RULESV,RULESW,RULESX
FEDCFF2C
1511: FFEE FF3AFF84 DATA RULESY,RULESZ,RULNUM,>FFFF
FF8EFFFF
1512:
1513: ;==============================================================================
1514: ; Interrupt vectors
1515: FFF6 F1BCF1C1 DATA INT4,INT3,>FFFF,INT1
FFFFF385
1516: FFFE F000 DATA CTS256
1517:
1518: ;==============================================================================
1519: 0200 PARLINP EQU >0200 ; Memory-mapped parallel input from Host
1520: 2000 SP0256 EQU >2000 ; Memory-mapped parallel output to SP0256A-AL2
1521: 3000 CTSXRAM EQU >3000 ; CTS-256A External RAM origin
1522: ;==============================================================================
1523:
1524: 0000 END CTS256
0 TOTAL ERROR(S)
Microchip, Inc. holds the copyrights to the CTS256A-AL2 ROM Image. Microchip retains the intellectual property rights to the algorithms and data the emulated device CTS256A-AL2 contains.
- Allow lower case;
- Allow spaces as field separators;
- Allow symbols for
Rn
andPn
; - Allow expressions;
- Generate Intel HEX format output;
- Support
INCLUDE
files. - parse binary strings;
- parse expressions containing + or - (todo: unary '-');
- parse char literals;
- ignore ':' after labels;
- allow 'H' and 'B' as suffixes for hex and binary literals;
- synonym ORG = AORG;
- synonym DB = BYTE/TEXT (todo: DB "text");
- synonym DW = DATA;
- Refactor/streamline the parser;
- Add DATE and TIME string constants;
- Conditional assembly not supported;
- Encapsulate parts of code in C++ classes (in progress).
- parsing of expressions
X-Y-Z
evaluatedX-(Y-Z)
- arguments field containing white space, eg:
mov %10, count
-
DB "string"
not handled -
DB count DUP (x)
not handled -
hi(x)
&lo(x)
not handled (functions) - functions with 2 or more args
-
DS
not generating filling zeros in CIM format - unary ops not working
Created by Michel Bernard (michel_bernard@hotmail.com) - http://www.github.com/GmEsoft/ASM7000
Copyright (c) 2024 Michel Bernard. All rights reserved.
This file is part of ASM7000.
ASM7000 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ASM7000 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ASM7000. If not, see https://www.gnu.org/licenses/.