getting segmentation fault in assembly

112 Views Asked by At

Program received signal SIGSEGV, Segmentation fault.

I am using this assembly program: and for some reason I'm getting a segmentation fault, is it related to the stack? What does this program even supposed to output? somebody told me to run it and see what it does, any ideas? I thought it would be problematic and made a post about it, but it wasn't a problem, I tried debugging it with GDB and that didn't really help. If you could tell me what it outputs it would probably even be better, that's what I'm really looking for

.code32
.intel_syntax noprefix

.global _start

_start:
      mov eax, 0x04
      push eax
      mov eax, 0x2d
      push eax
      call asm2

asm2:
    push ebp
    mov ebp, esp
    sub esp, 0x10
    mov eax, DWORD PTR [ebp + 0xc] --- seg fault here
    mov DWORD PTR [ebp-0x4], eax
    mov eax, DWORD PTR[ebp+0x8]
    mov DWORD PTR [ebp-0x8], eax
    jmp part_b

part_a:
     add DWORD PTR [ebp - 0x4], 0x1
     add DWORD PTR [ebp + 0x8], 0x64
part_b:
     cmp DWORD PTR [ebp+0x8], 0x1d89
     jle part_a
     mov eax, DWORD PTR [ebp-0x4]
     mov esp, ebp
     pop ebp
     ret
0

There are 0 best solutions below