Skip to content

Instantly share code, notes, and snippets.

@MacoChave
Last active November 5, 2020 02:05
Show Gist options
  • Save MacoChave/086c280fee8b3b30faec614a7eb1a25f to your computer and use it in GitHub Desktop.
Save MacoChave/086c280fee8b3b30faec614a7eb1a25f to your computer and use it in GitHub Desktop.
Sorting asm
bubbleSort PROC
xor bx, bx
xor cx, cx
mov cl, countStats
dec cx
iloop_quickSort:
push cx
push bx
xor ax, ax
mov al, countStats
sub ax, bx
mov cx, ax
dec cx
lea si, listTemp
jloop_quickSort:
cmp sortDirection, 1
jne desc_quickSort
; asc_quickSort:
mov ax, [si]
cmp ax, [si + 1]
jbe continue_quickSort
jmp xchg_quickSort
desc_quickSort:
mov ax, [si]
cmp ax, [si + 1]
jae continue_quickSort
xchg_quickSort:
xchg ax, [si + 1]
mov [si], ax
continue_quickSort:
add si, 2
LOOP jloop_quickSort
pop bx
pop cx
inc ax
LOOP iloop_quickSort
pause
jmp showMenu
ENDP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment