[list -] %INCLUDE "Along32.inc" %INCLUDE "Macros_Along.inc" [list +] ;--------------------------------------------------------------------- extern FillArray ; HLL prototype: void FillArray(int *array, int n); ; Reads n signed 32-bit integers and stores them in array. ; Implements the following loop: ; for (i = 0; i < n; i++) ; { ; Read a signed 32-bit integer from standard input ; Assign the acquired integer to array[i] ; } ; Receives: ESI = starting offset of array ; ECX = # of elements in array ; Returns: nothing ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- extern BubbleSort ; HLL prototype: void BubbleSort(int *array, int n); ; Implements the following code: ; for (i = 0; i < n - 1; ++i) ; { ; for (j = 0; j < n - i - 1; ++j) ; { ; if (array[j] > array[j+1]) ; swap(array[j], array[j+1]) ; } ; DisplayArray(array, n) ; } ; Receives: ESI = starting offset of array ; ECX = # of elements in array ; Returns: nothing ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- extern DisplayArray ; HLL prototype: void DisplayArray(int *array, int n); ; Implements the following loop: ; for (i = 0; i < n; ++i) ; print array[i] ; The elements are displayed on a single line, with elements being ; separated by commas. ; Receives: ESI = starting offset of array ; ECX = # of elements in array ; Returns: nothing ;--------------------------------------------------------------------- SECTION .data array times 1024 dd 0 SECTION .bss n resd 1 SECTION .text global _start _start: call ReadDec ; read an unsigned integer mov [n],eax ; move the integer to n mov esi,array mov ecx,[n] call FillArray mov esi,array mov ecx,[n] call DisplayArray mov esi,array mov ecx,[n] call BubbleSort Exit {0}