Skip to content(if available)orjump to list(if available)

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

IshKebab

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?

asgeir

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

Levitating

> 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.

IshKebab

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.

Grom_PE

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.

nekitamo

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

unquietwiki

The demo website at https://hlorenzi.github.io/customasm/web/ makes this even more accessible. I can actually follow along as to how this works.

jas39

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

zyedidia

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).