there is in pentium optimisation HELP: " 26.14 problematic instruction/Test instruction"

this instruction that surprises me:

Examples:

TEST ECX,ECX ; pairable<====??
Why test 2 same reg?
.....
or:
TEST EAX,EAX ;<========????
JZ SHORT BS1 ;<======== why JZ;CZ is always to zero?
MOV DWORD PTR ,EAX
MOV DWORD PTR ,0
FILD QWORD PTR
FSTP QWORD PTR
WAIT ; WAIT only needed for compatibility with old 80287 processor

MOV ECX, DWORD PTR
SHR ECX,20 ; isolate exponent
SUB ECX,3FFH ; adjust
TEST EAX,EAX ; clear zero flag
BS1:

thanks
Posted on 2002-02-14 06:28:03 by franlou
the test op is a logical and, it sets the flags but does not store the result.

anding any number with itself will only serve one purpose, test for zero....

In fact you've commented it as such later on!

Mirno
Posted on 2002-02-14 06:35:10 by Mirno
anding any number with itself will only serve one purpose, test for zero....

Much more :)
We also can use information about value from all three
"value description" flags ZF,SF and PF
Let say we call SomeProc and if it's OK the proc will return
positive number, else it returns three error codes
0
-1
-2
In one test we can set all nessesery flags to handle all 4 cases:
call SomeProc
test eax,eax
je CaseErrZero
jns CaseOk
jp CaseMinus1
;and here is CaseMinus2

It also can be used in addition to main perpose to clear CF etc.
And many other cases.
Posted on 2002-02-14 07:03:59 by The Svin
The branch prediction unit on newer chips have a problem with predicting 3 jumps within 32 bytes of code, iirc.
Posted on 2002-02-14 10:29:50 by bitRAKE