4 ms·
In my assembly and computer architecture class (CSC 236 at NC State University), the instructor grades us on efficiency - sometimes it's the number of instructi
by LeafStorm 14y ago
In my assembly and computer architecture class (CSC 236 at NC State University), the instructor grades us on efficiency - sometimes it's the number of instructions written, sometimes instructions executed. Additionally, he posts the all-time efficiency records for each program.
The end result is that I am now addicted to assembly programming. There's so many clever tricks you can use, like:
* Manipulating the addresses your code assembles at so that the addresses in a jump table can overlap.
* Using `lea` on data values to convert ASCII numbers to their normal equivalent while in motion.
* Making a 128KB lookup table.
* Unrolling all the loops in the program.
* Reusing as many registers as possible (including using bx as a frame pointer) just so you don't have to pop them.
And when you're studying your code, and you suddenly have the flash of inspiration about how to make it faster, there's this feeling of, "Oh, that's so brilliant, but so evil..."
(Of course, then you have to debug it all. :-P)
- daurnimator 14y agoAlthough I love this stuff, encountering code like this is a nightmare. I hope you never have to revisit your programs ;)
- martinced 14y ago"...encountering code like this is a nightmare." Well... "Code like this" and "micro-optimization" are basically what powers the 900 000 Linux / Android smartphones sold daily and 1000+ cores CPUs running Linux. The very reason why such an OS is so fast on such a wide range of devices is because there are kernel developers who value micro-optimization and who constantly revisit their program, trying to lower the number of cache misses and trying to reduce contention. As Linus Torvalds recently --and a bit provocatively-- said: "I don't do web development... Because I like programming". We're living in the comfort of our unit tests and frameworks and whatnots and can afford to be on our good practices high-horses... But we should never forget that meanwhile there are people out there bringing us the best of the best because, precisely, they're doing everything we see as "wrong".
- deleted 14y ago[deleted]
- stevekemp 14y agoIt does get addictive. One of my earliest memories was doing assembly programming on MS-DOS 3.3, when I came across Ralf Brown's interrupt list. My best result was a version of life that ran in about 100 bytes.