flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DimonSoft 12 Apr 2020, 13:07
Choose sorting algorithm you like most and instead of directly comparing the values compare the same values but bitwise-anded with appropriate mask.
|
|||
![]() |
|
Tomasz Grysztar 12 Apr 2020, 13:09
I would myself use a bitwise algorithm, where you first arrange the list so that items having the topmost bit 0 are before the items having the highest bit 1, and then for each of these two sub-lists you repeat the process, but looking at the bit below, and so on.To arrange the list this way, you can scan from the beginning of the list until you reach an element with the highest bit set, and from the top of the list until you reach an element with highest bit zeroed, and if the former is before the latter in the list, you swap them and continue scanning.
In your case you'd be looking at the highest bit of the green channel, and continue (perhaps recursively) to cover all 8 bits. So at first you'd be testing bit 800000h, during the next step you would be testing 400000h, and so on, ending on the 010000h bit. For assembly programming I have always been finding this algorithm very natural and easy, in fact in my early days of programming I had been using it without even realizing that it is simply a special case of Radix sort that one may learn during formal education. Note, however, that this algorithm is not stable, so if you also need stability, you might need to consider another one. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.