Welcome, Guest. Please login or register.

Author Topic: how to use timer.device's EClock unit's higher LONG  (Read 2579 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Trev

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« on: May 10, 2005, 07:24:22 PM »
This has Mac in the name, but it's all about 64-bit integer math on 68k.

http://www.mactech.com/articles/develop/issue_26/semchishen.html
 

Offline Trev

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« Reply #1 on: May 11, 2005, 12:56:45 AM »
No problem. I wouldn't use a double unless you really need the dangly bits. For timing, I'm guessing you just need to know whether or not you've passed a certain interval. If you do need the extra precision, a bit of calculus might get you what you need without resorting to floating-point math.

Trev
 

Offline Trev

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show all replies
Re: how to use timer.device's EClock unit's higher byte
« Reply #2 on: May 12, 2005, 11:02:59 PM »
It should work as long the structure is packed and stored just like a big endian 64-bit long in memory. But you're better off doing something like this:

long long val = (long long)((ptr->ev_hi << 32) + ptr->ev_lo);

And then you don't have to worry about how EClockVal is stored. Plus, the shift and add will allow the compiler to optimize the code. Casting pointers may require guessing on the compiler's part, which may lead to no optimization at all. The VBCC manual does a pretty good job of documenting what's optimized and what's not.

Per VBCC, the following register pairs are used for storing long long values: d0/d1, d2/d3, d4/d5, and d6/d7. Keep that in mind if you plan on using assembler or direct register references in your C code.

But if you're going to use floating point division, then you may as well keep your code simple and use double values throughout.

Trev