aboutsummaryrefslogtreecommitdiff
path: root/src/file_parser.s
diff options
context:
space:
mode:
authormithe24 <mithe24@student.sdu.dk>2025-10-09 13:07:51 +0200
committermithe24 <mithe24@student.sdu.dk>2025-10-29 13:49:57 +0100
commit36ed8ce55da6467986547c8612598f08e21f3154 (patch)
tree24fc5c9d4addc19fc2cb7ff70080baf8d2b2857b /src/file_parser.s
parent5767efb2e83d3cf0f6543d8f9c2e3966d2ddb9f8 (diff)
downloadsorter-36ed8ce55da6467986547c8612598f08e21f3154.tar.gz
sorter-36ed8ce55da6467986547c8612598f08e21f3154.zip
**JANITOR** removed orphans
Diffstat (limited to 'src/file_parser.s')
-rw-r--r--src/file_parser.s60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/file_parser.s b/src/file_parser.s
deleted file mode 100644
index b63708f..0000000
--- a/src/file_parser.s
+++ /dev/null
@@ -1,60 +0,0 @@
-# --------------------------------------------
-# FUNCTION: parse_file
-# PURPOSE : Parses the file into the array format.
-# INPUTS : rdi = File descriptor
-# OUTPUTS : rax = address of array
-# rdx = length of array in 8 byte chunks
-# CLOBBERS: none
-# NOTES : Preserves all registers.
-# --------------------------------------------
-.section .text
-.globl parse_file
-.type parse_file, @function
-parse_file:
- # Save registers
- push %rbx
- push %rbp
- push %r12
- push %r13
- push %r14
- push %r15
-
- movq %rdi, %r15 # Save file descriptor in r15
- movq %r15, %rdi # Select file descriptor
- call getFileSize # Get the file size
- movq %rax, %r14 # Save file size in r14
-
- movq %r14, %rdi # Select file size
- call allocate # Allocate memory for file contents
- movq %rax, %r13 # Save file buffer in r13
-
- movq %r15, %rdi # Select the file discriptor
- movq %r13, %rsi # Select the buffer to store input
- movq %r14, %rdx # Size to read from file
- movq $0, %rax # Select read syscall
- syscall # Read from the file
-
- movq %r13, %rdi # Select buffer for file contents
- movq %r14, %rsi # Select file size
- call getLineCount # Count lines
- movq %rax, %r12 # Save line count in r12
-
- movq %r12, %rdi # Select number of coordinates
- call make_coordinate_buffer # Create buffer
- movq %rax, %r13 # Override file buffer with coordinate buffer
-
- movq %r13, %rdi # Select coordinate buffer
- movq %r12, %rsi # Select number of coordinates
- call build_pointer_buffer # Create final array of pointers
- movq %rax, %rax # Return pointer to array
- movq %r12, %rdx # Return Number of coordinates
-
- # Restore registers
- pop %r15
- pop %r14
- pop %r13
- pop %r12
- pop %rbp
- pop %rbx
-
- ret