Initial checkin of asm version 1.0 of date(1) by Phil Vandry (no changes

for GNO v2.0.6).  I've not checked, but it's unlikely that this is
POSIX compliant.
This commit is contained in:
gdr-ftp 1998-04-10 18:00:18 +00:00
parent 45dd3d2857
commit 98f457ebec
4 changed files with 437 additions and 0 deletions

6
bin/date/NOTES Normal file
View File

@ -0,0 +1,6 @@
date.asm is 41% faster and one third of the size of date.c, the
original. Also uses 60% less stack space. Assembly can really make a
hell of a difference.
Will work under GNO or ORCA. Also fixes two small problems with the
original date utility.

34
bin/date/README Normal file
View File

@ -0,0 +1,34 @@
date
====
I wrote this just so I could see how much smaller than asm version would be
as compared to the C version. It turned out to be a great deal smaller, and
faster too - even with its additional options which I added later.
-V Version info.
-u continuously update the date on the screen. Killing the process will
force a "clean" exit.
mkfs
====
Basically FormatGS and EraseDiskGS in one. I was tired of using an old "Init"
program from ORCA 1.x, so I wrote a GNO one. This one supports specifying
the file system by name in addition to the options the old Init used to
support.
See the manpage for details.
cal
===
Yeah, I did it again. I wrote a program that already existed. (notice that all
the files in this archive are this type of program). So what, it didn't take
long!
I didn't rewrite this one from scratch. I just added a few lines to the "cal"
that came with GNO (1.0) so that it would print a calendar for the current
month if no month is specified. This is how UNIX cal behaves.
This is the very first thing I did when I got ORCA/C (Finally!) last week.

223
bin/date/date.asm Normal file
View File

@ -0,0 +1,223 @@
* asm version of date utility
* Phillip Vandry, May 1993
mcopy date.mac
keep date
cline gequ 0
main start
phk
plb
sty cline
stx cline+2
stz uflag
ldy #8
lpp15 lda [cline],y
and #$ff
beq ok
iny
cmp #$20
bne lpp15
lpp20 lda [cline],y
and #$ff
beq ok
iny
cmp #$20
beq lpp20
cmp #$22
beq lpp20
cmp #'-'
bne showusg
lda [cline],y
and #$ff
cmp #'V'
beq showvers
cmp #'u'
beq updateflag
showusg ~ErrWriteCString #usage
bra getoutPASS
showvers ~WriteCString #versstr
getoutPASS brl getout
updateflag inc uflag
ok anop
lda #2 ; SIGINT
jsr handle
lda #15 ; SIGTERM
jsr handle
refresh pha
pha
pha
pha
~ReadTimeHex
lda #year+3
sta cline
lda 4,s
and #$ff
clc
adc #1900
ldx #4
jsr insert
lda 1,s
and #$ff
ldx #2
jsr insert
jsr unpad
pla
xba
and #$ff
ldx #2
jsr insert
jsr unpad
pla
and #$ff
ldx #2
jsr insert
jsr unpad
lda 1,s
and #$ff
inc a
ldx #2
jsr insert
phk
plb
pla
jsr lookup
lda months,x
sta month
lda months+1,x
sta month+1
pla
jsr lookup
lda weekdays-3,x
sta weekday
lda weekdays-2,x
sta weekday+1
~WriteString #ramit
lda uflag
beq exitall
pea 0
pea 1
case on
jsl sleep
case off
brl refresh
exitall ~WriteString #justnewl
getout QuitGS qtrec
handler anop
phb
plx
ply
pla
pla
phy
phx
plb
lda #1
case on
sta >ringring
case off
lda #0
sta >uflag
rtl
handle anop
pha
pha
pha
pea handler|-16
pea handler
pea errno|-16
pea errno
ldx #$1603
jsl $e10008
pla
pla
rts
lookup xba
and #$ff
pha
asl a
asl a
sec
sbc 1,s
tax
pla
rts
unpad ldx cline
phk
plb
short m
lda |0,x
cmp #$20
bne allok
lda #'0'
sta |0,x
allok long m
rts
insert pha ; thenum
pea 0
plb
phk
lda cline
dec a
dec a
dec a
sta cline
pha
phx
pea 0
~Int2Dec *,*,*,*
rts
string anop
qtrec dc i'2'
dc a4'0'
dc i'$4000'
ramit dc i1'strend-strbeg'
strbeg anop
weekday dc c'xxx '
month dc c'xxx '
day dc c'xx '
hour dc c'xx:'
minute dc c'xx:'
second dc c'xx '
year dc c'xxxx'
dc h'0d'
strend anop
justnewl dc h'01 0a'
weekdays dc c'SunMonTueWedThuFriSat'
months dc c'JanFebMarAprMayJunJulAugSepOctNovDec'
versstr dc c'date utility, asm version 1.0'
dc h'0d 0a'
usage dc c'usage: date [-uV]',h'0d 0a'
dc h'0'
end
errno data
ds 2
end
uflag data
ds 2
end
copy modsleep.asm
dpstk data ~Direct
kind $12
ds 512
end

174
bin/date/modsleep.asm Normal file
View File

@ -0,0 +1,174 @@
* Modified sleep routine based on sleep in libgno
* It was necesary to disassemble this routine and reassemble it so that
* date.asm can use its private variables. It needs to do this to make
* date abort when it is in the middle of a sleep()
* Phillip Vandry, May 1993
case on
sleep start
tsc
sec
sbc #$0014
tcs
phd
tcd
ldx $07
phx
tsx
stx $07
pea sleephandler|-16
pea sleephandler
pea 14
jsl signal
tay
lda $07
tcs
pla
sta $07
tya
phx
pha
lda $01,s
sta $0d
lda $03,s
sta $0f
pla
pla
ldx $07
phx
tsx
stx $07
pea $0000
pea $2000
jsl sigblock
tay
lda $07
tcs
pla
sta $07
tya
phx
pha
lda $01,s
sta $11
lda $03,s
sta $13
pla
pla
lda #$0000
sta ringring
ldx $07
phx
tsx
stx $07
lda $18
ldx #$0000
phx
pha
jsl alarm
tay
lda $07
tcs
pla
sta $07
tya
checkrr anop
lda ringring
tax
beq theeor
lda #$0001
theeor eor #$0001
bne nojump
brl afterbrl
nojump ldx $07
phx
tsx
stx $07
pei $13
pei $11
pla
and #$dfff
pha
jsl sigpause
tay
lda $07
tcs
pla
sta $07
tya
brl checkrr
afterbrl ldx $07
phx
tsx
stx $07
ldx $0f
lda $0d
phx
pha
lda #$000e
pha
jsl signal
tay
lda $07
tcs
pla
sta $07
tya
ldx $07
phx
tsx
stx $07
ldx $13
lda $11
phx
pha
jsl sigsetmask
tay
lda $07
tcs
pla
sta $07
tya
lda $16
sta $18
lda $15
sta $17
ldy $05
pld
tsc
clc
adc #$0016
tcs
tya
rtl
end
sleephandler start
tsc
sec
sbc #$0006
tcs
phd
tcd
lda #$0001
sta ringring
lda $08
sta $0c
lda $07
sta $0b
pld
tsc
clc
adc #$000a
tcs
rtl
end
ringring data
ds 2
end
case off