News for hackers. Stuff that matters.
Re:Customasm – An assembler for custom, user-defined instruc... by IshKebab on Wednesday January 15, 2025 @02:51AM (#42708451)
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?

Re:Customasm – An assembler for custom, user-defined instruc... by Levitating on Wednesday January 15, 2025 @04:28AM (#42709018)
> 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.

Re:Customasm – An assembler for custom, user-defined instruc... by IshKebab on Wednesday January 15, 2025 @04:43AM (#42709108)
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.
Re:Customasm – An assembler for custom, user-defined instruc... by asgeir on Wednesday January 15, 2025 @05:22AM (#42709345)
Have you tried looking into something like NASM's macro functionality?
Re:Customasm – An assembler for custom, user-defined instruc... by actionfromafar on Wednesday January 15, 2025 @06:12AM (#42709649)
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.
Re:Customasm – An assembler for custom, user-defined instruc... by giancarlostoro on Wednesday January 15, 2025 @09:47AM (#42711347)
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

Re:Customasm – An assembler for custom, user-defined instruc... by Frenchgeek on Wednesday January 15, 2025 @10:52AM (#42712385)
Re:Customasm – An assembler for custom, user-defined instruc... by pjmlp on Wednesday January 15, 2025 @10:38AM (#42712128)
Naturally, it is time for some Forth. :)