Loop in Intel x86 Assembly going on forever

后端 未结 2 2044
刺人心
刺人心 2020-12-21 18:25

I\'m currently learning Intel x86 Assembly, and I\'ve run into a problem while trying to construct a simple loop, which loops 10 times. It\'s supposed to stop after the 10 l

2条回答
  •  轮回少年
    2020-12-21 19:08

    If the "overwriting"-problem is solved and if we are begining with a counter of 10 for decreasing the counter each circuit and if we branch if the value of the counter is greater or equal than 0, then we become a looping of 11 times.

    Alternativly we can also use the zeroflag to branch (if the zeroflag is not set):

                    dec     cl
                    jnz     _loop_start
    

    The "dec" instruction already involve the flag register, so we do not need the "cmp"-instruction, if we want to check if a value was decreasing to zero.

    Dirk

提交回复
热议问题