<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#include "common.inc"
#include "util.inc"


    ; EC_OSC external osciallator
    ; WDT_OFF no watchdog timer
    ; MCLRE_OFF gpio3 is not a reset pin. 
    ; CP_OFF no code protect
    ; CPD_OFF no code protect data
    ; BOD_ON brown out reset
    ; PWRTE_OFF power up timer disabled
    ; IESO_OFF no two speed startup
    ; FCMEN_OFF no fail-safe clock monitor

    __CONFIG (_EC_OSC &amp; _WDT_OFF &amp; _MCLRE_OFF &amp; _CP_OFF &amp; _CPD_OFF &amp; _BOD_ON &amp; _PWRTE_OFF &amp; _IESO_OFF &amp; _FCMEN_OFF) 


    udata

ClockMonth      res 1
ClockYearLow    res 1
ClockYearHigh   res 1

StackStart    equ 0xc0

    org     0
    goto    Main
    org     4
    retfie


    org 0x100

Main:

    movlw   StackStart
    movwf   FSR

    BANKSEL WDTCON
    clrf    WDTCON

    BANKSEL OPTION_REG
    movlw   0x3
    iorwf   OPTION_REG,F

    bcf     STATUS,RP0 ;bank0

    movlw   0x20
    movwf   ClockYearHigh
    movlw   0x12
    movwf   ClockYearLow
    movlw   0x1
    movwf   ClockMonth
    call    GetDaysInMonthClock
    addlw   -0x31
    btfss   STATUS,Z
    goto    Error1

    movlw   0x2
    movwf   ClockMonth
    call    GetDaysInMonthClock
    addlw   -0x29
    btfss   STATUS,Z
    goto    Error2

    movlw   0x20
    movwf   ClockYearHigh
    movlw   0x00
    movwf   ClockYearLow
    movlw   0x2
    movwf   ClockMonth
    call    GetDaysInMonthClock
    addlw   -0x29
    btfss   STATUS,Z
    goto    Error3

    movlw   0x20
    movwf   ClockYearHigh
    movlw   0x01
    movwf   ClockYearLow
    movlw   0x2
    movwf   ClockMonth
    call    GetDaysInMonthClock
    addlw   -0x28
    btfss   STATUS,Z
    goto    Error4

    movlw   0x12
    movwf   ClockMonth
    call    GetDaysInMonthClock
    addlw   -0x31
    btfss   STATUS,Z
    goto    Error5

    movlw   0x60
    sublw   0x59; 59 - W
    btfsc   STATUS,C; skip Borrow
    goto    Error6

    movlw   0x59
    sublw   0x59; 59 - W
    btfss   STATUS,C; skip Not Borrow
    goto    Error7

AddOneMonth:

    movlw   0x08
    movwf   ClockMonth

    movf    ClockMonth,W
    addlw   7
    btfss   STATUS,DC 
    incf    ClockMonth,W
    movwf   ClockMonth

    sublw   0x9; 
    btfss   STATUS,Z; skip Not Borrow
    goto    Error8

    movf    ClockMonth,W
    addlw   7
    btfss   STATUS,DC 
    incf    ClockMonth,W
    movwf   ClockMonth

    sublw   0x10; 
    btfss   STATUS,Z; skip Not Borrow
    goto    Error9

ParityCheck:

    movlw    0x13    
    call    CalculateParity
    andlw   0x1
    btfsc   STATUS,Z   
    goto    ParityError1

    movlw    0x13
    call    CalculateParityAdd
    andlw   0x1
    btfss   STATUS,Z   
    goto    ParityError2

BCDCheck:
    movlw   0x59
    call    FromBCD
    sublw   .59 
    btfss   STATUS,Z   
    goto    BCDError1

    movlw   0x60
    call    FromBCD
    sublw   .60 
    btfss   STATUS,Z   
    goto    BCDError2


    goto    Pass

    
    
GetDaysInMonthClock:
    ; pass arguments W=ClockMonth, ClockYearH, ClockYearL
    movf    ClockMonth,W
    decf    FSR,F
    movf    ClockYearHigh,W
    movwf   INDF
    decf    FSR,F
    movf    ClockYearLow,W
    movwf   INDF
    movf    ClockMonth,W
    call    GetDaysInMonthBCD
    incf    FSR,F
    incf    FSR,F
    return

    org     400


Pass: goto Pass

    org     500

Fail: goto Fail

Error1:  goto   Error1
Error2:  goto   Error2
Error3:  goto   Error3
Error4:  goto   Error4
Error5:  goto   Error5
Error6:  goto   Error6
Error7:  goto   Error7
Error8:  goto   Error8
Error9:  goto   Error9
Error10:  goto   Error10
ParityError1:  goto   ParityError1
ParityError2:  goto   ParityError2
BCDError1:  goto   BCDError1
BCDError2:  goto   BCDError2

    end
</pre></body></html>