1 line
13 KiB
NASM
1 line
13 KiB
NASM
|
keep obj/time
mcopy time.macros
case on
****************************************************************
*
* Time - Time and date libraries for C
*
* This code implements the tables and subroutines needed to
* support the standard C library TIME.
*
* January 1989
* Mike Westerfield
*
* Copyright 1989
* Byte Works, Inc.
*
* Note: Portions of this library appear in SysFloat
*
****************************************************************
*
Time start dummy segment
end
****************************************************************
*
* TimeCommon - common variables for the time library
*
****************************************************************
*
TimeCommon privdata
;
; For conversion to/from seconds since 1970
;
year ds 4 year 0..99
month ds 4 month 1..12
day ds 4 day 1..31
hour ds 4 hour 0..23
minute ds 4 minute 0..59
second ds 4 second 0..59
count ds 4 seconds since 1 Jan 1970
t1 ds 4 work variable
t2 ds 4 work variable
end
****************************************************************
*
* char *asctime(struct tm *ts)
*
* Inputs:
* ts - time record to create string for
*
* Outputs:
* returns a pointer to the time string
*
****************************************************************
*
asctime start
csubroutine (4:ts),0
phb
phk
plb
brl ~ctime2
end
****************************************************************
*
* clock_t clock()
*
* Outputs:
* X-A - tick count
*
****************************************************************
*
clock start
pha
pha
_GetTick
pla
plx
rtl
end
****************************************************************
*
* char *ctime(timeptr)
* time_t *timptr;
*
* Inputs:
* timeptr - time to create string for
*
* Outputs:
* returns a pointer to the time string
*
****************************************************************
*
ctime start
tm_sec equ 0 displacements into the time record
tm_min equ 2
tm_hour equ 4
tm_mday equ 6
tm_mon equ 8
tm_year equ 10
tm_wday equ 12
csubroutine (4:timeptr),0
phb
phk
plb
ph4 timeptr convert to a time record
jsl localtime
sta timeptr
stx timeptr+2
~ctime2 entry
ldy #tm_wday convert the week day to a string
lda [timeptr],Y
asl a
asl a
tax
lda weekDay,X
sta str
lda weekDay+1,X
sta str+1
ldy #tm_mon convert the month to a string
lda [timeptr],Y
asl a
asl a
tax
lda monthStr,X
sta str+4
lda monthStr+1,X
sta str+5
ldy #tm_mday convert the day to a string
lda [timeptr],Y
jsr mkstr
sta str+8
ldy #tm_hour convert the hour to a string
lda [timeptr],Y
jsr mkstr
sta str+11
ldy #tm_min convert minutes to a string
lda [timeptr],Y
jsr mkstr
sta str+14
ldy #tm_sec convert seconds to a string
lda [timeptr],Y
jsr mkstr
sta str+17
ldy #tm_year convert the year to a string
lda #'91'
sta str+20
lda [timeptr],Y
cmp #100
blt lb1
ldx #'02'
stx str+20
sec
sbc #100
lb1 jsr mkstr
sta str+22
lla timeptr,str
plb
creturn 4:timeptr
weekDay dc
|