alt.hn

1/12/2025 at 7:42:38 PM

Customasm – An assembler for custom, user-defined instruction sets

https://github.com/hlorenzi/customasm

by zdw

1/15/2025 at 6:12:57 AM

flat assembler g (fasmg) does this. It has a powerful macro language, in which, among other architectures and formats, it implements x86 and ELF/PE/macho and is able to assemble itself.

I like to use it for scripting for turning binary formats to text and vice-versa.

by Grom_PE

1/15/2025 at 7:51:28 AM

This is very cool. On the topic of assembly, does anyone know of a language that is higher level than assembly, but retains the property that the output doesn't depend on the compiler or its flags?

I want it for low level CPU benchmarks and tests. Using C or assembly for those both suck.

I don't really know exactly how this would look (is the register allocator part of the spec?) but has anyone tried something like this?

by IshKebab

1/15/2025 at 2:47:07 PM

There was a post on HN where someone implemented a new language compiler purely from Assembly, and shows you from nothing to the very end where it looked mostly like a LISP assembly language. It was really neat. Sadly I dont have the buzzwords for Google to find it anymore, used to be able to find the powerpoint slides for it.

I forgot about HLA (High Level Assembly) though I have not used it personally, there were also a few others like C-- as well:

https://en.wikipedia.org/wiki/High_Level_Assembly

by giancarlostoro

1/15/2025 at 10:22:08 AM

Have you tried looking into something like NASM's macro functionality?

by asgeir

1/15/2025 at 11:12:22 AM

That sounds like a tall order. If you want it for CPU benchmarks, you presumably want to be able to use all real CPU machine instructions. Or a simpler language instruction set but with an optimizer, but it's hard to write an optimizer and then you could never change the optimizer.

by actionfromafar

1/15/2025 at 3:38:37 PM

Naturally, it is time for some Forth. :)

by pjmlp

1/15/2025 at 9:28:29 AM

> but retains the property that the output doesn't depend on the compiler or its flags?

That's not an inherent property of assemblers, and not the case in practice either.

by Levitating

1/15/2025 at 9:43:53 AM

Yes I know there are some minor caveats with pseudo-instructions and relocations but in general it is basically true. You can't wildly change the output without changing the source like you can with C.

by IshKebab

1/17/2025 at 6:24:14 AM

Interesting. If only it supported little-endian architectures!

by teo_zero

1/15/2025 at 9:54:26 AM

This is great! I did a project just like this one for my Master's thesis at University of Glasgow, although this project looks to be much more mature and advanced (plus it has users!):

https://github.com/markoglasgow/assembler_generator

by nekitamo

1/15/2025 at 6:02:04 AM

This is very cool! I'm always on the lookout for extensible assemblers. I especially want one that can handle a normalized subset of GNU assembly so that it can be used on the output of LLVM or GCC (using existing assembly languages, but assembling them in non-standard ways or with extensions).

by zyedidia

1/15/2025 at 9:24:26 AM

My complements on this. Assembler is the ultimate understanding and control.

by jas39