diff options
Diffstat (limited to '')
| -rw-r--r-- | src/insertionSort.s (renamed from src/insertion_sort.s) | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/insertion_sort.s b/src/insertionSort.s index 3048a89..7badac0 100644 --- a/src/insertion_sort.s +++ b/src/insertionSort.s @@ -18,12 +18,12 @@ insertion_sort: cmp $1, %rsi # if n <= 1 jmp done - jle done + jle .insertion_sort_done # set up i movq $1, %r15 # i , start with 2nd element -loop: +.insertion_sort_loop: # load A[i] movq (%rdi,%r15,8), %r8 # pointer to key -> r8 movq (%r8,%rdx,8), %r9 # key -> r9 @@ -32,9 +32,9 @@ loop: movq %r15, %r14 # j -> r14 decq %r14 -inner_loop: +.insertion_sort_inner_loop: cmpq $0, %r14 # if j < 0 stop and insert the key - jl insert_key + jl .insertion_sort_insert_key # load A[j] movq (%rdi, %r14, 8), %r10 # pointer to key -> r10 @@ -43,25 +43,25 @@ inner_loop: # compare A[i] with A[j] cmpq %r11, %r9 - jge insert_key # if A[i] >= A[j] stop + jge .insertion_sort_insert_key # if A[i] >= A[j] stop # if A[i] < A[j] movq %r10, 8(%rdi, %r14, 8) # pointer to key of j -> A[j+1] decq %r14 # move to j - 1 - jmp inner_loop + jmp .insertion_sort_inner_loop -insert_key: +.insertion_sort_insert_key: movq %r8, 8(%rdi,%r14,8) # take the next number incq %r15 # i++ cmpq %rsi, %r15 # if i < n there are still numbers left to be sorted - jl loop - jmp done + jl .insertion_sort_loop + jmp .insertion_sort_done -done: +.insertion_sort_done: movq %rdi, %rax # retrieve |