Z80 opcode DAA

Started by
5 comments, last by Dave2001 22 years, 10 months ago
I am writing an emulator for a Z80 system. I have been searching FOREVER for a site that has a description of EXACTLY how the DAA instruction works, but I can find none. I know what it does, but recreating it is hard when you don''t know how it works. Does anyone else have any experience in this and can help me out? Dave2001, Dave2999@hotmail.com
Advertisement
you mean a z80 processor?

HHSDrum@yahoo.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

Not sure if this is what you''re after, but take a look at this URL:

http://www.geocities.com/SiliconValley/Peaks/3938/z80code.htm

Hope this helps,



--
Sean Timarco Baggaley
Sean Timarco Baggaley (Est. 1971.)Warning: May contain bollocks.
A working Z80 emulation (in java) can be found at

http://www.spectrum.lovely.net/

It''s written in java but you should be able to figger out how all
the instruction set are implemented. Hope this helps

Box2020
Box2020<CEng&,CRnd*>
Is this link any use?
DAA - Decimal Adjust Accumulator

It''s for BCD (Binary Coded Decimal) but you may already know that. Used to be used a lot in early Z80 based games for simple scoring arithmetic for when the score was greater that 65535.

Basically it takes the upper and lower nibbles of the accumulator and adds (conditionally) 6 to either or both depending on what bits are set in the F register after arithmetic operations.

When N flag is 0 (after ADD, ADC, INC)

C hi H lo add post-C
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-3 1 0-3 66 1

When N flag is 1 (after SUB, SBC, DEC, NEG )

C hi H lo add post-C
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

C and H are the status of the C and H flags. hi and lo is the value range that is in the nibbles. ''add'' is what you add and ''post-C'' is the C carry flag after the instruction.

Sorry about the table formatting. But it was taken from the Z80 bible ''Programming the Z80'' by Rodney Zaks so you can be sure it''s 100% (unless I typed it wrong). Let me know if you want the page scanning and sending through.

Thanks for the nostalgia trip anyway.
Thank you guys SOOOOOO much!!! It works perfectly now.

Dave2001,
Dave2999@hotmail.com

This topic is closed to new replies.

Advertisement