GNU Assembler (Mac OS X 64-bit): Illegal instruction: 4 [duplicate]

北慕城南 提交于 2019-12-11 20:39:26

问题


I am new to GNU Assembler and I'm trying to execute this piece of code:

.globl _main
_main:
    movl $1, %eax
    movl $0, %ebx
    int $0x80

This programm should exit by the system call exit (1). Compiled it (no warnings):

gcc test.s

But running it gives me the error: Illegal instruction: 4

Thanks for help!


回答1:


If you're compiling a 64-bit executable, then you should write something like this:

movq $0x2000001, %rax
movq $0, %rdi
syscall

Source.



来源:https://stackoverflow.com/questions/11178313/gnu-assembler-mac-os-x-64-bit-illegal-instruction-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!