aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormithe24 <mithe24@student.sdu.dk>2025-10-30 10:28:24 +0100
committermithe24 <mithe24@student.sdu.dk>2025-10-30 10:28:27 +0100
commit597022b22e0e499a567d29c7248e90b7726e0770 (patch)
tree063c35ca2b99f553ecb0ef3cc7684b6eef719e9a /src
parentd99c832dac240735f5aa282469762bab04c6a45c (diff)
downloadsorter-597022b22e0e499a567d29c7248e90b7726e0770.tar.gz
sorter-597022b22e0e499a567d29c7248e90b7726e0770.zip
consistent names
Diffstat (limited to '')
-rw-r--r--src/arrayMaker.s (renamed from src/array_maker.s)0
-rw-r--r--src/insertionSort.s (renamed from src/insertion_sort.s)20
-rw-r--r--src/lib/strcmp.s4
-rw-r--r--src/main.s24
-rw-r--r--[-rwxr-xr-x]src/quickSort.s (renamed from src/quicksort.s)6
5 files changed, 27 insertions, 27 deletions
diff --git a/src/array_maker.s b/src/arrayMaker.s
index 94bd4ea..94bd4ea 100644
--- a/src/array_maker.s
+++ b/src/arrayMaker.s
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
diff --git a/src/lib/strcmp.s b/src/lib/strcmp.s
index d495a91..e8f4334 100644
--- a/src/lib/strcmp.s
+++ b/src/lib/strcmp.s
@@ -13,7 +13,7 @@
strcmp:
xorq %rax, %rax # i = 0
-loop:
+.strcmp_loop:
movb (%rdi, %rax, 1), %r8b
movb (%rsi, %rax, 1), %r9b
@@ -25,7 +25,7 @@ loop:
incq %rax
- jmp loop
+ jmp .strcmp_loop
.strcmp_fail:
xorq %rax, %rax
diff --git a/src/main.s b/src/main.s
index b628d29..036671e 100644
--- a/src/main.s
+++ b/src/main.s
@@ -10,18 +10,18 @@
_start:
cmpq $2, (%rsp) # Check if there are only two arguments
- jne algorithm_selected # If not, go to algorithm_selected
+ jne .algorithm_selected # If not, go to algorithm_selected
-default:
+.default:
movq 16(%rsp), %rdi # Select first argument as file name
movq $0, %rsi # Select read only
movq $0, %rdx # Unused mode for read only
movq $2, %rax # Select open syscall
syscall # Open file, file descriptor returned in rax
movq %rax, %r13 # Save file descriptor in r13
- jmp select_quicksort # Select quicksort
+ jmp .select_quicksort # Select quicksort
-algorithm_selected:
+.algorithm_selected:
movq 32(%rsp), %rdi # Select third argument as file name
movq $0, %rsi # Select read only
movq $0, %rdx # Unused mode for read only
@@ -34,29 +34,29 @@ algorithm_selected:
movq $isort, %rsi # Select "isort" to compare with
call strcmp # Compare
cmp $1, %rax # If the strings where equal
- je select_insertionsort # Select insertionsort
+ je .select_insertionsort # Select insertionsort
.check_quicksort:
movq 24(%rsp), %rdi # Select algorithm string
movq $qsort, %rsi # Select "qsort" to compare with
call strcmp # Compare
cmp $1, %rax # If the strings where equal
- je select_quicksort # Go to selection_done
+ je .select_quicksort # Go to selection_done
.else_invalid_algorithm:
movq $60, %rax # Select exit syscall
movq $1, %rdi # Exit code 1
syscall # Exit
-select_insertionsort:
+.select_insertionsort:
movq $insertion_sort, %r14 # Select insertion_sort in r14
- jmp the_rest
+ jmp .the_rest
-select_quicksort:
- movq $quicksort, %r14 # Select quicksort in r14
- jmp the_rest
+.select_quicksort:
+ movq $quick_sort, %r14 # Select quicksort in r14
+ jmp .the_rest
-the_rest:
+.the_rest:
# Convert to array
movq %r13, %rdi # Select file descriptor
call make_array_from_file # Convert file to array format
diff --git a/src/quicksort.s b/src/quickSort.s
index 54720bf..af38a65 100755..100644
--- a/src/quicksort.s
+++ b/src/quickSort.s
@@ -7,9 +7,9 @@
# OUTPUTS : rax = address for sorted A
# --------------------------------------------
.section .text
-.globl quicksort
-.type quicksort, @function
-quicksort:
+.globl quick_sort
+.type quick_sort, @function
+quick_sort:
leaq -1(%rsi), %rcx
xorq %rsi, %rsi
call _quicksort