/*
INSTRUCTION(ccf)
        {
        FLAGS = (zuint8)(
                (F_SZPC ^ CF) | /* SF, ZF, PF unchanged; CF = ~CFi          */
                /* Zilog:    YF = A.5 | (YFi != YQ); XF = A.3 | (XFi != XQ) */
                /* NEC NMOS: YF = A.5; XF = A.3                             */
                /* ST CMOS:  YF = A.5 | (YFi != YQ); XF = A.3               */
#               ifdef Z80_WITH_Q
                        (MODEL != Z80_MODEL_ST_CMOS
                                ? ((MODEL > Z80_MODEL_ZILOG_CMOS ? A : (F ^ Q) | A) & YXF)
                                : (((F ^ Q) | A) & YF) | (A & XF)) |
#               else
                        (A & YXF) |
#               endif
                (F_C << 4)); /* HF = CFi */
                             /* NF = 0   */
        PC++;
        return 4;
        }

| 7 6 5 4 3 2 1 0 |
| S Z Y H X P N C |

    xor a   ; %s0z1y0h0x0p1n0c0
    ccf     ; %s0z1y0h0x0p1n0c1 NEC
            ; %s0z1y.h0x.p1n0c1 Zilog

 #.#.
 #.#.
 .#..
 .#..
 .#..


*/

    DEVICE ZXSPECTRUM48
    ORG $4201 : HEX 18 38 28 28 28 30 30 18
    ORG $4301 : HEX 20 08 28 28 28 28 28 20
    ORG $4401 : HEX 10 10 10 38 10 30 28 20
    ORG $4501 : HEX 08 20 10 28 28 20 28 20
    ORG $4601 : HEX 30 38 10 28 28 20 28 18
    ORG $8000
start:
    ; ped, xf=yf=0 on NEC, xf=yf=1 on (Q^F)|A
    ld a,$ff
    or a    ; Q = F = %s1z0y1h0x1p1n0c0
    ld a,0  ; Q = 0, F = %s1z0y1h0x1p1n0c0
    ccf
    push af : pop bc : ld hl,$5821 : call display_f_in_c

    ; TonyB A
    XOR A
    INC A  ;YF=XF=0
    LD A,0FFH
    SCF
    ;YF = XF = 0
    push af : pop bc : ld hl,$5861 : call display_f_in_c

    ; TonyB B
    XOR A
    DEC A  ;YF = XF = 1
    LD A,0
    INC B
    SCF
    ;YF = XF = 0
    push af : pop bc : ld hl,$58A1 : call display_f_in_c

    jr $

display_f_in_c:
    ld b,8
.showF:
    rl c
    sbc a,a
    and $30 ; yellow paper for bit=1, black for bit=0
    ld (hl),a
    inc hl
    djnz .showF
    ret

    SAVESNA "testccf.sna", start