Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Z80] DAA Algorithm

362 views
Skip to first unread message

Young S

unread,
Apr 1, 1997, 3:00:00 AM4/1/97
to

Could someone point out to me what algorithm the Z80 has for the DAA
instruction? (answer please in terms of: if H-flag is set and N-flag
is set then subtract 6 or something like that.)

So far I have emulated it with the intel equivalents, but
there seems to be some differences.

Thanks.

Sean Young.

Dave Baldwin

unread,
Apr 1, 1997, 3:00:00 AM4/1/97
to

Young S (syo...@cs.vu.nl) wrote:

: Could someone point out to me what algorithm the Z80 has for the DAA

: instruction? (answer please in terms of: if H-flag is set and N-flag
: is set then subtract 6 or something like that.)

It's a fairly long table in the current Z80 User's Manual on page A5-94.
--
-=-=-=-=-=-=-=-=-=-=-=- Check out DIBs and TCJ -=-=-=-=-=-=-=-=-=-=-=-=-
Dave Baldwin: dib...@netcom.com | The Computer Journal 1(800)424-8825
DIBs Electronic Design | Home page "http://www.psyber.com/~tcj/"
Voice : (916) 722-3877 | Hands-on hardware and software
TCJ/DIBs BBS: (916) 722-5799 | TCJ/DIBs FAX: (916) 722-7480
-=-=-=-=-=-=- @#$%^&* I can't even quote myself! Oh,well. -=-=-=-=-=-=-

Young S

unread,
Apr 1, 1997, 3:00:00 AM4/1/97
to

Dave Baldwin (dib...@netcom.com) wrote:
> It's a fairly long table in the current Z80 User's Manual on page A5-94.
> --
The current? Is it still available? \(^-^)/
How do I get it?

Sean Young.

Todd Parker

unread,
Apr 2, 1997, 3:00:00 AM4/2/97
to

Young S (syo...@cs.vu.nl) wrote:

: Could someone point out to me what algorithm the Z80 has for the DAA
: instruction? (answer please in terms of: if H-flag is set and N-flag
: is set then subtract 6 or something like that.)

: So far I have emulated it with the intel equivalents, but


: there seems to be some differences.
: Thanks.
: Sean Young.

N . C . high . H . low . # added . C after
. . nibble . . nibble . to A . execution
.................................................
add, adc, inc operands:
0 0 0~9 0 0~9 00 0
0 0~8 0 a~f 06 0
0 0~9 1 0~3 06 0
0 a~f 0 0~9 60 1
0 9~f 0 a~f 66 1
0 a~f 1 0~3 66 1
1 0~2 0 0~9 60 1
1 0~2 0 a~f 66 1
1 0~3 1 0~3 66 1
.................................................
sub, sbc, dec, neg operands:
1 0 0~9 0 0~9 00 0
0 0~8 1 6~f fa 0
1 7~f 0 0~9 a0 1
1 6~f 1 6~f 9a 1

states: 1m, 4t
flags: S Z H P/V C used, N unused.

--
[todd] Saving Virtual Trees;

Young S

unread,
Apr 4, 1997, 3:00:00 AM4/4/97
to

Todd Parker (tpa...@netcom.com) wrote:
> N . C . high . H . low . # added . C after
> . . nibble . . nibble . to A . execution
> .................................................
> add, adc, inc operands:
> 0 0 0~9 0 0~9 00 0
> 0 0~8 0 a~f 06 0
> 0 0~9 1 0~3 06 0
> 0 a~f 0 0~9 60 1
> 0 9~f 0 a~f 66 1
> 0 a~f 1 0~3 66 1
> 1 0~2 0 0~9 60 1
> 1 0~2 0 a~f 66 1
> 1 0~3 1 0~3 66 1
> .................................................
> sub, sbc, dec, neg operands:
> 1 0 0~9 0 0~9 00 0
> 0 0~8 1 6~f fa 0
> 1 7~f 0 0~9 a0 1
> 1 6~f 1 6~f 9a 1

> states: 1m, 4t
> flags: S Z H P/V C used, N unused.

Thanks! This is exactly what I was looking for! (and I'm not kidding).

Sean.

0 new messages