12 ms·
If you are developing a compiler you will need to understand the output assembly. Learning to program in it is one way to get to know it. There is also plenty o
by mbel 8y ago
If you are developing a compiler you will need to understand the output assembly. Learning to program in it is one way to get to know it. There is also plenty of little code snippets around run-time libraries and OS that are written directly in assembly (e.g. crt0.o, crt1.o & friends).
Basically: somebody has to provide the infrastructure between assembly and high level languages, so that everyone else can write in HLL.
Optimization of games or HPC workloads is also a valid use-case, but today you probably want to use intrinsics in C instead.
- namibj 8y agoNot necessarily regarding the latter. Intrinsics only help with the part where your code doesn't fit the instruction set because the latter can encode operations the former can't natively, and the compiler might not always be able to detect such structures.Als Also, if you use assembler you can take better care about scheduling instructions around loops in a way to get very high throughput, because you might see that k-ary search happens to be faster than binary search because you can hide some of the latency you'd otherwise have. Also some other issues requiring higher-level restructuring once you see that your first implementation stalls the processor too hard. Once you reach GPU cores and other non-OoO cores you need to be careful with memory load stalls, and try to use some staging memory or so and e.g. load the data for the iteration after the next iteration into staging, then fetch it into registers in the next iteration, so it is ready in the one where it will be processed. You need such optimization to reach e.g. high throughput in matrix multiplication, because you need to minimize the instructions that use the ALU but don't do actual result-affecting calculations (and instead just e.g. loop/array index manipulation and such). The ability to be good with this is reduced in OoO machines with register renaming, sadly, and I'd like a core that is fast for sequential code due to low-delay high-clock operation, yet exposes the whole register set to the assembly programmer... One of the recent chip startups seems to target such a processor. Obviously also the Mill, but that's vaporware since forever...
- pjmlp 8y agoSome mainframe and workstation architectures never had direct support for Assembly instructions, only intrinsics on their system languages. Burroughs, Xerox PARC workstations, ETHZ workstations as a couple of examples.