Category : C Source Code
Archive   : LHA211S.ZIP
Filename : _CNVTIME.ASM

 
Output of file : _CNVTIME.ASM contained in archive : LHA211S.ZIP
;***********************************************
; _cnvtime.asm -- replacement of LSI C-86
; run time library routine
;***********************************************
page 0, 128

include amscls.inc
$_init GEN

LHA = 1

CGROUP GROUP TEXT
DGROUP GROUP DATA,BSS
assume cs:CGROUP, ds:DGROUP, ss:DGROUP

TEXT segment byte public 'CODE'
TEXT ends

DATA segment word public 'DATA'
DATA ends

BSS segment word public 'DATA'
BSS ends

tm struc
tm_sec dw 1 dup (?)
tm_min dw 1 dup (?)
tm_hour dw 1 dup (?)
tm_mday dw 1 dup (?)
tm_mon dw 1 dup (?)
tm_year dw 1 dup (?)
tm_wday dw 1 dup (?)
tm_yday dw 1 dup (?)
tm_isdst dw 1 dup (?)
tm ends

DATA segment word public 'DATA'
daysmonth label word
m3 dw 31
m4 dw 30
m5 dw 31
m6 dw 30
m7 dw 31
m8 dw 31
m9 dw 30
m10 dw 31
m11 dw 30
m12 dw 31
m1 dw 31
m2 dw 29
DATA ends

TEXT segment byte public 'CODE'
public _convtime_
_convtime_ proc near
push cx
push dx
push si
push di
mov si, ax

mov di, 60
mov ax, [bx + 2]
xor dx, dx
div di
mov cx, ax
mov ax, [bx]
div di ; cx:ax
mov tm_sec[si], dx

xchg ax, cx
xor dx, dx
div di
xchg ax, cx
div di ; cx:ax
mov tm_min[si], dx

mov di, 24
xchg ax, cx
xor dx, dx
div di
xchg ax, cx
div di ; cx:ax
mov tm_hour[si], dx

mov cx, ax
xor dx, dx
mov di, 7
div di
mov tm_wday[si], dx
mov ax, cx

mov cx, 68
; adjust to 1968-3-1
$_if , C, OR
$_c , AE
sub ax, 365 * 32 + 8 ; adjust to 2000-3-1
mov cx, 100
if 0
xor dx, dx
mov di, 365 * 400 + 97
div di
push dx
mov di, 400
mul di
add cx, ax
pop ax
endif
xor dx, dx
mov di, 365 * 100 + 24
div di
push dx
mov di, 100
mul di
add cx, ax
pop ax
$_endif
xor dx, dx
mov di, 365 * 4 + 1
div di
shl ax, 1
shl ax, 1
add cx, ax

mov di, 365
mov ax, dx
xor dx, dx
div di
$_if , AE
dec ax
add dx, di
$_endif
add ax, cx
ifndef LHA
mov bx, dx
add bx, 31 + 28
endif
mov cx, 2
mov di, offset DGROUP:daysmonth
$_while , AE
inc di
inc di
inc cx
$_enddo
add dx, [di]
ifndef LHA
$_if , AE
inc ax
sub cx, 12
sub bx, 365
$_else
$_if , Z
inc bx
$_endif
$_endif
else
$_if , AE
inc ax
sub cx, 12
$_endif
endif

inc dx
mov tm_mday[si], dx
mov tm_mon[si], cx
mov tm_year[si], ax
ifndef LHA
mov tm_yday[si], bx
endif
pop di
pop si
pop dx
pop cx
ret
_convtime_ endp
TEXT ends

end


  3 Responses to “Category : C Source Code
Archive   : LHA211S.ZIP
Filename : _CNVTIME.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/