Simple question:
what is the difrence from the TEST mnemonic and CMP mnemonic ?
cyas
jean/ Coder7345
what is the difrence from the TEST mnemonic and CMP mnemonic ?
cyas
jean/ Coder7345
TEST is AND but doesn't save the results unlike AND, this is usually to TEST for carry, overflow, parity, signed or zero.
E.G.
E.G.
mov eax, -1
test eax, eax
js ;Check if EAX is signed(negative)
As Agner Fog describes in his Pentium Optimizations (masm32/help/) document.
The test instruction is pairable.
It is suitable to be used for boolean operations.
its faster using test
The test instruction is pairable.
It is suitable to be used for boolean operations.
better use:
test eax,eax
je label
than use:
cmp eax, 0
je label
its faster using test
test = and (without writing result in the first operand)
cmp = sub (without writing result in the first operand)
The are used to set flags wich will tell about data in the first
opernad. The flags then may be used for further operations.
Mostly for JCC but not exlusivly.
Actually there is no any jcc like ja jb etc.
It is just aliases for real condition (flag states) operation
Actuall conditions are on the left on your screen:
Alias name make sence when you use them after sub or cmp
operations.
Test (and) operation mostly used to check (test) or change (and)
particular bit(s)
Test can be also used to check some data about operand.
for example:
test eax,eax
may say you if eax is zero (ZF will be set), negative (SF will be set)
or last byte has parity of bits (PF will be set)
cmp = sub (without writing result in the first operand)
The are used to set flags wich will tell about data in the first
opernad. The flags then may be used for further operations.
Mostly for JCC but not exlusivly.
Actually there is no any jcc like ja jb etc.
It is just aliases for real condition (flag states) operation
Actuall conditions are on the left on your screen:
Real conditions. Alias names.
=============================================
CF=0 & ZF=0 JA
JNBE
---------------------------------------------
CF=0 JAE
JNB
JNC
---------------------------------------------
CF=1 JB
JNAE
JC
---------------------------------------------
CF=1 || ZF =1 JBE
JNA
---------------------------------------------
ZF=1 JE
JZ
---------------------------------------------
ZF=0 and SF=OF JG
JNLE
---------------------------------------------
SF<>OF JNGE
JL
---------------------------------------------
ZF=1 or SF<>OF JLE
JNG
---------------------------------------------
ZF=0 JNE
JNZ
---------------------------------------------
OF=0 JN0
---------------------------------------------
OF=1 JO
---------------------------------------------
PF=0 JNP
JP0
---------------------------------------------
SF=0 JNS
---------------------------------------------
SF=1 JS
=============================================
Alias name make sence when you use them after sub or cmp
operations.
Test (and) operation mostly used to check (test) or change (and)
particular bit(s)
Test can be also used to check some data about operand.
for example:
test eax,eax
may say you if eax is zero (ZF will be set), negative (SF will be set)
or last byte has parity of bits (PF will be set)