1/* 2** Copyright 2001, Travis Geiselbrecht. All rights reserved. 3** Distributed under the terms of the NewOS License. 4*/ 5 6#define FUNCTION(x) .global x; .type x,@function; x 7 8.text 9 10/* saves the conversion factor needed for system_time */ 11cv_factor: 12 .word 0 13 14FUNCTION(__x86_setup_system_time): 15 movl 4(%esp),%eax 16 movl %eax,cv_factor 17 ret 18 19/* long long system_time(); */ 20FUNCTION(system_time): 21 /* load 64-bit factor into %eax (low), %edx (high) */ 22 rdtsc /* time in %edx,%eax */ 23 24 pushl %ebx 25 pushl %ecx 26 movl cv_factor, %ebx 27 movl %edx, %ecx /* save high half */ 28 mull %ebx /* truncate %eax, but keep %edx */ 29 movl %ecx, %eax 30 movl %edx, %ecx /* save high half of low */ 31 mull %ebx /*, %eax*/ 32 /* now compute [%edx, %eax] + [%ecx], propagating carry */ 33 subl %ebx, %ebx /* need zero to propagate carry */ 34 addl %ecx, %eax 35 adc %ebx, %edx 36 popl %ecx 37 popl %ebx 38 ret 39