drbitboy
Lifetime Supporting Member
Corrected typo in y4 calculation: [SUB cury y4 y4] is correct; [SUB cury 3 y4] was incorrect.
...
Kinda makes daba's relative approach more attractive, eh?Code:######################################################################## ### Exit this routine unless "finished cleaning" one-shot is 1 fin_cln_ons -------]/[---------<RET>--- ######################################################################## ### Assume count of days in current month, tag curdim, is 30 _______________ ---[MOV ]---- [Source 30] [Dest curdim] --------------- ######################################################################## ### Calculations to check for leap year ### - Int tag yN is a year evenly divisible by N and near cury ### - Strictly speaking, this calculation is not needed unless curm is 2 ### - Assumes modulo instruction is not available ### - No more than y4 is really needed; this will be irrelevant ca. 2100 _____________ ---+---[AND ]---+--- | [SourceA cury] | | [SourceB 3] | | [Dest y4] | | ------------- | | _____________ | +---[SUB ]---+ [SourceA cury] [SourceB y4] [Dest y4] ------------- _____________ ---+---[DIV ]---+--- | [SourceA cury] | | [SourceB 100] | | [Dest y100] | | ------------- | | _____________ | +---[MUL ]---+ [SourceA y100] [SourceB 100] [Dest y100] ------------- _____________ ---+---[DIV ]---+--- | [SourceA cury] | | [SourceB 400] | | [Dest y400] | | ------------- | | _____________ | +---[MUL ]---+ [SourceA y400] [SourceB 400] [Dest y400] ------------- ######################################################################## ### Adjust 30d assumption above for Jan, Mar, May, Jul, Aug, Oct, Dec _____________ curm/0 __________________ ---+---[LES ]----] [----+---[ADD ]------ | [SourceA curm] | [SourceA curdim] | [SourceB 8] | [SourceB 1] | ------------- | [Dest curdim] | | ------------------ | _____________ curm/0 | +---[GRT ]----]/[----+ [SourceA curm] [SourceB 7] ------------- ######################################################################## ### Adjust 30d assumption above for Feb: ### 30-2 => 28, then +1 => 29 for leap years _____________ _______________ ---[EQU ]---+-------------------------------------------[SUB ]---+-- [SourceA curm] | [SourceA curdim] | [SourceB 2] | [SourceB -2] | ------------- | [Dest curdim] | | --------------- | | _____________ _____________ _______________ | +---[EQU ]---[NEQ ]---+---[ADD ]---+ | [SourceA cury] [SourceA cury] | [SourceA curdim] | [SourceB y4] [SourceB y100] | [SourceB 1] | ------------- ------------- | [Dest curdim] | _____________ | --------------- +---[EQU ]---------------------+ [SourceA cury] [SourceB y400] ------------- ######################################################################## ### Move cury & curm to nxty & nxtm as initial year and month estimates ### Calculate nxtd, day of month a fortnight hence ### Correct for rollover at end of month ____________ ---+---[MOV ]------------------------------+--- | [Source cury] | | [Dest nxtd] | | ------------ | | _____________ | +---[MOV ]------------------------------+ | [Source curm] | | [Dest nxtm] | | ------------ | | _____________ | +---[ADD ]-----------------------------+ | [SourceA curd] | | [SourceB 14] | | [Dest nxtd] | | ------------- | | _______________ _______________ | +---[GRT ]---+---[SUB ]---+ [SourceA nxtd] | [SourceA nxtd] | [SourceB curdim] | [SourceB curdim] | --------------- | [Dest nxtd] | | --------------- | | _____________ | +---[ADD ]-----+ [SourceA nxtm] [SourceB 1] [Dest nxtm] ------------- ######################################################################## ### Correct for rollover at end of year _______________ _______________ ---[GRT ]---+---[MOV ]---+--- [SourceA nxtm] | [SourceA 1] | [SourceB 12] | [SourceB nxtm] | --------------- | --------------- | | _____________ | +---[ADD ]-----+ [SourceA nxty] [SourceB 1] [Dest nxty] -------------