;This program demonstrates a subroutine that can be called to
;enable a "user-friendly" display of the current CCR contents.
; The display will label the CCR bits and display them in binary.
;It is particularly useful for class demonstrations to show how
;various CCR flags are affected by arithmetic instructions.
;E.g.:   SXHINZVC
;        00100001
;**************************************************************
        .org    $0000
        ldaa    #$0F
        adda    #$13    ;CCR should now have H=1/N=0/Z=0/V=0 and C=0
        jsr     showccr
        ldaa    #$F7
        adda    #$9D
        jsr     showccr
        swi     ;end of main routine

        .org    $0180   ;Note-this code is relocatable!
showccr: psha
        pshb
        pshx
        tpa     ;A <-- CCR
        psha    ;save this as .outstr corrupts Acc. A
        ldx     #mylab  ;print label string "SXHINZVC"/CR/LF
        jsr     $FFC7   ;call Buffalo .outstr routine
        pulb    ;B <-- CCR
        ldx     #8      ;loop counter
shloop: ldaa    #'0'    ;assume bit is cleared- output ASCII '0'=$30
        lslb    ;shift out bits, MSB first
        bcc     sclr    ;see if bit set or cleared
        inca            ;if set then output ASCII '1'=$31
sclr:   jsr     $FFB8   ;call Buffalo .outa routine
        dex
        bne     shloop
        jsr     $FFC4   ;call Buffalo .outcrlf routine
        pulx            ;Restore registers A,B,X
        pulb
        pula
        rts
mylab:  .db     "SXHINZVC",13,4  ;(CR & EOT characters-Buffalo appends a LF)
        .end