|
-
Oct 18th, 2005, 05:42 AM
#1
Loop????
In my book it says that LOOPZ works like this...
ECX = ECX - 1
if ECX > 0 and ZF = 1 then jump <label>
Eh? How is it possible for that condition to be true?? if ECX is greater than 0 then surely its not possible for ZF to be 1, thats like saying...
if ECX > 0 and ECX = 0 then jump <label>
What am I missing here?
I don't live here any more.
-
Oct 23rd, 2005, 06:50 AM
#2
Last edited by Andy_P; Oct 23rd, 2005 at 06:59 AM.
-
Oct 23rd, 2005, 09:52 AM
#3
Re: Loop????
 Originally Posted by wossname
In my book it says that LOOPZ works like this...
ECX = ECX - 1
if ECX > 0 and ZF = 1 then jump <label>
Eh? How is it possible for that condition to be true?? if ECX is greater than 0 then surely its not possible for ZF to be 1, thats like saying...
if ECX > 0 and ECX = 0 then jump <label>
What am I missing here?
AFAIK, it means that while ECX > 0 and ZF = 1 then execute the THEN statement, if either one of them fails, i.e. IF ECX > 0 but ZF = 0 (or not equals 1) then execute the ELSE statement or come out of the IF statement.
but i may be wrong, it's been a long time since i touched Assembly language.
-
Oct 24th, 2005, 01:13 AM
#4
Re: Loop????
I think Andy is closer. If I can remember that entire book on x86 assembly, it said that the CX register didn't directly change the ZF flag value.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Oct 24th, 2005, 01:13 AM
#5
Re: Loop????
read this, else look at the links provided by Andy for details:
Some forms of the loop instruction (LOOPcc) also accept the ZF flag as a condition for terminating the loop before the count reaches zero. With these forms of the instruction, a condition code (cc) is associated with each instruction to indicate the condition being tested for. Here, the LOOPcc instruction itself does not affect the state of the ZF flag; the ZF flag is changed by other instructions in the loop.
-
Oct 24th, 2005, 04:48 AM
#6
Re: Loop????
Wow this is an old thread. I worked this out days ago 
It occured to me that the loop instructions don't affect ZF.
I don't live here any more.
-
Nov 9th, 2005, 07:24 AM
#7
Addicted Member
Re: Loop????
BTW...since you are interested in performance...avoid LOOPcc ...it is slower on newer PCs (newer than 486 )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|