msTimerULONG timer

Purpose: Determine if a desired time period has passed, based on the entire 4-byte system millis value.
Assumes: System interrupts are enabled, so the Operating System is able to update ulT0_Millis and ulT0_Seconds.
Passed:    R25:R24:R23:R22  WORD   ulStart the millis value saved at the starting time
R21:R20:R19:R18  ULONG ulDuration   the timer delay time, 0 to 4,294,967,290 milliseconds
Returns: R24  BYTE bIfDone 0 (or FALSE) if the specified amount of time has NOT passed OR
1 (or TRUE) if the specified amount of time has passed
FLAGS  ZERO flagset (TRUE) when the time has NOT expired (i.e., when R24 is 0) OR
clear (FALSE) when the timer has timed out (i.e., when R24 is 1)
Alters: R0, R22 through R27, R30, R31, and the FLAGS,
and R18 through R21 if ulDuration > 4,294,967,290 (= 0xFFFFFFFA)
Example:  This example uses the constant duration of 86,400 Seconds, which is 0x05265C00 milliseconds. It is loaded as a ULONG value into R21:R20:19:R18 below. Although more often than not, the duration would be a variable, this example shows that it doesn't always have to be.
ulMyTimer = 0x700                 ; SRAM address of 1 ULONG variable
ulDURATION  = 86400000            ; milliseconds in 1 day

OneDayTimer:
   LDI     R31, ulMyTimer >> 8    ; Point 'Z' at the ULONG variable above
   LDI     R30, ulMyTimer & 0xFF
   LD      R22, Z                 ; Read the value, the starting time (the low
   LDD     R23, Z + 1             ;  order BYTE is read first, into R22)
   LDD     R24, Z + 2
   LDD     R25, Z + 3
   LDI     R18, ulDURATION & 0xFF ; Load R21:R20:R19:R18 with a CONSTANT value
   LDI     R19, (ulDURATION >>  8) & 0xFF
   LDI     R20, (ulDURATION >> 16) & 0xFF
   LDI     R21, (ulDURATION >> 24) & 0xFF
   CALL    AmsTimerULONG
   BREQ    AOneDay_Exit
   CALL    Amillis                ; Read the present millis value and reset
   ST      Z    , R22             ;  the timer by updating the starting time
   STD     Z + 1, R23             ;  with that value
   STD     Z + 2, R24
   STD     Z + 3, R25
   CALL    ARotatePumpSequence    ; Rotate the pump sequence once each day

OneDay_Exit:
   RET
Notes: See the notes in the msTimerBYTE and SecTimerBYTE functions.
Dropin: 
(setup
code)
;   Setup for the msTimerULONG() call:
; Passed:  R25:R24:R23:R22 ULONG  the millis() value saved at the starting time
;          R21:R20:R19:R18 ULONG  the delay duration (0 to 4,294,967,290 mSec)
;              Note: values from 4,294,967,291 to 4,294,967,295 may be passed,
;                    will limit it 4,294,967,290 and will not cause an error.
; Returns: R24 BYTE  0 if the time delay is not done yet OR
;                    1 if (at least) the desired amount of time has passed
;  (Also): ZERO FLAG TRUE when the time has NOT passed yet OR
;                    FALSE when the time has passed
; Alters:  R0, R22 through R27 and FLAGS (R24 has the return value)
;          R18 through R21 if the value passed in it is overrange
Also see:  The millis and SystemSeconds variables, the msTimerBYTE, SecTimerBYTE, msTimerWORD, and SecTimerWORD timers.