![]() |
[x86]Instruction test setting the zero flag
Was currently stepping through an application and found a piece of code that I could not understand.
My question is: How can a TEST instruction set the ZERO flag when testing a byte with the same byte? :
...Thanks for your help! /Klarre |
When CL = 0 of course...
|
True. The TEST instruction ANDs the two operands and sets the flags accordingly. If the two operands are the same thing, the result will be zero only if the operand(s) are zero. It is really a dumb thing to do, in this case. Comparing CL to zero and jumping accordingly would be much clearer. But coders often do dumb things. That's why they wear dirty teeshirts and smell bad.
|
Quote:
I agree though, the clarity leaves something to be desired. However, if this was compiler-generated assembly (as seems likely from the context), the programmer has no business expecting it to be clear if optimizations are enabled. |
Re: [x86]Instruction test setting the zero flag
Arguing about the readability of things such as 'XOR REG,REG'/'TEST REG,REG' is stupid. Someone should not be complaining about how they can understand somebody elses source when it's such a simple matter.
Furthermore, such instructions are not only shorter, they are a few clocks faster. |
Re: [x86]Instruction test setting the zero flag
Dredging up a six month old thread to call people stupid, and having your first two posts in a forum call people stupid, is a sure way to make a name for yourself. Unfortunately, that name isn't a very nice one.
|
Re: [x86]Instruction test setting the zero flag
Quote:
For you to even bring up the argument of repertoire in a forum which is essentially made for helping others is laughable, so please; consider this my first and only response to you. |
Re: [x86]Instruction test setting the zero flag
I wasn't having a go at you because you haven't posted much, if that is what you mean by "argument of repertoire". Extra helpers here are always welcome. Calling people who are asking questions and people who are answering them "stupid" is not helping, in fact it is a great hindrance to a forum such as this as it is likely to turn people away.
|
| All times are GMT -5. The time now is 12:39 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC