Posts: sorting
- TDD on the CPC: sorting pointers to strings
An insertion sort in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: the pointers move, the strings stay where they are, strcmp compares, stability shows at last, and the budget depends on n and on the prefixes.
- TDD on the CPC: strcmp, comparing two strings that end on bit 7
A string comparison in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: strings in the firmware format, an answer in the flags like CP, the bit 7 trap, then a budget for each path.
- TDD on the CPC: radix sort, two counting passes for 16-bit keys
Radix sort in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: a stable counting sort that moves the keys, two passes made into one routine by a byte swap, then its budget in NOPs.
- TDD on the CPC: counting sort, 256 counts and not one comparison
Counting sort in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: a table of 256 counts, a scan that started in the wrong place, a table left clean, then the four sorts head to head.
- TDD on the CPC: bubble sort, the flag or Knuth's bound
Bubble sort in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: a budget test decides between the classic flag and Knuth's bound, then a match of the three sorts.
- TDD on the CPC: insertion sort, four versions to the NOP
Insertion sort in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: four ways to shift the bytes, measured to the NOP, then a match against selection sort.
- TDD on the CPC: selection sort, and what it costs
Sorting an array in Z80 on the Amstrad CPC, one test at a time, with z80-tdd: from O(n²) complexity to an exact formula in NOPs.