On Sat, 14 May 2022 09:25:20 +0100
"Kerr-Mudd, John" <ad...@nospicedham.127.0.0.1> wrote:
> On Fri, 13 May 2022 14:45:01 +0100
> "Kerr-Mudd, John" <ad...@nospicedham.127.0.0.1> wrote:
>
> > On Wed, 11 May 2022 11:11:56 +0100
> > "Kerr-Mudd, John" <ad...@nospicedham.127.0.0.1> wrote:
> >
> > > DOS prog to display current month - parm of capital 'M' starts week at Monday, defaults to Sunday.
> > > uses int 21 fn 2A for getting current date and fn 09 for display.
[]
>
> New! Improved! 256 bytes. Warranty expires Dec 31st 9999. (code is OK to y32k, but it won't display 5 digit year)
>
> Thanks for taking a peek Wolfgang, don't get hung up on the DOS interrupt, focus on the leap year test and month length array...
244 bytes:
->d 100 l100
1636:0100 A0 82 00 3C-4D 75 01 43-BF 24 09 57-B4 2A CD 21 ...<Mu.C.$.W.*.!
1636:0110 51 28 C2 28-DA 80 C2 06-BE CE 01 A5-B9 06 00 B0 Q(.(............
1636:0120 20 F3 AA 88-F1 49 01 CE-01 CE 01 CE-A5 A4 AA 58 ....I.........X
1636:0130 B1 64 52 99-F7 F1 52 08-D2 75 02 88-C2 83 E2 03 .dR...R..u......
1636:0140 4A F6 D6 FE-CE B1 0A F6-F1 0D 30 30-AB 58 F6 F1 J.........00.X..
1636:0150 0D 30 30 AB-BE BE 01 56-A5 01 DE 01-DE B0 20 B1 .00....V...... .
1636:0160 07 38 D9 75-03 BE C0 01-A5 AA E2 F5-5E A5 5B 80 .8.u........^.[.
1636:0170 FF 02 74 01-99 88 F9 BD-B5 06 D3 ED-80 D6 1E 93 ..t.............
1636:0180 BE 0A 0D B1-07 D4 07 74-0D 28 C1 51-88 C1 93 AA .......t.(.Q....
1636:0190 AA AA E2 FB-91 59 40 38-C6 72 17 50-D4 0A 86 E0 .....Y@8.r.P....
1636:01A0 3C 00 75 02-B0 10 35 30-30 AB B0 20-AA 58 E2 E6 <.u...500.. .X..
1636:01B0 B1 07 96 AB-96 73 DF 5A-89 D0 AA CD-21 C3 0D 0A .....s.Z....!...
1636:01C0 53 75 4D 6F-54 75 57 65-54 68 46 72-53 61 0D 0A SuMoTuWeThFrSa..
1636:01D0 4A 61 6E 46-65 62 4D 61-72 41 70 72-4D 61 79 4A JanFebMarAprMayJ
1636:01E0 75 6E 4A 75-6C 41 75 67-53 65 70 4F-63 74 4E 6F unJulAugSepOctNo
1636:01F0 76 44 65 63-20 20 20 20-20 20 20 20-20 20 20 20 vDec
y2k code slimmed down; still a bit clunky I feel:
actual code for those not keen to convert hex dumps:
;PrtYear: I: ax=year ; O: dh=Febadj
mov cl,100d ; ch 0 still
push dx ; hi=mth lo=StrtDayOff
; xor dx,dx
cwd ; prog no good after y32k! but [-1]
div cx ; ax=CC, dx=YY ; bad disp after 10k
push dx
;; lpyrcalc I: dl=YY, al=CC; O: dh=Febadj [14]
or dl,dl ; YY=0? [2]
jnz notcent
mov dl,al ; so check CC
notcent: ; lpyr notlpyr
and dx,3 ; 0 nz [3]
dec dx ; dh=FFFF dh=0
not dh ; 0 -1 [2]
dec dh ; -1, -2 [2]
mov cl,10 ; lth prt [13]
putnumal ; CC (6)
pop ax
putnumal ; YY
;;ah nz
[omitted header print]
pop bx ; hi=mth lo=StrtDayOff
;; calc mthlth I: bh=mth, dl=Febadj; O: dl=mthlth [17+10=27], dl lost
;; uses cl, bp. al untouched
;; lpyr check earlier
cmp bh,2 ; [3]
je IsFeb ; retain dh Febadj
cwd ; dh=0 for non Feb mths any year
IsFeb:
mov cl,bh ; DNOSAJJMAMFJ
mov bp,0x06B5 ; 101011010101; default feb to 30
shr bp,cl
adc dh,30 ; this mth lth [16]
[omitted rtn to print day numbers offset to correct column, stop at dh]