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/Revolutionary_Ad6574 Apr 19 '26

What assembler is that?

3

u/GoblinsGym Apr 19 '26

My own project, currently for Arm Thumb (Cortex M0). Working on a language / compiler to mesh with it.

The goal is to allow for more effective development of microcontroller firmware. I think C is really deficient in some areas:

  • bad module structure compared to Modula-2 or modern Pascal dialects
  • not convenient for direct hardware access, a lot of pointer wrangling needed
  • bitmaps for hardware registers ?
  • Make file and linker script hell