utdtM
* S*BASIC Date routines
*
* Released under the GNU GENERAL PUBLIC LICENSE, Version 2, June 1991
*
* Functional code by Laurence Reeves 1994(?)+
*
* Re-packaged by pjwitte 2oo6
*
* V0.01 September 27th 2006
*
section code
xdef ut_cvdt
include dev8_keys_sbasic
dot equ 1961
* Input: d1 = year + 6 longs on ri stack
* Return: d1 = seconds, resetting ri stack
* d2-d4/d6/a0/a2 are all smashed.
* Number of days preceeding each month in a non-leap year, less one.
monoff dc.w -1,30,58,89,119,150,180,211,242,272,303,333
ut_cvdt
lea.l 6*4(a1),a1 6 longs to
move.l a1,sb_arthp(a6) tidy off stack
* d0 - o- ???
* d1 -i o- input year, output seconds since dot
* d2 - o- zero
* a1 -ip - pointer rel a6 to end of 20 bytes, 5 longs: mm,dd,hh,mm,ss
* a6 -ip - base for a1
* d3/d4 and d6.lsb destroyed
bf_datez
moveq #-16,d2
add.l a1,d2 offset on stack to days
move.b d1,d6
sub.w #dot,d1 (year-dot)
move.w d1,d4
move.w #365,d0
bsr.s muladd ... * 365 + days ...
lsr.w #2,d4
add.w d4,d1 ... + (year-dot) div 4 ...
move.w -18(a6,a1.l),d0 get month
add.w d0,d0
add.w monoff-2(pc,d0.w),d1 ... + offset(month-1) ...
lsl.b #6,d6 if it's a leap year
bne.s dhms
subq.w #6,d0 and it's gone february
bcs.s dhms
addq.l #1,d1 then ... + 1 ... (feb 29 not in offset table)
dhms
moveq #24,d0
bsr.s muladd ... * 24 + hrs ...
hms
jsr mul60add ... * 60 + mins ...
ms
* bsr.s mul60add ... * 60 + secs
* Multiply and add subroutine
* Entry:
* d0.w = w, 16 bit multiplier
* d1.l = l, 32 bit multiplicand
* d2.l = offset on ri stack to "p", the 32 bit addend
* Exit:
* d0.l = 0
* d1.l = l*w+p
* d2.l 4 added
* d3.l smashed
mul60add
moveq #60,d0
muladd
move.l d1,d3
swap d3
mulu d0,d3
swap d3 d3(msw) = l(msw) * w
clr.w d3 d3(lsw) = 0
mulu d0,d1 d1 = l(lsw) * w
add.l d3,d1 d1 = l * w
add.l 0(a6,d2.l),d1 add p
addq.l #4,d2 move on pointer
rts
*
end
Back to Index
HTML generated by the amazing asm2htm !
2006 Oct 01 00:36:34