;
; subroutine time: assembly language routine to allow the acquisition
; of the current value of the system clock
;
; fortran call is : call time(hours,mins,secs,hsecs) 
;
; where j = hour:minute, i = secs:hsecs
;
;
;	interface to IBM professional fortran 1.0

stack_size	equ	6	; number of bytes needed on stack

data		segment
		db	'time    '
sp_save	dw	?
		dd	time
		dd	0
data		ends



;
code		segment	'code'
		assume	cs:code,ds:data,es:nothing,ss:nothing
		public	time
time		proc		far


;----------execute Profort standard entry linkage--------------------

		push	ds
		sub	bp,stack_size+6
		mov	ax,data
		mov	ds,ax
		mov	sp_save,sp
		mov	sp,bp
;---------------------------------------------------------------------

		mov	ah,2ch
		int	21h			; get time

;	es:[bx] =	&hours
;	es:4[bx] =	&mins
;	es:8[bx] =  &secs
;	es:12[bx] =	&hsecs

;	format returned by dos is dh(secs),dl(hsecs),ch(hours),cl(mins)

		lds	si,es:[bx]
		xor	ax,ax			; zero ax
		mov	al,ch
		mov	[si],ax		; store hours
		lds	si,es:4[bx]
		mov	al,cl
		mov	[si],ax		; store mins
		mov	al,dh
		lds	si,es:8[bx]
		mov	[si],ax		; store secs
		mov	al,dl
		lds	si,es:12[bx]
		mov	[si],ax		; store hsecs


;-------------perform exit linkage------------------------------------

		add	sp,stack_size+2
		ret
;---------------------------------------------------------------------

time		endp
code		ends
		end

stack		segment word stack 'stack'
		db	stack_size dup(?)
stack		ends
		end
stack		segment wo