;contact ;nsfcwt round 4 ;redcode-94 ;name bubble gum ;author M R Bremer ;strategy pray for ordered data. ;strategy hopefully small, hopefully not TOO slow. ;strategy my quicksort-->bubble speedup is in the shop. ;strategy please, please, please, please don't break my sorter org start PTRSAVE EQU -1 ENDER EQU -2 ADDER EQU -3 STORAGE EQU -4 ptr dat 4001-1, 4002-1 start jmz.b stock, ptr+4000 ;stock is ascending order modify mov.x ptr, ptr ;change to descending order stock seq.i >count, ENDER+ptr ;parse: how many elements to sort djn.f -1, ADDER+ptr sub.f ADDER+ptr, ptr ;points ptr to (quasi)bottom of list mov ptr, PTRSAVE+ptr mul.a #-1, ADDER+ptr add.ab ADDER+ptr, j3 add.ab ADDER+ptr, j2 pass add.ab ADDER+ptr, j sortb slt.b {ptr, flag ;there were switches this pass erase sne.i @sortb, ENDER+ptr jmp j2 sne.ab #3990, pass ;don't kill flag jmp dec sne.i @pass, @sortb mov.i ENDER+ptr, @pass ;wipe the double out! dec nop pass nop }pass j3 djn.b degap, #0 mov.i ENDER+ptr, >pass ;mark the end