Arnt Gulbrandsen
About meAbout this blog
2013-09-25

Two bytes one bug

This is the shortest program I have ever written and expected to do something:

118 243

I wrote that on a timesharing host in the eighties. The host had a Z80 processor and ran MP/M (a multiuser variant of CP/M), and I was curious to see whether my code would affect other users. The host did not have an assembler, but I knew the bit patterns for most assembly instructions by heart anyway.

I did one thing right: I didn't tell anyone in advance. Never ask a question if you already know what the answer will be. Instead I waited until just before the end of the class.

And I did two things wrong. What I wanted was

di ; disable interrupts halt ; stop processing until interrupted

Sadly, halt is 118 and di is 243, which was my first mistake. And the second was that when it didn't work, I told someone (so what were you doing there at the end, Arnt?), which led to a ban on such experiments before I had found the first mistake.