A86: recursion


[Prev][Next][Index][Thread]

A86: recursion




I've gotten a few emails about people wanting to know the difference between
recursion and looping in asm, so I'm going to give a little explanation.

This is an example of a recursive call:

doThis:
 dec a
 ret z
 jr doThis        ;you can look at this as: <call doThis / ret>

This is an example of a loop:

doThis:
 dec a
 jr nz,doThis

In a recursive algorithm a condition is checked, if the condition is met
then it _returns_, otherwise it contiues calling itself.  In a loop, it
loops until a certain condition becomes true.