*********************************************** * NSFCWT - Rules for round 4 * *********************************************** In round 4, you don't get to kill your opponent, you get to sort him :) This is a programming challenge, which involves writing a program (can't really call it a warrior) that sorts a block of instructions by A and B-field value; a special flag instruction tells your program whether to sort in ascending or descending order and whether to delete duplicate instructions or not. Any sorting algorithm (bubble-, insertion-, quick-sort, etc.) will do. Programs have to be correct (ie. sort 10 different data sets correctly) and are awarded points based on speed and size (faster and smaller is better). Input/Output Data starts at core location 4000. The first instruction is a flag instruction (see below) and *must not* be sorted. The actual data to be sorted is a block of consecutive instructions starting at 4001 and has a length of between 10 and 1000. The empty core instruction DAT.F \$0,\$0 is not part of the data set and can therefore be used to tell the extent of the data block. The sorted data block is written in place, starting at location 4001 without gaps. You can use any other place in core for temporary storage, etc., as long as the sorted data block ends with an empty core instruction. Flag instruction The instruction at location 4000 tells your program how to perform the sort. The B-field specifies the sort order, a "0" means increasing sort order (small values first); a non-zero value means decreasing sort order. A zero A-field means that duplicate instructions are not removed; a non-zero A-field means that instructions that are identical (opcode, modes and all) are removed during the sort, such that each instruction is unique. Sorting criteria Only A and B-field values are used for sorting. The B-field is sorted first; the A-field is only significant if several instructions with the same B-value exist. E.g. dat 0,2 is greater than dat 1,1. Termination Upon completion, your program has to commit suicide, i.e. execute a DAT instruction. Code/run time No restrictions on code length, instruction use or run time. Scoring Programs are given 10 data sets of varying length and "randomness"; only those that sort all 10 correctly are ranked based on 1) size, 2) weighed average run time. The overall rank is the mean of the size and time ranks. Examples Input 4000 dat 0,1 ;don't delete duplicates, order descending 4001 cmp 200,0 4002 slt #0,@0 4003 cmp 0,1 4004 slt #0,@0 4005 dat 0,0 ... Output 4000 dat 0,1 4001 cmp 0,1 4002 cmp 200,0 4003 slt #0,@0 4004 slt #0,@0 4005 dat 0,0 ... Input 4000 dat 1,0 ;delete duplicates, order ascending 4001 cmp 200,0 4002 slt #0,@0 4003 cmp 0,1 4004 slt #0,@0 4005 dat 0,0 ... Output 4000 dat 1,0 4001 slt #0,@0 4002 cmp 200,0 4003 cmp 0,1 4004 dat 0,0 ... Mail your sorters to Stefan.Strack@vanderbilt.edu by Friday, Nov. 3. Break a leg, (crash your hard-drive?) Nandor & Stefan