Going back down the stack a bit, the BCD "aam" and "aad" instructions not only allow one to mess around with nibbles, but also (thanks to linearity) can be used to pun the decoder.

For instance, the following sequence decodes an ascii nibble, not only mapping "A..F" to 0xA-0xF, but also "a..f" and even (compatibly with some of my early kludges) ":..?":

0C 20   or al,20
D4 10   aam 10
D5 03   aad 3
2C 09   sub al, 9

-Dave

Before I started, this bootstrappy way of thinking tied my brain in
knots with even relatively simple problems. Now it's starting to make
sense.  And I like the way you can get boxed in a corner and just
imagine some magic to unblock you, and if it's simple enough magic and
it works, you feel like you're getting away with something that
shouldn't be possible, like you're using your first wish to ask the
genie for 5 more wishes.

That's awesome. Inspirational, even. It's like the "law of attraction"
with less bullshit.

magic, or leverage? Archimedes[0] would say there's a conservation law for genies, so it's possible to exchange one wish for 5 fractional wishes at a lesser hypothetical advantage...

(martial arts have a similar concept: the key to having a mechanical advantage is to arrange for the engagement to occur much closer to your center of gravity than that of your opponent -- win first, then hit)

[0] Archimedes:
δῶς μοι πᾶ στῶ καὶ τὰν γᾶν κινάσω

--
To unsubscribe: http://lists.canonical.org/mailman/listinfo/kragen-discuss

Reply via email to