3 ms·
I was studying operating systems and computer architecture in university (this included a tiny amount of assembly programming) and was interning at a company th
by znpy 6y ago
I was studying operating systems and computer architecture in university (this included a tiny amount of assembly programming) and was interning at a company that used scala and learning scala. At the time there was quite a fuss about the fact that the jvm did not support tail call optimization (at least until Java 7 IIRC?).
So on one side i was programming in scala and on the other side i was "hand-compiling" small C functions into m68k assembly...
The aha-moment came when I was hand-compiling a recursive function down to m68k assembly and I saw that I could completely eliminate ALL the recursive calls by re-arranging some register values and some values in the stack frame, inserting a small preamble in the assembly and then at the end of the assembly routine jump back to said preamble instead of making a recursive call.