Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 4th, 2006, 1:27 AM   #1
eax
Newbie
 
eax's Avatar
 
Join Date: Mar 2006
Posts: 17
Rep Power: 0 eax is on a distinguished road
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.
eax is offline   Reply With Quote
Old Apr 4th, 2006, 10:20 PM   #2
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 3 Kaja Fumei is on a distinguished road
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
Kaja Fumei is offline   Reply With Quote
Old Apr 6th, 2006, 11:52 AM   #3
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>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.
Narue is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC