;       SCCSID = @(#)timnow.asm	6.1 90/11/18
;      SCCSID = @(#)timnow.asm	  13.2 90/01/25
;***	TIMNOW - Gets times out of the global info seg
;
;	timNow - Gets the current time out of the global info seg
;
;	msNow - Gets the number of milliseconds since boot time
;

.286

ifdef MEDIUM_MODEL
.model medium, pascal
else
.model small, pascal
endif


include infoseg.inc   ; get struc definition for the info seg

.data

extrn pGIS:dword

ifdef MEDIUM_MODEL
.code	_TEXT
else
.code
endif

;**	timNow - Gets the current time out of the global info seg
;
;	tim = timNow()
;
;	Returns current time in secs since jan 1 1970
;		in (dx:ax)
;

public timNow
timNow	proc
	les	bx,pGIS 	; point es:bx to the global info seg

	cli			; disable the interrupts so we can get
				;   the hole dword at once

; Get pGIS->time into dx:ax
	mov	ax,Word ptr es:[bx].SIS_BigTime 	; get low word
	mov	dx,Word ptr es:[bx].SIS_BigTime + 2	; get hi word

	sti			; reenable the interrupts
	ret
timNow	endp



;**	msNow - Gets the number of milliseconds since boot time
;
;	cMSec = msNow()
;
;	Returns milliseconds since boot in (dx:ax)
;

public msNow
msNow	proc
	les	bx,pGIS 	; point es:bx to the global info seg

	cli			; disable the interrupts so we can get
				;   the hole dword at once

; Get pGIS->msec into dx:ax
	mov	ax,Word ptr es:[bx].SIS_MsCount    	; get low word
	mov	dx,Word ptr es:[bx].SIS_MsCount + 2	; get hi word

	sti			; reenable the interrupts
	ret
msNow	endp

end
