; my quick sort program!
;
; use SASM under linux.
%include "io.inc"
section .data
dat db 9,13,8,6,8,22,-11,1,-4,9,7,2,-7,-5,4,2;
datlen equ $-dat
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
;write your code here
xor eax, eax
mov eax, dat
mov ebx, dat+ datlen
dec ebx
call quicksort
mov eax, dat
mov ebx, datlen
loopshow:
mov cl,byte[eax]
PRINT_DEC 1, cl
PRINT_STRING ","
inc eax
dec ebx
cmp ebx,0
jz loopshowout
jmp loopshow
loopshowout:
ret
quicksort: ; split in half.. datarange:eax-ebx.
cmp eax, ebx-1
jge nothing
jmp startpos
nothing:
ret
startpos:
push ebx
push eax
;eax = i
;ebx = j
mov ecx, eax;
inc ecx;
loop:
mov dh, byte[eax]
mov dl, byte[ecx]
cmp d
SASM Quicksort / 汇编快速排序
最新推荐文章于 2024-08-26 10:49:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)