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:
Major Assembler - a symbolic assembler written in BASIC
-
- Posts: 20
- Joined: Sat Nov 26, 2022 6:24 pm
Major Assembler - a symbolic assembler written in BASIC
- Attachments
-
- MajorAssembler.prg
- (8.6 KiB) Downloaded 307 times
-
- Assembling.png (871.15 KiB) Viewed 4979 times
Re: Major Assembler - a symbolic assembler written in BASIC
Hey, this is neat how you hijack lines 1000+ - I'll have to look further into how you're doing that from within BASIC itself (getting a string to its own code? wild).
But now that we have X16EDIT, what do you think about a modified version to read the input from a TXT file?
And this runs pretty slow, but I'll see what Blitz does with it.
But now that we have X16EDIT, what do you think about a modified version to read the input from a TXT file?
And this runs pretty slow, but I'll see what Blitz does with it.
Re: Major Assembler - a symbolic assembler written in BASIC
Change necessary for new rom R46.
222 P=BT+4:S=$C134:E=S
Table that lists Tokens has moved.
Handles 6502 but maybe not 65C02 mnemonics.
Also, the example program used a reserved location.
1000 PTR: EQU $22
would be better.
222 P=BT+4:S=$C134:E=S
Table that lists Tokens has moved.
Handles 6502 but maybe not 65C02 mnemonics.
Also, the example program used a reserved location.
1000 PTR: EQU $22
would be better.
Last edited by koyaa on Sat Mar 09, 2024 11:12 pm, edited 2 times in total.
Re: Major Assembler - a symbolic assembler written in BASIC
Yeah, the token list moves around from release to release.
You can look at the SYM files to get the current location of the token table (.reslst), or simply scan through the bank and look for "EN" + chr$(196).
You can look at the SYM files to get the current location of the token table (.reslst), or simply scan through the bank and look for "EN" + chr$(196).