Major Assembler - a symbolic assembler written in BASIC

Post Reply
MarkTheStrange
Posts: 20
Joined: Sat Nov 26, 2022 6:24 pm

General - CX16 Major Assembler - a symbolic assembler written in BASIC

Post by MarkTheStrange »

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:
Image
Attachments
MajorAssembler.prg
(8.6 KiB) Downloaded 306 times
Assembling.png
Assembling.png (871.15 KiB) Viewed 4976 times
voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

Re: Major Assembler - a symbolic assembler written in BASIC

Post by voidstar »

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.
User avatar
koyaa
Posts: 4
Joined: Wed Nov 29, 2023 10:15 pm

Re: Major Assembler - a symbolic assembler written in BASIC

Post by koyaa »

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.
Last edited by koyaa on Sat Mar 09, 2024 11:12 pm, edited 2 times in total.
TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

Re: Major Assembler - a symbolic assembler written in BASIC

Post by TomXP411 »

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).
Post Reply