Hi,
On all X86 architecture, the Time Stamp Counter (TSC) is a 64-bit register counts the number of cycles since reset. It is used as a precise timer (a clock cycle delta).
https://en.wikipedia.org/wiki/Time_Stamp_Counter
Is there something that could be equivalent on SH4 architecture ?
I need a timer at clock cycle ticks.
Thanks for your help.
Equivalent to RTSC x86 indtruction on SH4
- Newbie
- Insane DCEmu
- Posts: 171
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Sat Jul 27, 2013 1:16 pm
- Has thanked: 0
- Been thanked: 0
-
- DC Developer
- Posts: 108
- Joined: Sun Oct 04, 2009 11:13 am
- Has thanked: 2 times
- Been thanked: 90 times
Re: Equivalent to RTSC x86 indtruction on SH4
The closest thing to the x86 TSC would be using the undocumented performance monitor to count CPU cycles. That gives you a 48-bit timer. The normal, documented hardware timers don't have the resolution to give you exact CPU cycles.
Re: Equivalent to RTSC x86 indtruction on SH4
Thanks you very much, I will see this more closely.
I am every time amazed the number of things undocumented ...
I am every time amazed the number of things undocumented ...
- BlueCrab
- The Crabby Overlord
- Posts: 5660
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: Equivalent to RTSC x86 indtruction on SH4
Are you sure that the performance monitor is actually available on the Dreamcast's CPU? The Linux source code seems to imply that there are many SH-4 CPUs on which it is not available.
It wouldn't surprise me if it is, but it wouldn't surprise me if it isn't either.
It wouldn't surprise me if it is, but it wouldn't surprise me if it isn't either.
-
- DC Developer
- Posts: 108
- Joined: Sun Oct 04, 2009 11:13 am
- Has thanked: 2 times
- Been thanked: 90 times
Re: Equivalent to RTSC x86 indtruction on SH4
It works, I've tried it. (Although I had trouble getting the second counter to work consistently, it might just be a problem with my implementation.)
- BlueCrab
- The Crabby Overlord
- Posts: 5660
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: Equivalent to RTSC x86 indtruction on SH4
Cool. Always good to know that something has been tested and isn't just a theoretical possibility.
-
- DCEmu Crazy Poster
- Posts: 28
- Joined: Wed Apr 23, 2014 3:04 pm
- Has thanked: 0
- Been thanked: 0
Re: Equivalent to RTSC x86 indtruction on SH4
fun fact: Virtua Fighter 3TB uses SH4 performance monitor. game set 1st monitor to event 0x23 (elapsed cycles) and some time later read counter. probably dev/debug leftovers, not actually required for this game functioning.