Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:27:33+00:00 2026-05-26T18:27:33+00:00

Apologies for this seemingly minor question, but I can’t seem to find the answer

  • 0

Apologies for this seemingly minor question, but I can’t seem to find the answer anywhere – I’m just coming up to implementing the DAA instruction in my Z80 emulator, and I noticed in the Zilog manual that it is for the purposes of adjusting the accumulator for binary coded decimal arithmetic. It says the instruction is intended to be run right after an addition or subtraction instruction.

My questions are:

  • what happens if it is run after another instruction?
  • how does it know what instruction preceeded it?
  • I realise there is the N flag – but this surely wouldnt definitively indicate that the previous instruction was an addition or subtraction instruction?
  • Does it just modify the accumulator anyway, based on the conditions set out in the DAA table, regardless of the previous instruction?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:27:34+00:00Added an answer on May 26, 2026 at 6:27 pm

    Does it just modify the accumulator anyway, based on the conditions set out in the DAA table, regardless of the previous instruction?

    Yes. The documentation is only telling you what DAA is intended to be used for. Perhaps you are referring to the table at this link:

    --------------------------------------------------------------------------------
    |           | C Flag  | HEX value in | H Flag | HEX value in | Number  | C flag|
    | Operation | Before  | upper digit  | Before | lower digit  | added   | After |
    |           | DAA     | (bit 7-4)    | DAA    | (bit 3-0)    | to byte | DAA   |
    |------------------------------------------------------------------------------|
    |           |    0    |     0-9      |   0    |     0-9      |   00    |   0   |
    |   ADD     |    0    |     0-8      |   0    |     A-F      |   06    |   0   |
    |           |    0    |     0-9      |   1    |     0-3      |   06    |   0   |
    |   ADC     |    0    |     A-F      |   0    |     0-9      |   60    |   1   |
    |           |    0    |     9-F      |   0    |     A-F      |   66    |   1   |
    |   INC     |    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     |    0    |     0-9      |   0    |     0-9      |   00    |   0   |
    |   SBC     |    0    |     0-8      |   1    |     6-F      |   FA    |   0   |
    |   DEC     |    1    |     7-F      |   0    |     0-9      |   A0    |   1   |
    |   NEG     |    1    |     6-F      |   1    |     6-F      |   9A    |   1   |
    |------------------------------------------------------------------------------|
    

    I must say, I’ve never seen a dafter instruction spec. If you examine the table carefully, you will see that the effect of the instruction depends only on the C and H flags and the value in the accumulator — it doesn’t depend on the previous instruction at all. Also, it doesn’t divulge what happens if, for example, C=0, H=1, and the lower digit in the accumulator is 4 or 5. So you will have to execute a NOP in such cases, or generate an error message, or something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a duplicate, but I've not managed to find this question
Apologies if this has been asked...but I can't find (or I am using completely
My apologies if this is a stupid question, however I can't find any information
Apologies if this is a too basic question but I couldn't find any satisfactory
Apologies if this question has been asked. I couldn't find it, but if it
Apologies if this has been answered before but I can't find a reference. I
Apologies if this ends up being a stupid question, but I was just wondering
Apologies if this is a slightly noob question, but looking to clarify my thoughts
Apologies if this was already asked but, I have had a look and can't
Apologies if this is a dumb question but I'm trying to format a currency

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.