Show HN: Torque – A lightweight meta-assembler for any processor

benbridle | 79 points

Very cool and I like the idea of a "meta-assembler." The most-recent version of flatassembler (fasm 2) is built with fasmg which is also a "meta-assembler" of sorts, in that it also doesn't directly support a specific instruction set and instead is a very powerful macro assembler. I'm keen to check out functionality overlaps between the two implementations.

https://board.flatassembler.net/topic.php?t=19389

https://flatassembler.net/download.php

2ton_jeff | 24 days ago

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

sitkack | 24 days ago

At first I thought it was useless: "but each ISA will still end up having different effective syntax because the underlying macro systems will not be designed the same".

But then I reread it and realised I was not paying attention to the usecase. It's about making it easy to write assemblers. So this isn't for your Arms and RISC-Vs it's for your random niche microcontrollers where the vendor-provided toolchain kinda sucks.

Seems cool!

I've experienced a couple of under-documented assemblers in my time. In neither case did this turn out to be that much of a problem in practice, but I guess I just don't write that much assembly.

bjackman | 24 days ago

I'm reminded of a 2016 [talk][1] where Rob Pike describes the common-denominator assembly language that the Go compiler generates. Then that assembly is translated into machine-specific code via table lookups. See the 11 minute mark.

[1]: https://www.youtube.com/watch?v=KINIAgRpkDA

MathMonkeyMan | 24 days ago

Reminds me of TDASM from the turn of the century: https://web.archive.org/web/20230906054935/http://www.pengui...

I remember there were a few other meta-assemblers I came across in the 80s-90s, so this is definitely not "unchartered territory", but it's good to see another one show up.

Of course, in the other direction there are meta-disassemblers used for analysis in tools like Ghidra.

userbinator | 24 days ago

someone should embed Prolog or microKanren

2ro | 14 days ago

Any time I read about Z80, my mind wants to try to run something on a GameBoy emulator.

Pretty cool project!

angelmm | 24 days ago

Is there any support for non-Unicode text? Is there any support for octal numbers? These things should be corrected, hopefully.

Also, some of the links in the table of contents of the documentation does not seems to work.

zzo38computer | 23 days ago

Excellent work man! I know some low level guys who would really appreciate this.

zadkey | 24 days ago

Well done! I write quite a bit of z80 for msx and this seems a nice addition.

anonzzzies | 24 days ago

This looks very cool, maybe I'll try this for risc-v if I have some time. I guess you could also use this to write RAW images, or other binary data.

roetlich | 23 days ago

Nice!

Would be interesting to target the RISC CPU of https://www.projectoberon.net with it.

eterps | 24 days ago

Need to address this point:

"Assemblers tend to be poorly documented"

I wish everything in programming was as good documented as assemblers and ISAs.

kunley | 24 days ago

I shared Torque elsewhere and people asked what license it has

vanderZwan | 23 days ago

[dead]

curtisszmania | 24 days ago