r/programming • • Aug 18 '26

Odin's New Inline Assembly Templates

https://odin-lang.org/docs/inline-asm/
62 Upvotes

3 comments sorted by

8

u/pjmlp Aug 19 '26 edited Aug 19 '26

I like it, it has some resemblance with Turbo Pascal Assembly procedures/functions.

procedure MyAssemblyFunc (n: Integer); assembler;
asm
   ....
end;

6

u/gingerbill Aug 19 '26

That's a partial inspiration but I wanted something which I don't think existed before. It's fundamentally a semantically type checked hygienic macro system.

There are only a few common approaches to inline assembly and most of big issues (strings as the body, incomprehendible clobbering parameters, cannot state things to be pinned to specific registers, statement only, etc). The approach I've chosen for Odin will have things that many people will criticize (that I know for definite), but there are good reasons for every single trade-off.

I am very happy with the design that I've come up with and I am so glad this came together in about a week too thanks to our core:rexcode package which is a high-performance multi-architecture instruction encoder/decoder/printer library written in Odin.

-33

u/brutal_seizure Aug 18 '26

Odin is so fisher price, lol.