zlacker

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

submitted by zdw+(OP) on 2025-01-12 19:42:38 | 73 points 17 comments
[view article] [source] [links] [go to bottom]
replies(8): >>unquie+3c8 >>zyedid+ld8 >>Grom_P+le8 >>IshKeb+sn8 >>jas39+mw8 >>nekita+4z8 >>westur+6Ha >>teo_ze+Xbf
1. unquie+3c8[view] [source] 2025-01-15 05:48:49
>>zdw+(OP)
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.
2. zyedid+ld8[view] [source] 2025-01-15 06:02:04
>>zdw+(OP)
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).
3. Grom_P+le8[view] [source] 2025-01-15 06:12:57
>>zdw+(OP)
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.

replies(2): >>sitkac+9n8 >>Rohans+vL8
◧◩
4. sitkac+9n8[view] [source] [discussion] 2025-01-15 07:49:40
>>Grom_P+le8
https://github.com/tgrysztar/fasmg
5. IshKeb+sn8[view] [source] 2025-01-15 07:51:28
>>zdw+(OP)
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?

replies(5): >>Levita+Bw8 >>asgeir+SB8 >>action+MG8 >>gianca+a89 >>pjmlp+Lk9
6. jas39+mw8[view] [source] 2025-01-15 09:24:26
>>zdw+(OP)
My complements on this. Assembler is the ultimate understanding and control.
◧◩
7. Levita+Bw8[view] [source] [discussion] 2025-01-15 09:28:29
>>IshKeb+sn8
> 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.

replies(1): >>IshKeb+3y8
◧◩◪
8. IshKeb+3y8[view] [source] [discussion] 2025-01-15 09:43:53
>>Levita+Bw8
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.
9. nekita+4z8[view] [source] 2025-01-15 09:54:26
>>zdw+(OP)
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

◧◩
10. asgeir+SB8[view] [source] [discussion] 2025-01-15 10:22:08
>>IshKeb+sn8
Have you tried looking into something like NASM's macro functionality?
◧◩
11. action+MG8[view] [source] [discussion] 2025-01-15 11:12:22
>>IshKeb+sn8
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.
◧◩
12. Rohans+vL8[view] [source] [discussion] 2025-01-15 12:00:16
>>Grom_P+le8
It's also possible to use stock flat assembler (non-g) for this, to some extent. I've done it before here: https://github.com/Rohansi/FPCompo11/blob/master/Assembler/i...
◧◩
13. gianca+a89[view] [source] [discussion] 2025-01-15 14:47:07
>>IshKeb+sn8
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

replies(1): >>French+Uo9
◧◩
14. pjmlp+Lk9[view] [source] [discussion] 2025-01-15 15:38:37
>>IshKeb+sn8
Naturally, it is time for some Forth. :)
◧◩◪
15. French+Uo9[view] [source] [discussion] 2025-01-15 15:52:30
>>gianca+a89
something like this: http://web.archive.org/web/20061108010907/http://www.rano.or... ?
16. westur+6Ha[view] [source] 2025-01-15 21:32:32
>>zdw+(OP)
Is there an ISA for WASM that's faster than RISC-V 64, which is currently 3x faster than x86_64 on x86_64 FWICS? https://github.com/ktock/container2wasm#emscripten-on-browse... demo: https://ktock.github.io/container2wasm-demo/
17. teo_ze+Xbf[view] [source] 2025-01-17 06:24:14
>>zdw+(OP)
Interesting. If only it supported little-endian architectures!
[go to top]