home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CASM.ARJ
/
CLOCK.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-10-02
|
1KB
|
60 lines
;_ clock.asm Fri Oct 2 1987 Modified by: Walter Bright */
; Copyright (C) 1986-1987 by Northwest Software
; All Rights Reserved
; Written by Walter Bright
include MACROS.ASM
begcode clock
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Return the time in 1/100ths of a second since midnight.
; Useful for timing various things.
; Use:
; clock_t clock(void);
c_public clock
func clock
bdos 2Ch ;get system time
; compute ticks + 100L * (secs + 60L * (mins + 60 * hours))
; DL DH CL CH
push DX
push DX
mov BX,60
mov AL,BL ;60 min/hr
mul CH ;AX = 60 * hours
clr CH ;CX = minutes
add AX,CX ;AX = mins + 60 * hours
mul BX ;DXAX = 60 * (mins + 60 * hours)
pop BX
mov BL,BH
clr BH ;BX = seconds
add AX,BX
adc DX,0 ;DXAX = secs + 60L * (mins + 60 * hours)
mov BX,AX
mov AX,DX
mov CX,100
mul CX
xchg AX,BX
mul CX
add DX,BX ;DXAX = 100L * (secs + 60L * (mins + 60 * hours))
pop BX
clr BH
add AX,BX
adc DL,BH ;DXAX = ticks + ...
; (will never overflow into DH)
ifndef MSC
mov BX,AX
mov AX,DX
endif
ret
c_endp clock
endcode clock
end