Generate nested-loop PIC16 assembly delay routines from crystal frequency and desired delay.
For the 4 MHz example, your equation is:
The generator scales the required instruction cycles according to the selected crystal frequency. It searches the three 8-bit loop counters (1–255) for a combination that produces the closest possible delay.
PIC16 classic mid-range devices normally execute one instruction cycle every 4 oscillator periods. The generated routine assumes the same instruction timing used by your example.