hjalfi wrote:
I got distracted by other things --- Christmas, catching Covid, writing a novel...
I am glad you recovered from COVID. I hear there is a lot of that going around...
NaNoWriMo or something else? I almost went down that rabbit hole...
hjalfi wrote:
The biggest missing piece is a native assembler. It turns out that adding the requirement to produce relocatable binaries substantially increases the complexity of the assembler. It needs to keep track of which symbols are absolute and which are relocatable, plus the appropriate logic in the expression evaluation, and also needs to somehow keep track of the relocation table itself for emission, making memory management harder. There are also design constraints to juggle --- keeping all the data structures in memory is dramatically faster, but 6502 systems are typically fairly short on RAM and if the system's intended to be self-hosted it may need to be a disk-based assembler. Also, I really want it to be in C so I can use the assembler for cross-compilation.
We are in the same boat. One of the reasons I have been holding off on releasing FLEX is the lack of a native assembler. Luckily, the FLEX 6800 assembler source is available. Unfortunately, modifying it to handle 6502 instead of 6800 has not been easy, particularly handling the many addressing modes. I am making headway, however. Further challenges include:
* As with many assemblers (especially native) from the time, expression evaluation is strictly left-to-right instead of algebraic priority and it does not allow the use of parenthesis to specify priority. I have become too used to the latter
* Allow putting a colon after a label
* Symbols are limited to six significant characters and I want more
* Cannot use underscore in a symbol
* Directives are naturally Motorola style and some of the 6502isms are very different
* File inclusion can only be nested a single level; I need at least two
* My FLEX code depends upon conditional assembly to configure for different platforms, especially for the ROMmable version
* I have become dependent upon using local labels, so I will also need to add that
My approach has been to break it up into several smaller projects:
* Port the 6800 assembler to the 6502, yielding a 6800 cross-assembler running on the 6502 - done.
* Assemble 6502 instead of 6800, yielding a 6502 cross-assembler running on the 6800 - coming along
* Add the above desired features into the 6800 native assembler - barely started
* Combine all of the above into a native 6502 assembler
hjalfi wrote:
Native support has been upstreamed into LLVM-MOS, so you should be able to write C and assembler programs with their toolchain and it should Just Work. But I'm not very happy about requiring it as a prerequisite because it's vast, rather quirky and requires a different syntax for anything which will run natively. But writing complex tools in raw assembly is a PITA, and even DR thought so.
You may be able to increase adoption by doing what Digital Research did, namely provide pre-built binaries for everything possible so that someone can use their current toolset. Also provide images for the boot disks you are using for development.
That is the dark side of open source. You not only get to build it from the source, but you often have to which requires getting the toolchain going first. Linux would not have gotten going if everybody had to bootstrap up instead of merely downloading and installing a distro...
Edit: I thought you were off converting the 8080 assembler you had previously written into a 6502 assembler for CPM65.
Further: Added to comment about expression evaluation