blob: c461c495798a816197667acce1bcdb5b830672ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 bytes
# rdx = index of key to sort by
# rcx = address of sorting algorithm
# OUTPUTS : rax = address of sorted a
# CLOBBERS: none
# NOTES : Preserves all registers except eax
# --------------------------------------------
.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
|