Making variable delay routines
Delay loops are nasty, and you shouldn't be using them very often. 

Alternatives include timers, periodic interrupts and such like. 

That said, they're occasionally useful. Be sure to take care of the WDT somewhere during the looping or you could have some nasty problems. 

There's an assembly language code generator here that generates cycle perfect assembly delay routines (delay time fixed at assembly, not variable). 

There's no reason why you couldn't make a cycle-perfect programmable delay generator in asm but I think it would be a bit complex. Interrupts would cause inaccuracy, but often you only need to guarantee a minimum time and if it runs (say) 11ms rather than 10ms it's not a big deal.