←back to thread

73 points ingve | 5 comments | | HN request time: 0.202s | source
1. tom_ ◴[] No.42477165[source]
It's always been a mystery to me why people put up with this stuff. Adding strings to the assembler output is fine if you want to assemble some unsupported instruction, and a useful getout clause. But as the only option, it sucks, and it's no fun if you want to insert more than 1 instruction.

I used CodeWarrior for PowerPC about 15 years ago, and its inline assembler was very easy to use. No markup required, and you didn't even have to really understand the ABI. Write a C function, add "register" to the parameters, put register variables inside the function, add an asm block inside it, then do your worst. It'd track variable liveness to allocate registers, and rearrange instructions to lengthen dependency chains. Any problems, you'd get an error. Very nice.

replies(4): >>42477331 #>>42477671 #>>42477682 #>>42479166 #
2. kccqzy ◴[] No.42477331[source]
I haven't used CodeWarrior for PowerPC, but that approach sounds like it requires the C compiler to understand the assembler instructions you are using. Is it? But most use cases of inline assembler I've seen these days is for using instructions that the compiler will not emit.
3. Conscat ◴[] No.42477671[source]
Raw multi-line R"()" strings in C++ reduce some of the tedium. I wrote myself an Emacs tree sitter pattern to highlight asm syntax nicer than a string normally would, which helps. There is also the stasm library (which I haven't used) that looks like a pleasant syntax. https://github.com/stasinek/stasm

Clang (but not GCC) also supports the MSVC assembly syntax which is derived from Borland inline assembly. Unlike MSVC, Clang supports it in 64-bit mode and also for arm.

4. astrange ◴[] No.42477682[source]
Most of the time I've used inline assembly it's because the compiler was optimizing something badly. I don't want it to rearrange anything.

(Scheduling is almost useless on modern desktop CPUs anyway, except for some instruction fusion patterns.)

5. throwaway_1224 ◴[] No.42479166[source]
+1, ^5, ditto and Amen for CodeWarrior and its inline asm. CW was way ahead of its time in terms of UX. Its C++ compiler was well above average too, particularly in terms of codegen (although all C++ compilers were effectively broken in that era.)

The only thing that held it back was the lack of scripting. It was probably a rebound rejection of the MPW days, when everything was script-based (and with a crazy custom language.) I remember thinking that the design team probably didn't want to open that Pandora's box, lest scripting might lazily become required and spoil the UX.

Unfortunately, this made CW unsuited to the advent of CI. Even then, I still think it was stupid for Apple not to acquire Metrowerks. The first 5-10 years of Xcode versions had a worse UX and way worse codegen.