开发者

What does the `test` instruction do? [duplicate]

开发者 https://www.devze.com 2023-03-06 09:21 出处:网络
This question already has answers here: 开发者_JAVA技巧 `testl` eax against eax? (8 answers) Closed 5 years ago.
This question already has answers here: 开发者_JAVA技巧 `testl` eax against eax? (8 answers) Closed 5 years ago.

I'm looking at some small assembler codes and I'm having trouble understanding the TEST instruction and its use. I'm looking at the following code at the end of a loop:

8048531:    84 c0                   test   al,al
8048533:    75 dc                   jne    8048511 <function+0x2d>

The way i understand TEST is that it works a bit like the AND operator and it sets some flags. I guess I don't really understand how the flags work. test al,al to me looks like it checks the same lower bits and will always get the same results.

Can someone explain?


It tests the register against itself, just to set the flags. The result will be different for a zero and a non-zero value.

0

精彩评论

暂无评论...
验证码 换一张
取 消