Re: using rdtsc with 64 bits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> > > __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

-- 
Lukas Ruf
http://www.lpr.ch                                 http://www.maremma.ch    
    http://www.{{topsy,nodeos}.net,{promethos,netbeast,rawip}.org}
Wanna know anything about raw ip? Join rawip@rawip.org on www.rawip.org
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux