I'm a student and completely new to assembly programming, especially to GAS. I have a .asm program that uses selection sort to (obviously) sort an array of 10 integers and we were tasked to convert the code to GAS. I'm stuck at getting the input for the array. Here's a snippet of what I did:
section .bss
arr resb 10
section .text
global _start:
_start:
push arr
call getInput
...
getInput:
mov esi, 0
mov ebp, [esp+4] ; line number 59
...
The problem is, I have trouble finding out how to convert the code in line number 59. Here's what I did (loosely based on the tutorials I found):
.data
arr: .space 10
.text
.globl _start
_start:
push arr
call getInput
...
getInput:
movl $0, %esi
movl 4(%esp,1), %ebp
I tried running it and it produced a segmentation fault. What am I doing wrong? Am I pushing the address of the arr correctly? Is 4(%esp,1) equal to [esp+4]? Thank you in advance!