Herbert's XOR (done with praying yet?)

From: wolfgang kern (nowhere_at_nevernet.at)
Date: 01/29/05


Date: Sat, 29 Jan 2005 15:47:24 +0100

Sorry for the new topic, I cannot reply to threads 'that' long.

"The Half" skrev:

| Okye. Assuming nothing I test again, during a more relaxed stage of the
| app :
 
| 3 seperate tests
|
| example 1 clocks in at 027, 027, 26 ....ect
| example 2 clocks in at 0113, 1d, D6 ....etc
| example 3 clocks in at 013, 013, 013 ...etc
|
| Seems to me Betov still have the final word on assembly.
| All this is simply nonsense.
|
|
| Code used :
|
| [test1:0 Test2:0 Test3: 0]
| TestProc:
| rdtsc | push eax edx
|
| mov eax a ;5 bytes
| not D$eax | add eax 4 | ;5 bytes
| not D$eax | add eax 4 | ;5 bytes
| not D$eax ;2 bytes
|
| rdtsc | pop ecx ebx
| sub eax ebx
| mov D$test1 eax
|
| rdtsc | push eax edx
|
| mov eax a
| not D$eax | add eax 4 |
| not D$eax | add eax 4 |
| neg D$eax | dec D$eax
|
| rdtsc | pop ecx ebx
| sub eax ebx
| mov D$test2 eax
|
|
| rdtsc | push eax edx
|
| not D$a | not D$a | not D$a ;18 bytes
|
| rdtsc | pop ecx ebx
| sub eax ebx
| mov D$test3 eax
| int 3
|
| ret
| --
| http://www.TheWannabee.org

How about:

[test1:0 Test2:0 Test3: 0]
TestProc:
     rdtsc |push eax |push edx
     mov eax test1 ;5 bytes
     XOR D$eax 0-1 ;3 bytes
     XOR D$eax+4 0-1 ;4 bytes
     XOR D$eax+8 0-1 ;4 bytes
     rdtsc
     sub eax D$esp+4
     sbb edx D$esp
 int3 ;16 bytes, ~13 cycles (+11 for one rdtsc)
     add esp +8
     ret
  
I think Herbert meant the logical construction of an (inverting)
XOR-function with only two NOT and just using OR and AND:

      not
       |\ ___ A B XOR
A O-o--| x--| \ ___
    | |/ |and|----\ \ 0 0 0
B O-|-o-----|___/ |or|---O XOR 0 1 1
    | | ___ ,-/___/ 1 0 1
    '-|-----| \ | 1 1 0
      | |\ |and|--'
      '-| x-|___/
        |/
       not

__
wolfgang



Relevant Pages

  • Re: this is the time to pray
    ... > rdtsc | push eax edx ... > sub eax ebx ... > mov D$test1 eax ...
    (alt.lang.asm)
  • Re: "We Never Use Assembly Language"
    ... tests, I did, and posted, using rdtsc show the RosAsm one to be faster. ... xor eax eax ... while ecx> 0 ...
    (alt.lang.asm)
  • Re: "We Never Use Assembly Language"
    ... This greatly enhances the accuracy of timings, compared to putting them at the main: ... rdtsc | push eax ... mov ecx D$n ... xor eax eax ...
    (alt.lang.asm)
  • Re: No difference on my machine
    ... xor eax, eax ... ; mov eax, 0 ... ; xor eax, eax ... I've seen code, from folks who may or may not know what they're doing, which uses *three* cpuid's before each rdtsc. ...
    (alt.lang.asm)
  • Re: rdtsc on Athlon 64 x2 speeds up, slows down
    ... rdtsc counts the clock cycles as required, ... >> after RDTSC, and before each CPUID an XOR EAX, EAX ... > when using the Time Stamp Counter (TSC) in the face of various power ...
    (comp.lang.asm.x86)