Keep DAA! (was Re: 8086 bugs)

Jim Leonard trixter at oldskool.org
Sun Dec 11 01:41:15 CST 2005


Chuck Guzis wrote:
>>I don't think you can get any fewer instructions using this algorithm,
>>because you need to adjust the alphanumerics by an offset of 7, and
>>you need one extra instruction to set the inital carry flag boundary,
>>which makes 8 in total.
> 
> I haven't found a shorter solution yet.  Good work!
> 
> So who needs DAA?

Anyone who wants to implement the nybble-to-hex functionality in a lot shorter 
space, maybe?  :-)  This:

           AND     AL,0FH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,0AH
           ADD     AL,0F6H
           ADC     AL,3AH

...is 30 bytes (accumulator forms included).  This:

         mov     bx,offset hextable
	and	al,0fh
	xlat 	bx
hextable:
         db    '0123456789ABCDEF'

...is a total of 22 bytes including the hex table.  (I love xlat.)  But our DAA 
solution:

         and   al,15
         add   al,90h
         daa
         adc   al,40h
         daa

...is only 8 bytes.

If DAA were slow, I'd say ditch it.  But DAA is only 4 cycles and according to 
my real-world 8088 timings (slow night tonight), the DAA approach is only just 
a hair slower than the XLAT method.

So I guess there *is* a need for DAA ;-)
-- 
Jim Leonard (trixter at oldskool.org)                    http://www.oldskool.org/
Want to help an ambitious games project?             http://www.mobygames.com/
Or check out some trippy MindCandy at             http://www.mindcandydvd.com/


More information about the cctalk mailing list