Major Assembler - a symbolic assembler written in BASIC
Posted: Fri Aug 04, 2023 1:38 am
A revival of an old project that began on the VIC-20, this is more of a proof of concept than a practical tool, as it is quite limited and slow. But it does let you write short symbolic assembly programs using just BASIC and no other software. It gets around the lack of a native text editor by using the BASIC line editor instead; the program to assemble is entered starting at BASIC line number 1000. Simply running the program performs the assembly, either directly into RAM, a LOADable disk file, or a SEQ file containing the source of a BASIC program that will POKE the assembled program into RAM and then SYS to it.
Assembly lines without labels must begin with a colon (which is needed since BASIC won't preserve leading whitespace anyway); the available directives are ORG to set the target memory location, EQU to define a symbol, and DB and DW for Byte and Word-sized lists of Data values. Character literals are available, as are double-quoted strings in a DB list; in both cases a `£` may be used to enter a literal quotation mark (no other escapes, but you can freely intermix quoted text with numeric literals).
Expressions - either in the operand part of an instruction or as an element of a data list - may not have internal whitespace. The only operators are < to take the low byte, > the high, - to negate or subtract, and + to add; in the case of addition or subtraction, only one operation per expression is allowed. (It actually recurses without the benefit of a stack, so more than one addition operator will definitely yield an incorrect result.) Where operand size is ambiguous, any whose value is not known when it is encountered on the first pass is assumed to be a full word.
It's probably quite easy to break. But it does successfully assemble the included "hello, world" code.
Screenshot below:
Assembly lines without labels must begin with a colon (which is needed since BASIC won't preserve leading whitespace anyway); the available directives are ORG to set the target memory location, EQU to define a symbol, and DB and DW for Byte and Word-sized lists of Data values. Character literals are available, as are double-quoted strings in a DB list; in both cases a `£` may be used to enter a literal quotation mark (no other escapes, but you can freely intermix quoted text with numeric literals).
Expressions - either in the operand part of an instruction or as an element of a data list - may not have internal whitespace. The only operators are < to take the low byte, > the high, - to negate or subtract, and + to add; in the case of addition or subtraction, only one operation per expression is allowed. (It actually recurses without the benefit of a stack, so more than one addition operator will definitely yield an incorrect result.) Where operand size is ambiguous, any whose value is not known when it is encountered on the first pass is assumed to be a full word.
It's probably quite easy to break. But it does successfully assemble the included "hello, world" code.
Screenshot below: