Created
July 11, 2019 03:19
-
-
Save aldoea/9faed2dcebf0bad8bc9ec3c78bf4e0cb to your computer and use it in GitHub Desktop.
Bubble sort macro assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MPRINTARR MACRO | |
mov ecx, lengthArr | |
mov esi, OFFSET milista | |
PRINTLOOP: | |
mov eax, [esi] | |
call WriteDec | |
mWrite " " | |
add esi,4 | |
LOOP PRINTLOOP | |
Call Crlf | |
ENDM | |
Mburbuja MACRO | |
.data | |
milista DWORD 100, 10, 1, 20, 50 ,23, 62, 5, 2, 7, 11, 27, 66 | |
lengthArr DWORD ? | |
.code | |
mov lengthArr, LENGTHOF milista | |
mov ecx, lengthArr | |
dec ecx | |
.WHILE ecx > 0 | |
push ecx | |
mov esi, OFFSET milista | |
.WHILE ecx > 0 | |
mov eax, [esi] | |
mov ebx, [esi+4] | |
.IF ebx < eax | |
xchg eax,[esi+4] ; intercambia el par | |
xchg ebx,[esi] | |
mov [esi+4], ebx | |
mov [esi],eax | |
.ENDIF | |
add esi,4 | |
dec ecx | |
.ENDW | |
pop ecx | |
dec ecx | |
.ENDW | |
MPRINTARR | |
WAITUSER | |
ENDM | |
WAITUSER MACRO | |
Call Waitmsg | |
ENDM | |
CLEAR MACRO | |
Call Clrscr | |
ENDM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment