aboutsummaryrefslogtreecommitdiff
path: root/src/insertionsort.s
diff options
context:
space:
mode:
authorAndreas Kapp Lindquist <alind24@student.sdu.dk>2025-09-30 09:06:49 +0200
committermithe24 <mithe24@student.sdu.dk>2025-10-29 13:49:57 +0100
commit4e8096421d9aa6fda1a8820aa3712a22bb5b8cc1 (patch)
treefeb2a7a65c22c8d839af934d07df0c98f25fe2d8 /src/insertionsort.s
parent245ab12e7e9cb8c333312e2f1f5588d6a903febf (diff)
downloadsorter-4e8096421d9aa6fda1a8820aa3712a22bb5b8cc1.tar.gz
sorter-4e8096421d9aa6fda1a8820aa3712a22bb5b8cc1.zip
fix(insertionsort.s): Address reference and jump to end_while
Diffstat (limited to '')
-rw-r--r--src/insertionsort.s10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/insertionsort.s b/src/insertionsort.s
index 66f0323..790f620 100644
--- a/src/insertionsort.s
+++ b/src/insertionsort.s
@@ -30,25 +30,25 @@ insertion_sort:
pop %rsi # Restore array size
movq (%rdi, %rsi, 8), %rbp # Save address at A[n] in rbp
- movq (%rbp, %rdx), %rbx # Save value of A[n] in rbx
+ movq (%rbp, %rdx, 8), %rbx # Save value of A[n] in rbx
movq %rsi, %r15 # Save copy of n in r15
subq $1, %r15 # Make r15 = n-1 = j
while:
cmp $0, %r15 # Compare j with 0
- jl end # Go to end if less than
+ jl end_while # Go to end if less than
movq (%rdi, %r15, 8), %rbp # Save address at A[j] to rbp
- movq (%rbp, %rdx), %r12 # Move value at A[j] into r12
+ movq (%rbp, %rdx, 8), %r12 # Move value at A[j] into r12
cmp %r12, %rbx # Compare A[j] with A[n]
- jge end # Go to end if greater than or equal
+ jge end_while # Go to end if greater than or equal
movq %r15, %r14 # Duplicate r15 into r14
addq $1, %r14 # And add 1: j+1
movq (%rdi, %r14, 8), %rbp # Save address of A[j+1] in rbp
- movq %r12, (%rbp, %rdx) # Move value at A[j] into value at A[j+1]
+ movq %r12, (%rbp, %rdx, 8) # Move value at A[j] into value at A[j+1]
subq $1, %r15 # j = j - 1