On Tuesday 10 September 2002 02:47 am, Lukas Ruf wrote: > > > > __asm rdtsc > > > > __asm sub eax, time_low // Find the difference > > > > __asm sub edx, time_high > > > > > > > > __asm div mhz // Unsigned divide EDX:EAX by mhz > > > > > > > > __asm mov time, eax > > > > printf("Seconds: %u\n", time); > > > > > > > > What exactly does the div line do? > > > > > > divides the number of cycles measured by the number of hertz which > > > leads to the seconds consumed ,-) > > > > I know that's what it does, > > but what is the dividend? Is it the 64-bit number created by combining > > eax and edx? I don't understand where the dividend on that line is coming > > from. And if it is a 64-bit number, how do I change the mull assembly in > > do_fast_getttimeoffset to do the same thing? > > From the Intel Instruction Set Reference Manual, page 219: > (http://developer.intel.com/design/pentium4/manuals/245471.htm) > > Operand Size Dividend Divisor Quotient Remainder Maximum Quotient > Word/byte AX r/m8 AL AH 255 > Doubleword/word DX:AX r/m16 AX DX 65,535 > Quadword/doubleword EDX:EAX r/m32 EAX EDX 232 1 > > - If you read the rdtsc, the counters are stored in EDX:EAX. > - If you read the lines I posted, the dividend is stored in EDX:EAX > - If you read further these lines, the divisor may be a register or a > memory location with size of 32bit. > - If you have any further questions, please ask. > > --lpr So in this case: __asm__("mull %2" :"=a" (eax), "=d" (edx) :"rm" (fast_gettimeoffset_quotient), "0" (eax)); So this inline assembly does Move the memory location at eax into %eax %edx:%eax = %eax * fast_gettimeoffset_quotient It then moves %edx to the memory location edx and %eax to the memory location eax. The real result should be held at this point in edx unless the result was too large to hold in %edx alone. Am I right? Anton -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/