March 2010
Beginner
760 pages
18h 51m
English
Almost every textbook on this planet gives an example of a sort when introducing arrays. Because you've probably seen how to do a sort in high-level languages already, it's probably instructive to take a quick look at a sort in HLA. The example code in this section will use a variant of the bubble sort, which is great for short lists of data and lists that are nearly sorted but horrible for just about everything else.[63]
const NumElements := 16; static DataToSort: uns32[ NumElements ] := [ 1, 2, 16, 14, 3, 9, 4, 10, 5, 7, 15, 12, 8, 6, 11, 13 ]; NoSwap: boolean; . . . // Bubble sort for the DataToSort array: repeat mov( true, NoSwap ); for( mov( 0, ebx ); ebx <= NumElements-2; inc( ebx )) do mov( DataToSort[ ebx*4], ...