aboutsummaryrefslogtreecommitdiff
path: root/src/main.s
diff options
context:
space:
mode:
authorNavid Samanghoon <nsama24@student.sdu.dk>2025-10-21 13:34:36 +0200
committermithe24 <mithe24@student.sdu.dk>2025-10-29 13:49:57 +0100
commite0d2d485a3f344edf267df643c9b08b6fa77c899 (patch)
treed7b058467df400feba57bd5b9076343f473c721e /src/main.s
parenta09bb68366b6953920be493b10397fcba74cdf1d (diff)
downloadsorter-e0d2d485a3f344edf267df643c9b08b6fa77c899.tar.gz
sorter-e0d2d485a3f344edf267df643c9b08b6fa77c899.zip
update: Improved code readability and clarity by refining comments
Diffstat (limited to 'src/main.s')
-rw-r--r--src/main.s34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/main.s b/src/main.s
index 56b682c..c0d6e85 100644
--- a/src/main.s
+++ b/src/main.s
@@ -2,27 +2,29 @@
.globl _start
_start:
# Open file
- 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 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
# Convert to array
- movq %rax, %rdi # Select file descriptor
- call make_array_from_file # Convert file to array format
- movq %rdx, %r15 # Save length of array in r15
+ movq %rax, %rdi # Select file descriptor
+ call make_array_from_file # Convert file to array format
+ movq %rdx, %r15 # Save length of array in r15
- movq %rax, %rdi # Select address of array
- movq %r15, %rsi # Select length of array
- movq $1, %rdx # Sort by key 1
+ # Sort
+ movq %rax, %rdi # Select address of array
+ movq %r15, %rsi # Select length of array
+ movq $1, %rdx # Sort by key 1
call insertion_sort # Sort the array
# Print array
- movq %rax, %rdi # Select the pointer to the array
- movq %r15, %rsi # Select length of array
- call print_buffer # Print array
+ movq %rax, %rdi # Select the pointer to the array
+ movq %r15, %rsi # Select length of array
+ call print_buffer # Print array
- movq $60, %rax # Select exit syscall
- movq $0, %rdi # Exit code 0
+ # Exit
+ movq $60, %rax
+ movq $0, %rdi # Exit code 0
syscall