3 ms·
I don't mean that there is a 1-1 constant relation between C statements and exact assembly, but if you run gcc with -S or run objdump -b binary -Matt,x86-64
by samsquire 3y ago
I don't mean that there is a 1-1 constant relation between C statements and exact assembly, but if you run gcc with -S or run
objdump -b binary -Matt,x86-64 -D main.bin -m i386 ;
(note: this command places the assembly and C code side next to eachother, I think you have to compile with -g debug flag with gcc)
You can work that the assembly implements the semantics of C's virtual machine model and it is this that I find easier to understand than some algebraic systems. I kind of think of struct->ptrarray[indx]->struct.something corresponds to the calculation of ultimately a single memory address even if there is various shift lefts or adds or ors.
Java has its template interpreter which is interesting to read about and there is copy and patch JIT compilers.
- pjmlp 3y agoYou can do the same in any compiled language, including Java. Sun's Forte Pro was one of the first IDEs to have such capability for Java.
- IshKebab 3y agoSure but the relationship between assembly and source lines can be very complicated, even for trivial code: https://godbolt.org/z/hjW4T934q https://godbolt.org/z/hjW4T934q And that capability is not remotely unique to C - look at the list of languages Godbolt supports! Not all of them support linking source code to assembly but a large number do: C++, Rust, Zig, Ada, even Dart.
- IshKebab 3y agoI don't think the correspondence between C and assembly is really significantly higher than Rust, Zig or even Go.