Results 1 to 7 of 7

Thread: Loop????

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  2. #2
    Fanatic Member Andy_P's Avatar
    Join Date
    May 2005
    Location
    Dunstable, England
    Posts
    669

    Re: Loop????

    Do these links help any?

    http://enrico.phys.cmu.edu/QCDcluste...ence/vc162.htm

    http://faydoc.tripod.com/cpu/loopz.htm

    http://docs.sun.com/app/docs/doc/802...oo?l=fr&a=view


    Looks like th ZF flag is not affected by the change in ECX, but from other things within the loop.

    Hope that helps.
    Last edited by Andy_P; Oct 23rd, 2005 at 06:59 AM.
    Using Windows XP Home sp3
    Mucking around with C# 2008 Express
    while ( this.deadHorse ) { flog( ); }


  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Loop????

    Quote 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.
    Show Appreciation. Rate Posts.

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    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

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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.
    Show Appreciation. Rate Posts.

  6. #6

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  7. #7
    Addicted Member
    Join Date
    Aug 2005
    Location
    York
    Posts
    197

    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
  •  



Click Here to Expand Forum to Full Width