3 ms·
> One valuable property of C that the author didn't hit, C code is easily translatable into assembler in your head. He kind of misses this point with the virtua
by saghul 8y ago
> One valuable property of C that the author didn't hit, C code is easily translatable into assembler in your head. He kind of misses this point with the virtual machine discussion. Yes C code becomes different types of assembly by platform, but you can look at C and have a clear idea of what the assembly will look like.
I've seen this many times, I'll be honest: I can write C, but for the life of me I don't have the slightest clue how the assembly code will look like.
- inetknght 8y ago> I can write C, but for the life of me I don't have the slightest clue how the assembly code will look like. Compiler Explorer can help a ton. https://gcc.godbolt.org/ https://gcc.godbolt.org/ I recommend liberal use of Compiler Explorer to verify claims during code review.
- JonathonW 8y agoSame here. At one point, I probably could've looked at C and had a pretty clear idea of what the 68HC12 assembly would look like... but I've never bothered to learn x86/x64 assembly, or ARM assembly, and I've written way more C code for those architectures than I ever did for microcontrollers back in undergrad.
- Koshkin 8y agoWhy not simply imagine it as something like this: ; c = a + b load reg1, a load reg2, b add reg1, reg2 store reg1, c
- freeone3000 8y agoThat's the correct steps, but that doesn't add anything that the original C code doesn't do. On x86, that could be: mov [ebx], eax add [ecx], eax Which is an entirely separate set of operands, instructions, and addressing modes. It's still the same steps, but it's not really telling you anything.