-1

I have the following assembly line which I want to understand:

TEST DL,DL
JE SHORT 6C250EDF

So, in DL we have the character 'C'. Actually, the value 43 which is ANSCII code for 43. I know that TEST is like AND, but in TEST we don´t store the result.

But ollydbg says that the jump is not taken. How that can be? 43 AND 43 is equal, right ? so, why not jump?

my second question would be: How can i translate that in C code ?

user3097712
  • 1,565
  • 6
  • 27
  • 49
  • If you want to compare for equality, and make JE make sense, then you need to use CMP. TEST only sets the Z flag if the result is 0. It is not, it is 43. JZ is an alias for JE, use JZ here to make sense. – Hans Passant May 25 '14 at 02:04

2 Answers2

3

You are right that TEST does logical AND on its operands, but your JE test checks the Zero flag, and the test instruction sets the ZF when the result of AND is zero, which only happens when DL is zero:

http://en.wikipedia.org/wiki/TEST_%28x86_instruction%29

physdad
  • 46
  • 2
  • ah, ok. This means that with TEST DL, DL (DL=43) the ZF is 0. And the jump is only taken if ZF=1, which is not the case here, right? So, if i try to transform into C language, then i would write something like : if ((43&43) == 0) { .....} – user3097712 May 26 '14 at 00:49
  • In idiomatic C, you'd just say `if (dl == 0) {...}`. The `TEST` instruction is just a convenient way to cause a condition register to be set. – Russell Borogove May 28 '14 at 01:41
  • ok, thank you for the explanation with idiomatic C. It also helps a lot.. – user3097712 May 29 '14 at 22:53
0

Here you code is testing if DL ise equal to null caracater

Stevlulz
  • 11
  • 1