why is segmention fault while printing?

后端 未结 2 1681
星月不相逢
星月不相逢 2021-01-28 05:16

This is my x86 assembly code:

section .data 
  output db \'%d\',10,0
section .text 
  global main
  extern printf 
main :
  xor ecx,ecx
  xor eax,eax
  mov eax,1         


        
2条回答
  •  轮回少年
    2021-01-28 06:06

    print ends with a ret instruction, which implies that it is something that you should call. So jg print should be jng skip / call print / skip: (or just call print, because the > 0 check seems unnecessary).
    call places the return address on the stack, jg does not.

提交回复
热议问题