1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

8080 DAA opcode

Discussion in 'Intel' started by IanB, May 27, 2007.

  1. IanB

    IanB Guest

    Can anyone point me at a reasonably detailed description of the
    workings of the 8080 DAA instruction?

    I've written an 8080 simulator but if I follow the details that I have
    found for DAA [1] then it doesn't quite work as expected. If I make a
    very small change to the details (reading between the lines really)
    then I can get BCD add, subtract (using Intel's published method) and
    increment to work correctly with DAA.

    I'm sure I remember reading that DAA didn't work properly (or as
    intended?) on the 8080 so I'm just trying to work out if my simulator
    is wrong or not.


    [1] I'm following this two step process

    (1) If the least significant four bits of the accumulator represent a
    number greater than 9, or if the auxiliary carry bit is equal to one,
    the accumulator is incremented by six. Otherwise, no incrementing

    (2) If the most significant four bits of the accumulator now represent
    a number greater than 9, or if the normal carry bit is equal to one
    (*), the most significant four bits of the accumulator are incremented
    by six. Otherwise, no incrementing occurs.

    (*) The bit I added to get BCD to work is to add "or step 1 caused a
    carry from bit 7"
    IanB, May 27, 2007
    1. Advertisements

  2. IanB

    Andy Guest

    1. Advertisements

  3. IanB

    IanB Guest

    IanB, May 29, 2007
  4. IanB

    Ian D Guest

    There is a good book that has several pages devoted to this very tricky
    instruction: "The 8080A BUGBOOK", published by SAMS, ISBN #
    0-672-21447-4. This is an excellent book with many practical programming
    examples for the 8080A. Do a Google search and you will find low priced
    sources for the book. One thing they do say is " Use the decimal adjust
    accumulator (DAA) instruction only after an ADD, ADC, or ADI
    instruction." A suggested way to use the very weird DAA is:

    Octal Mnem.
    306 ADI
    000 000
    047 DAA

    Ian D, May 30, 2007
  5. IanB

    Ian D Guest

    Another SAMS book by the same authors is "8080 8085 Software Design",
    ISBN # 0-672-21541-1. It also covers the DAA instruction in some detail.
    Ian D, May 30, 2007
  6. IanB

    IanB Guest

    Thanks for the reply and apologies for the delay in replying
    I've actually got a copy of that book, purchased back in the late 70's
    or early 80's I seem to recall it was one of the first "useful'
    programming books that Tandys (the UK's version of Radio Shack)

    I'm pretty sure now that I must have some flag logic wrong, and that's
    why I can't get DAA to work even in the "half hearted way" described
    in the various 8080 references.

    I've just got a Z80 emulator working correctly [1] so, with the added
    insight that has given me, I'll go back and see what I had wrong with
    the 8080.

    Thanks again


    [1] It passes some stringent tests I found on the web and also some
    (less stringent) comparisons against a working z80 system..
    IanB, Jun 5, 2007
  7. We've been waiting to hear what you found.
    Bill Davidsen, Jun 15, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.