From e068a165e039742c1718ccf70020382896d2bf15 Mon Sep 17 00:00:00 2001 From: Andreas Kapp Lindquist Date: Mon, 29 Sep 2025 22:11:29 +0200 Subject: refactor(sorting.s): Renamed to sorter.s --- src/sorter.s | 39 +++++++++++++++++++++++++++++++++++++++ src/sorting.s | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 src/sorter.s delete mode 100644 src/sorting.s (limited to 'src') diff --git a/src/sorter.s b/src/sorter.s new file mode 100644 index 0000000..ba232fe --- /dev/null +++ b/src/sorter.s @@ -0,0 +1,39 @@ +# -------------------------------------------- +# FUNCTION: sorter +# PURPOSE : Sorts array A, with references to arrays A_i, based on the given +# key in A_i, address and size of A, and an address of a sorting algorithm to be +# used +# INPUTS : rdi = address for A +# rsi = length of A in 64 bit chunks +# rdx = index of key to sort by +# rcx = address of sorting algorithm +# OUTPUTS : rax = address for sorted A +# CLOBBERS: none +# NOTES : Preserves all registers +# -------------------------------------------- +.section .text +.globl sorter +.type sorter, @function +sorter: + # Save registers + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + + # rdi is the addres of a + # rsi is the length of a + # rdx is the index of the key + call *%rcx # Sort the array (* is indirect call) + + # Restore registers + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + + ret diff --git a/src/sorting.s b/src/sorting.s deleted file mode 100644 index 771b4c8..0000000 --- a/src/sorting.s +++ /dev/null @@ -1,39 +0,0 @@ -# -------------------------------------------- -# FUNCTION: sorter -# PURPOSE : Sorts array A, with references to arrays A_i, based on the given -# key in A_i, address and size of A, and an address of a sorting algorithm to be -# used -# INPUTS : rdi = address for A -# rsi = length of A in bytes -# rdx = index of key to sort by -# rcx = address of sorting algorithm -# OUTPUTS : rax = address for sorted A -# CLOBBERS: none -# NOTES : Preserves all registers -# -------------------------------------------- -.section .text -.globl sorter -.type sorter, @function -sorter: - # Save registers - push %rbx - push %rbp - push %r12 - push %r13 - push %r14 - push %r15 - - # rdi is the addres of a - # rsi is the length of a - # rdx is the index of the key - call rcx # Sort the array - - # Restore registers - pop %r15 - pop %r14 - pop %r13 - pop %r12 - pop %rbp - pop %rbx - - ret -- cgit v1.2.3-70-g09d2