How to call a function in Assembly At & t syntax

317 Views Asked by At

I know all the convention rule for caller and callee function as,I have gone through this link (http://flint.cs.yale.edu/cs421/papers/x86-asm/asm.html). But one thing i haven't got is how to call,till now i am using this code for the purpose.It may be wrong way as i am trying this for first time.

.data
arr : .quad 25,35,99,24,5,1,13,42,34


.text
.globl main
   .type main,@function
main:
call sort 
movq $60,%rax                     # syscall for exit
movq $0, %rbx                     
syscall                           # calling interrupt to exit



.globl sort 
.type sort,@function
  sort:
   movq $1,%rax
   ret

But when i am using gdb to debug sort is never called.Actually i have to perform selection sort in assembly i have already written a working program link (https://pastebin.com/P7qZAezd) but in this i have used labels not function. Also i haven't follow any convention of caller and callee in my function call as i was just testing.Can anyone show me a way how to do it.

0

There are 0 best solutions below