Minias – A mini x86-64 assembler for fun and learning
github.com
github.com
The OP speaks of the assembler not freeing allocated memory, and refers to "manual calls to free". Back in the day, memory management was the programmer's responsibility; I don't know how an assembler might divine the programmer's intention.
Like, you could allocate stack memory in assembler, and deallocate it simply by returning. But heap management would be the responsibility of some library or OS (and the stuff I wrote ran on bare metal, this was before Windows).
I wrote a crude assembler in Pascal once (for fun). It didn't need a heap, it was all static allocation and stack - it didn't cross my mind that one might write an assembler that needs to do heap allocation. I was a callow youth, and probably didn't know what a heap was!
The only storage you need other than stack is for a symbol table. In the general case, you can't know in advance how big that's going to be, so I suppose heap allocation for the symbol table makes sense.
May be 6502 is just simplifier. But dealing with basic memory, asm, machine code, cpu and flags are so intuitive when you got a javascript emulator using canvas.
Minias can assemble itself
...but it's written in C and uses a parser generator? IMHO it feels a bit backwards --- and perhaps even a bit cheating if you're doing this for a "bootstrap pilgrimage" --- to write a lower-level tool in a higher-level language. On the other hand, the same author also links to a C compiler in C, without a parser generator: https://github.com/michaelforney/cproc
I don't know why you would think referencing Intel's x86 software developer manual has anything to do with what syntax an assembler would use. Anyone writing an assembler, regardless of its input syntax would refer to it.
> ...but it's written in C and uses a parser generator? IMHO it feels a bit backwards --- and perhaps even a bit cheating if you're doing this for a "bootstrap pilgrimage"
Who says they share your goals? It says they wrote this just for "fun and learning," i.e. to learn how an assembler works and how x86 instructions are encoded, maybe even to practice their C.
https://github.com/nathell/lithium/blob/master/src/lithium/a...
Are you interested in contributions for a custom parser?
One thing is I like the declarative nature of the peg, so I considered trying to make a tiny peg parser generator to go with it (Also worth noting that peg/leg itself is very small).
All that being said, a hand written parser could probably dramatically increase performance and not be that much more code - so I am still unsure - but probably.