diff --git a/bsrt.uc b/bsrt.uc index d142841..848cc59 100644 --- a/bsrt.uc +++ b/bsrt.uc @@ -1,40 +1,44 @@ #define LIST_START 0xE0 #define HASH_MASK 0b1111 +#define BUCKET_SIZE 13 +#define FIRST_BUCKET_ADDRESS 0x10 +#define LAST_BUCKET_ADDRESS 0xe0 // PM initial state -#data 0x00 0x70 -#data 0x01 0x7c -#data 0x02 0x88 -#data 0x03 0x94 -#data 0x04 0xa0 -#data 0x05 0xac -#data 0x06 0xb8 -#data 0x07 0xc4 +#data 0x00 0x78 +#data 0x01 0x85 +#data 0x02 0x92 +#data 0x03 0x9f +#data 0x04 0xac +#data 0x05 0xb9 +#data 0x06 0xc6 +#data 0x07 0xd3 #data 0x08 0x10 -#data 0x09 0x1c -#data 0x0a 0x28 -#data 0x0b 0x34 -#data 0x0c 0x40 -#data 0x0d 0x4c -#data 0x0e 0x58 -#data 0x0f 0x64 +#data 0x09 0x1d +#data 0x0a 0x2a +#data 0x0b 0x37 +#data 0x0c 0x44 +#data 0x0d 0x51 +#data 0x0e 0x5e +#data 0x0f 0x6b #data 0x10 0x10 -#data 0x1c 0x1c -#data 0x28 0x28 -#data 0x34 0x34 -#data 0x40 0x40 -#data 0x4c 0x4c -#data 0x58 0x58 -#data 0x64 0x64 -#data 0x70 0x70 -#data 0x7c 0x7c -#data 0x88 0x88 -#data 0x94 0x94 -#data 0xa0 0xa0 +#data 0x1d 0x1d +#data 0x2a 0x2a +#data 0x37 0x37 +#data 0x44 0x44 +#data 0x51 0x51 +#data 0x5e 0x5e +#data 0x6b 0x6b +#data 0x78 0x78 +#data 0x85 0x85 +#data 0x92 0x92 +#data 0x9f 0x9f #data 0xac 0xac -#data 0xb8 0xb8 -#data 0xc4 0xc4 +#data 0xb9 0xb9 +#data 0xc6 0xc6 +#data 0xd3 0xd3 + // TODO: Include register initial-state compiler directive (saves, like, 2 cycles max) // Set PC to LIST_START @@ -157,8 +161,6 @@ bra @DANK_SORT; incpc $BUCKET_SORT_END - - // PC is 0 here. Data is sorted smallest-to largest in memory: just spread out into buckets ;) // Perform final merge here @@ -172,7 +174,7 @@ mov ar pc // COPY NEGATIVE // Initialize GR as bucket pointer and IR as element pointer -const 0x10 +const FIRST_BUCKET_ADDRESS mov ar gr @@ -190,7 +192,6 @@ mov gr ar add 1 mov ar ir -// Copy 0x78 to initial list (0xE0) $COPY_BUCKET bls @NEXT_BUCKET @@ -206,10 +207,11 @@ mov hr pm; incpc; declc bra @COPY_BUCKET $NEXT_BUCKET + mov gr ar -add 0x0C +add BUCKET_SIZE mov ar gr -sub 0xD0 +sub LAST_BUCKET_ADDRESS bnz @LOOP