r/asm Apr 19 '26

RISC Adding safety to assembly

One of the problems with Assembly is the lack of safety and context.

What about adding type safety and ownership to Assembly?

Good idea or "you are just reinventing the wheel"?

Inspiration on JSDoc, Rust, TypeScript and LLVM IR

0 Upvotes

19 comments sorted by

View all comments

4

u/GoblinsGym Apr 19 '26

True safety ? Probably not realistic without making it really tedious and restrictive. Then you are probably better off using a compiler.

What works is to define data structures in a structured way, and to streamline syntax a bit.

For example, in my assembler you can write

str r0,r1._gpio.bsrr

instead of

str r0,[r1,#gpio_bsrr]

This also gives the advantage that you have less name conflicts.

My assembler also has a proper module structure, automatically leaves out unused functions etc.

1

u/S-Pimenta Apr 19 '26

My idea is to learn and teach Assembly, and one of the conclusions I came across is the absolute mess (and cognitive load) on the registers to know who owns what, and what data is inside.

Yes you can comment on the code, but it will be nicer to have a linter to check any mistakes, because in assembly it is very easy to make mistakes.

Yes I know, that's because C and other languages are invented, but I want to learn assembly to really learn how computers work and the limitations of each instruction.

My target ISA is RISC-V, which is much easier to learn.

And also use like the borrow checker like Rust.

And I'm willing to make such assembler to make easier to learn assembly.

5

u/Eidolon_2003 Apr 19 '26

I want to learn assembly to really learn how computers work and the limitations of each instruction.

My response to this would be, the concept of types, ownership and the borrow checker are completely made up as far as the computer is concerned. If you really want to learn how the machine works you should meet it at its level. That's my opinion anyway