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.
精彩评论