2 ms·
Ever written anything in assembly? We trade cycles and bytes for programmer convenience. Assembly code heavily optimized for size will do things that are abso
by retrac 5y ago
Ever written anything in assembly? We trade cycles and bytes for programmer convenience. Assembly code heavily optimized for size will do things that are absolutely horrifying from a maintenance or general "architectural cleanliness" angle. Terribleness you might encounter:
* Reading instructions as constants because the values you need happen to already be in the code.
* Self-modification, including writing variables as constants into the instruction stream, generating instructions at run-time, and reusing code space as data space for one-once code.
* Using bits in the opcodes to store data, since a single bitflip doesn't affect the interpretation of some instructions. E.g. on the Z80 if Z and C are both always 1 at a particular point, you can use either jrz (0010 1000) or jrc (0011 1000) and use the 5th bit in that instruction as a flag. Free storage!
I do find this sort of thing fun. As a hobby. I wouldn't want to write an air traffic control system that way.