Z80 DAA instruction

后端 未结 4 1137
无人共我
无人共我 2021-02-12 16:24

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 no

4条回答
  •  一生所求
    2021-02-12 17:13

    Just wanted to add that the N flag is what they mean when they talk about the previous operation. Additions set N = 0, subtractions set N = 1. Thus the contents of the A register and the C, H and N flags determine the result.

    The instruction is intended to support BCD arithmetic but has other uses. Consider this code:

        and  15
        add  a,90h
        daa
        adc  a,40h
        daa
    

    It ends converting the lower 4 bits of A register into the ASCII values '0', '1', ... '9', 'A', 'B', ..., 'F'. In other words, a binary to hexadecimal converter.

提交回复
热议问题