; insertion sort - requires FIRST to point to top of the data to ; sort, and LENGTH to be the number of elements ; 2 elements sorted in min 5, max 6 cycles ; 3 elements sorted in min 14, max 19 cycles ; 4 elements sorted in min 23, max 35 cycles ; 5 elements sorted in min 32, max 54 cycles ; x elements sorted in min (9x-13), max ((3x^2+11x)/2-11) cycles org inner-1 temp equ (outer-1) z outer mov #2, y q mov #FIRST+LENGTH-p-2,p p mov.ba #FIRST+LENGTH-1,#FIRST+LENGTH-1 nop }z, {q mov {p, temp inner slt @p, temp jmp found mov >p, }p y djn inner, #1 found mov temp, *p x djn outer, #LENGTH-1 dat 0, 0 LENGTH EQU 10 FIRST a for LENGTH dat 100-a rof end