code timing , whats wrong ?
code timing , whats wrong ?
well
i have tryed to time my code, using the RDTSC instrcution
but each time i use the instruction, Extreamly many cycles have passed since the last time,
and i dont have any code in betewen
the source is attached ( it is compiled as a "com" program, i have tryed on os, no change)
the time keeps changeing, but the difference is far too high.
Kmt dk
i have tryed to time my code, using the RDTSC instrcution
but each time i use the instruction, Extreamly many cycles have passed since the last time,
and i dont have any code in betewen
the source is attached ( it is compiled as a "com" program, i have tryed on os, no change)
the time keeps changeing, but the difference is far too high.
Kmt dk
- Attachments
-
- test.asm
- the source file
- (1.29 KiB) Downloaded 99 times
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: code timing , whats wrong ?
This looks wrong:
Code: Select all
mov [si],eax
mov [si+2],edx
Re: code timing , whats wrong ?
the code stores the 64 bit integer at the variable ( i use si to point)
but have i done it reverse , so edx shuld be the first , and then eax.??
KMt dk
but have i done it reverse , so edx shuld be the first , and then eax.??
KMt dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
-
- Member
- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: code timing , whats wrong ?
Did you mean:
Code: Select all
mov [si],eax
mov [si+4],edx
- Masterkiller
- Member
- Posts: 153
- Joined: Sat May 05, 2007 6:20 pm
Re: code timing , whats wrong ?
it returns EDX:EAX, so EAX store less-significant bytes and they are 32-bit = 4 bytes, you store them between two bytes so rewrite the EAX. In the memory less-significant bytes are stored in lower addresses.
Edit: Lower address is the address that you do not add offset (since the offset is positive). EAX is less-significant, so it should be stored at lower address e.g. [si+0], not [si+4]
Edit: Lower address is the address that you do not add offset (since the offset is positive). EAX is less-significant, so it should be stored at lower address e.g. [si+0], not [si+4]
Last edited by Masterkiller on Tue Nov 18, 2008 8:19 am, edited 2 times in total.
ALCA OS: Project temporarity suspended!
Current state: real-mode kernel-FS reader...
Current state: real-mode kernel-FS reader...
Re: code timing , whats wrong ?
* DOH
i forgot i was using 32 bit instructions, so that was one Big error.( the reason is i have worked on 16 bit too much ... )
so the code shuld look like this:
I will just test it ( and if i dont post/ edit, it means that i dont have tryed it..)
KMT dk
i forgot i was using 32 bit instructions, so that was one Big error.( the reason is i have worked on 16 bit too much ... )
so the code shuld look like this:
Code: Select all
mov [si],edx
mov [si+4],eax
KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
-
- Member
- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: code timing , whats wrong ?
kmtdk wrote:* DOH
i forgot i was using 32 bit instructions, so that was one Big error.( the reason is i have worked on 16 bit too much ... )
so the code shuld look like this:I will just test it ( and if i dont post/ edit, it means that i dont have tryed it..)Code: Select all
mov [si],edx mov [si+4],eax
KMT dk
Code: Select all
mov [si],eax
mov [si+4],edx
Re: code timing , whats wrong ?
Well
now i got it to work, but one thing shuld be told
this does not work 100 % under windows, but it does ( it counts wierd), but you can see a different
the code is attached , and use it as you want, but if you want to publise the code, ask for permission.
bye the way, the code is Not optimised .
happy timing ,:P
KMT dk
now i got it to work, but one thing shuld be told
this does not work 100 % under windows, but it does ( it counts wierd), but you can see a different
the code is attached , and use it as you want, but if you want to publise the code, ask for permission.
bye the way, the code is Not optimised .
happy timing ,:P
KMT dk
- Attachments
-
- test.asm
- The timing file, see inside where to place code to test.
- (3.46 KiB) Downloaded 96 times
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: code timing , whats wrong ?
I expect the TSC to jump large amounts when the OS decides to yield the CPU to another process. Also, unsynchronized counters can cause strange effects (going back in time, anyone?) when windows tosses the application between cores (windows' CPU affinity sucks big time, try forcing applications onto a single core and see whether it works better)