![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 17
Rep Power: 0
![]() |
confused about the usage of Test instruction
I know that test instruction in assembly language is same as and instruction excpet that destination in previous instruction doesnot effected.
But i dont understand the usage of "test instruction" , please if possible give me an example of its usage. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 134
Rep Power: 3
![]() |
It is a lot like the "cmp" instruction and is often found right before a conditional jump. The difference is the "cmp" instruction uses subtraction to compare them and set the flags while test uses a bitwise AND.
The most common usage of test is to see if a value is 0 or not: test eax, eax; eax & eax == 0 only if eax == 0 jz .L1 |
|
|
|
|
|
#3 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>But i dont understand the usage of "test instruction"
'test a,b' is identical to 'and a,b' except that test doesn't write the result to a. The usage reflects that. test is used when all you care about is how the flags are set after the operation.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|