2023-06-20 00:26:57 -04:00
|
|
|
( usage: arvelie.rom )
|
2023-06-17 14:48:46 -04:00
|
|
|
|
2023-05-25 14:14:21 -04:00
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
|
|
|
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|
|
|
|
|
2023-06-17 14:48:46 -04:00
|
|
|
|0000
|
|
|
|
|
|
|
|
@buf
|
2023-05-25 14:14:21 -04:00
|
|
|
|
2023-06-17 14:48:46 -04:00
|
|
|
|0100
|
|
|
|
|
|
|
|
@on-reset ( -> )
|
2023-05-25 14:14:21 -04:00
|
|
|
.Console/type DEI ?on-params
|
2023-06-17 14:48:46 -04:00
|
|
|
( today ) .DateTime/doty DEI2 .DateTime/year DEI2 <emit-arv>
|
|
|
|
#0a18 DEO
|
2023-05-25 14:14:21 -04:00
|
|
|
#800f DEO
|
2023-06-17 14:48:46 -04:00
|
|
|
BRK
|
2023-05-25 14:14:21 -04:00
|
|
|
|
2023-05-25 15:11:06 -04:00
|
|
|
(
|
|
|
|
@|vectors )
|
|
|
|
|
2023-05-25 14:14:21 -04:00
|
|
|
@on-params ( -> )
|
|
|
|
;on-console .Console/vector DEO2
|
2023-06-17 14:48:46 -04:00
|
|
|
BRK
|
2023-05-25 14:14:21 -04:00
|
|
|
|
|
|
|
@on-console ( -> )
|
2023-06-17 14:48:46 -04:00
|
|
|
.Console/read DEI DUP #21 LTH ?&validate
|
|
|
|
.buf zcap STZ
|
|
|
|
BRK
|
|
|
|
&validate ( c -> )
|
|
|
|
POP .buf parse BRK
|
2023-05-25 14:14:21 -04:00
|
|
|
|
2023-05-25 15:11:06 -04:00
|
|
|
(
|
|
|
|
@|core )
|
|
|
|
|
2023-05-25 14:14:21 -04:00
|
|
|
@parse ( ztr -- )
|
|
|
|
DUP zlen #05 EQU ?&on-arvgre
|
2023-05-25 14:33:43 -04:00
|
|
|
DUP zlen #0a EQU ?&on-grearv
|
2023-06-20 00:26:57 -04:00
|
|
|
( | print-error )
|
|
|
|
;&err
|
|
|
|
&w ( -- )
|
|
|
|
LDAk #19 DEO
|
|
|
|
INC2 LDAk ?&w
|
2023-06-17 14:48:46 -04:00
|
|
|
POP2
|
|
|
|
( err ) #010f DEO
|
|
|
|
JMP2r
|
|
|
|
&on-arvgre ( ztr -- )
|
|
|
|
( m ) INCk INC LDZk [ LIT "A ] SUB #00 SWP #000e MUL2 STH2
|
|
|
|
( d ) INC bytedec STH2r ADD2 INC2
|
|
|
|
( y ) ROT bytedec #07d6 ADD2 <emit-gre>
|
|
|
|
#0a18 DEO
|
|
|
|
( end ) #800f DEO
|
|
|
|
JMP2r
|
|
|
|
&on-grearv ( ztr -- )
|
|
|
|
( y ) STHk shortdec LIT2r 0005 ADD2r DUP2
|
|
|
|
( m ) STHkr bytedec INCr INCr INCr
|
|
|
|
( d ) STHr bytedec #0001 SUB2 doty SWP2 <emit-arv>
|
|
|
|
#0a18 DEO
|
|
|
|
( end ) #800f DEO
|
2023-06-20 00:26:57 -04:00
|
|
|
JMP2r
|
|
|
|
&err "usage: 20 "arvelie.rom 20 "YYYY-MM-DD 0a $1
|
2023-06-17 14:48:46 -04:00
|
|
|
|
|
|
|
@<emit-gre> ( doty* year* -- )
|
|
|
|
DUP2 <emit-dec2>
|
|
|
|
[ LIT2 "- 18 ] DEO
|
2023-05-25 15:54:37 -04:00
|
|
|
,&y STR2
|
2023-06-17 14:48:46 -04:00
|
|
|
STH2 #0c00
|
|
|
|
&l ( -- )
|
|
|
|
DUP [ LIT2 &y $2 ] ROT diam #00 SWP DUP2 STH2kr GTH2 ?&>skip
|
2023-06-20 00:26:57 -04:00
|
|
|
STH2k SUB2r !&>continue
|
|
|
|
&>skip
|
|
|
|
POP2 !&end
|
|
|
|
&>continue
|
2023-06-17 14:48:46 -04:00
|
|
|
POP2 INC GTHk ?&l
|
|
|
|
&end ( -- )
|
|
|
|
NIP INC <emit-dec>
|
|
|
|
[ LIT2 "- 18 ] DEO
|
|
|
|
STHr POPr INC !<emit-dec>
|
|
|
|
|
|
|
|
@<emit-arv> ( doty* year* -- )
|
2023-05-28 13:12:10 -04:00
|
|
|
#07d6 SUB2 NIP
|
2023-06-17 14:48:46 -04:00
|
|
|
( year ) <emit-dec>
|
|
|
|
( month ) DUP2 #000e DIV2 NIP #11 ADD DUP #2a GTH #30 MUL SUB <emit-num>
|
|
|
|
( digit3 ) #000e DIV2k MUL2 SUB2 NIP !<emit-dec>
|
2023-05-25 15:54:37 -04:00
|
|
|
|
2023-06-17 14:48:46 -04:00
|
|
|
@<emit-dec2> ( short* -- )
|
|
|
|
#0064 DIV2k DUP <emit-dec>
|
2023-05-25 19:13:25 -04:00
|
|
|
MUL2 SUB2 NIP
|
2023-06-17 14:48:46 -04:00
|
|
|
|
|
|
|
@<emit-dec> ( byte -- )
|
|
|
|
DUP #0a DIV <emit-num>
|
2023-05-25 19:00:17 -04:00
|
|
|
#0a DIVk MUL SUB
|
2023-06-17 14:48:46 -04:00
|
|
|
|
|
|
|
@<emit-num> ( num -- )
|
|
|
|
[ LIT "0 ] ADD #18 DEO
|
|
|
|
JMP2r
|
2023-05-25 15:11:06 -04:00
|
|
|
|
|
|
|
(
|
|
|
|
@|utils )
|
|
|
|
|
2023-05-25 14:51:02 -04:00
|
|
|
@doty ( year* month* day* -- doty* )
|
|
|
|
ROT2 ,&y STR2
|
2023-06-17 14:48:46 -04:00
|
|
|
LIT2r 0000 SWP2 NIP #01 SUB #00 EQUk ?&skip
|
|
|
|
&l #00 OVR [ LIT2 &y $2 ] ROT diam STH2 ADD2r INC GTHk ?&l
|
|
|
|
&skip POP2 STH2r ADD2 JMP2r
|
2023-05-25 14:51:02 -04:00
|
|
|
|
|
|
|
@diam ( year* month -- days )
|
2023-06-17 14:48:46 -04:00
|
|
|
#00 OVR ;diam-lut ADD2 LDA SWP #01 NEQ ?&>no-feb
|
2023-06-20 00:26:57 -04:00
|
|
|
STH DUP2 is-leap-year STHr ADD &>no-feb
|
2023-06-17 14:48:46 -04:00
|
|
|
NIP NIP JMP2r
|
2023-05-25 14:51:02 -04:00
|
|
|
|
|
|
|
@is-leap-year ( year* -- bool )
|
2023-06-17 14:48:46 -04:00
|
|
|
( leap year if divisible by 400 ) DUP2 #0190
|
|
|
|
( mod2 ) DIV2k MUL2 SUB2 #0000 EQU2 ?&leap
|
|
|
|
( not a leap year if divisible by 100, but not by 400 ) DUP2 #0064
|
|
|
|
( mod2 ) DIV2k MUL2 SUB2 #0000 EQU2 ?¬-leap
|
|
|
|
( leap year if not divisible by 100, but by 4 ) #0003 AND2 #0000 EQU2 JMP2r
|
|
|
|
¬-leap ( -- )
|
|
|
|
POP2 #00 JMP2r
|
|
|
|
&leap ( -- )
|
|
|
|
POP2 #01 JMP2r
|
2023-05-25 14:33:43 -04:00
|
|
|
|
2023-05-25 19:00:17 -04:00
|
|
|
@shortdec ( zp -- dec* )
|
2023-06-17 14:48:46 -04:00
|
|
|
( a ) STHk bytedec #0064 MUL2
|
|
|
|
( b ) STHr INC INC bytedec ADD2 JMP2r
|
2023-05-25 14:51:02 -04:00
|
|
|
|
2023-05-25 19:00:17 -04:00
|
|
|
@bytedec ( zp -- dec* )
|
|
|
|
LDZ2
|
2023-06-17 14:48:46 -04:00
|
|
|
( a ) [ LIT "0 ] SUB SWP
|
|
|
|
( b ) [ LIT "0 ] SUB #0a MUL ADD #00 SWP JMP2r
|
2023-05-25 14:51:02 -04:00
|
|
|
|
2023-05-25 14:14:21 -04:00
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
2023-06-17 14:48:46 -04:00
|
|
|
@zlen ( ztr -- len )
|
|
|
|
DUP zcap SWP SUB JMP2r
|
|
|
|
|
|
|
|
@zcap ( ztr -- end )
|
2023-06-20 00:26:57 -04:00
|
|
|
!&a
|
2023-06-17 14:48:46 -04:00
|
|
|
&w ( -- )
|
2023-06-20 00:26:57 -04:00
|
|
|
INC &a LDZk ?&w
|
2023-06-17 14:48:46 -04:00
|
|
|
JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|memory )
|
|
|
|
|
|
|
|
@diam-lut
|
|
|
|
[ 1f 1c 1f 1e 1f 1e 1f 1f 1e 1f 1e 1f ]
|
2023-05-25 14:14:21 -04:00
|
|
|
|