3 ms·
Inline assembly arguably not needed, and of debatable merit, vs. writing assembly code. > an instruction set reference I think the programming manual just as
by P_I_Staker 2y ago
Inline assembly arguably not needed, and of debatable merit, vs. writing assembly code.
> an instruction set reference
I think the programming manual just as important, especially if you're working with mixed asm and c code.
One way to think about it: the C programming language has a runtime environment that is everyone's responsibility to maintain. A bug-free compilation should ensure this is protected.
Without the all seeing machine help, it's all on you not to interfere with this environment by following the specified calling conventions.
Also, don't try to get too tricky. I saw a really bad bug where someone thought it wise to use a macro, to place a (C language) add operation directly before a function, then it calls it, and first instruction checks the overflow flag. The thing is C has no idea what you're doing, and doesn't guarantee that it will happen like that. In fact the assembly language couldn't even do certain register swaps for function calls without clearing the flag.
So, basically it "seemed to work" for years. A new compiler caused it to fail testing. Yes, this was a terrible idea and you should no better, but it's important to understand this challenging to predict and "testing resistant" risk. Extreme misuse can help illustrate the point.
P.S. I actually have come to favor asm code for asm, for the writing of asm code that is not trivial. It's mostly a preference and a style thing. Developers are more likely to think about the fact that the code has to play nice with C, instead of assuming some help. You should know better, but it can feel like everything is playing nice.