Show HN: Torque – A lightweight meta-assembler for any processor
benbridle.comHello everyone, I've been working on this project for the past few months.
Torque is a meta-assembler: instead of having an instruction set built into the assembler, you use macros to build up a small language that decribes an instruction set and then you use that to write your program. It's designed to work for any microcontroller/processor architecture, you build from the bit level upwards so there aren't any assumptions around word widths, instruction formats, or endianness.
I created Torque initially to write programs for a PIC microcontroller, after running into difficulties with the official assembler. I've also used it to write programs for the Z80 processor inside an old TRS-80 computer.
Let me know if you try it out or have any questions!
Super fun site!
Did you get inspiration from other assemblers or macro processors?
You have it running on a TRS-80, how does that work? I had no idea Rust could target a TRS-80.
I am getting hints of Forth, Lisp and TCL.
How would you go about laying out structs in memory?
I am sure you considered an internal DSL, what caused you go with something stand alone?
Any thoughts on adding a constraint solver, like Z3 and allowing end users to set constraints on things like the size of a jump.
I could see taking this an growing it into a compiler by making macro(macro(macros txt)))
Is there an internal IR?
Projects for inspiration
https://github.com/mattbierner/Template-Assembly
Specifying representations of machine instructions https://dl.acm.org/doi/pdf/10.1145/256167.256225
https://www.semanticscholar.org/paper/Specifying-representat...
Typed Assembly Language (TAL) https://www.cs.cornell.edu/talc/
And you haven't come across it, you are in for a treat https://en.wikipedia.org/wiki/META_II has spawned a whole trove of clones
https://en.wikipedia.org/wiki/OMeta
https://github.com/DalekBaldwin/clometa
Well done! I write quite a bit of z80 for msx and this seems a nice addition.
Excellent work man! I know some low level guys who would really appreciate this.
[dead]