Hacker News new | past | comments | ask | show | jobs | submit login
Optimising Assembly Like an 80's Hacker (retrocode.blogspot.com)
24 points by hailxenu on Feb 13, 2009 | hide | past | favorite | 5 comments



Heh... That takes me back.

I remember a puzzle in an old demoscene document: Assuming EAX contains all zeros except for a byte value in AL, what is the shortest number of instructions needed to copy AL's value to the other three bytes in EAX?

The puzzle was hard not because the task was particularly difficult but because the audience had spent so long optimizing assembly for speed that the hopelessly inefficient one-instruction answer would not occur to them.

(Answer: http://home.sch.bme.hu/~ervin/codegems.html#17)


According to the Intel IA-32 Optimization Reference Manual, integer multiplication has a 3 cycle latency. What's "hopelessly inefficient" about 3 cycles?

( Source: http://download.intel.com/design/processor/manuals/248966.pd... )


On earlier-model processors, it could be as bad as 40 cycles. You really didn't want to touch multiplication (or division!) back then. I recall programmers went as far as calculating memory offsets for a 320x200 screen as (x + (y << 8) + (y << 6)) instead of (x + y * 320).

http://home.comcast.net/~fbui/intel_i.html#imul


I just bought a C64, an Atari 130XE, a TI99/4A, and an original Gameboy on eBay. I've been tinkering with chiptunes lately, and wanted to use the Real Thing. My first five or six computers were Commodore 8 bit machines...it's amusing to go back to that world.

I just read a code analysis for one of Rob Hubbard's music routines, and that was pretty interesting. The size of software back then is mind-blowing today. And what's interesting is that I couldn't even use a very high level language (like Ruby or Perl or Python) to write a music player, plus the music, in the same number of lines, without resorting to loading libraries that are comparatively very large. The move away from specialized chips to very powerful generic processors has interesting repercussions.

I guess a lot of kids of the 80's are reaching the point where they get to feeling nostalgic, because I've seen a lot of 8-bit retro related activities of late. Chiptunes are bigger than ever (_why just released a chiptune library, for instance), someone just made a Haskell library for writing BASIC programs, and pixel art is also showing up everywhere. Weird how that happens. I guess the 70s and 80s had their 50s and 60s flashback with Happy Days and such, so it shouldn't be surprising that our generation is doing the same.


Retro programmers: Respect.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: