Keep DAA! (was Re: 8086 bugs)

J.C. Wren jcwren at jcwren.com
Sat Dec 10 08:00:54 CST 2005


    I thought I saw all the postings in this thread, but I missed where 
you posted that, Chuck.  Sorry.

    The advantage of the method, and yours below, is that they're 
deterministic.  Another is that it's position independent.  Now, 
admittedly, in 25+ years of writing software, I've only had one occasion 
where I needed it to be deterministic, and it was on a 8051 (same method 
works on any processor with DAA).  I've never had to worry about it 
having to be PIC.

    I like using the DAA method for testing job candidates.  It's not a 
pass/fail sort of thing, but if they can get reasonably close to 
figuring out what it's doing, they've earned points.  I usually throw in 
some other little questions like "What is Duffs Device" and a few 
others, just to see how in-depth they are (I've never seen Duffs used in 
real-world code, but it's useful trick to be aware of, and indicates a 
good understanding of the way C can be twisted).

    --jc

Chuck Guzis wrote:

>On 12/10/2005 at 12:03 AM woodelf wrote:
>
>  
>
>>It gets me confused before it returns. I think I've  seen the same code 
>>in the 386 book I have.
>>If it is the program segment I am thinking of that is a cute trick  if 
>>it returns AL as a ascii character.
>>    
>>
>
>Didn't I just post that selfsame code yesterday, albeit in 8080?
>
>How about:
>
>	and	al,0fh
>	xlate	hextable
>
>hextable	 db	'0123456789ABCDEF'
>
>Straightforward and fewer instructions.   Not only that, you can use ANY
>character code (say, EBCDIC) for output.
>
>Or even:
>
>	and	al,0fh
>	movzx	ebx,al
>	mov	al,hextable[ebx]
>
>--Chuck
>
>
>
>
>  
>


More information about the cctalk mailing list