I am trying to implement bubble sort in assembly. Here is my code. I keep getting segmentation fault. I have a function down below. I have been trying to figure this out but I couldn't find a compiler for x86 and I have been checking with my code to check what is wrong but to no avail.
here is my function code:
bubble:
    push ebp
    mov ebp, esp
    push ecx
    push edx
    push edi
    push esi
    push ebx
    push eax
    
   
    mov eax, 0
    mov ecx, [ebp+12] ; number of elements in the array
    mov edx, [ebp+8]; address of array
    mov edi, 0
    mov esi, 0
    dec ecx; n - 1
    mov esi, 1
    sortOuter:
        cmp esi, 0
        jg sort
        sort:
        mov esi, 0 ;count
        check:
        cmp edi, ecx ; i < n - 1
        jl sortInner
        sortInner:
            mov ebx, [edx+edi*4] ; mov array[i+1] to ebx
            cmp [edx], ebx   ; cmp array[i] to array[i+1]
            jle noswap
            swap:
                mov eax, ebx ; mov array[i+1] to eax
                mov ebx, [edx] ; mov array[i] to array[i+1]
                mov [edx], eax ; mov array[i+1] to array[i]
                
                inc esi ; count++
            noswap:
            inc edi ; i++
            jmp check
    
        
        jmp sortOuter
    done:
    call print_nl
    pop ebx
    pop esi
    pop edi
    pop edx
    pop ecx
    
    mov esp, ebp
    pop ebp
    ret
 
     
    