NASM 编程 - `int0x80` 与 `int 0x80`
我有一个简单的 NASM 程序,它只调用 sys_exit
:
segment .text
global _start
_start:
mov eax, 1 ; 1 is the system identifier for sys_exit
mov ebx, 0 ; exit code
int 0x80 ; interrupt to invoke the system call
当我第一次编写它时,我犯了一个错误,忘记了 int
和 0x80
之间的空格:
int0x80
...但是程序仍然编译没有问题!
[prompt]> nasm -f elf MyProgram.asm
[prompt]> ld -o MyProgram MyProgram.o
当我运行它时,它只是给了我一个分段错误!
[prompt]> ./MyProgram
Segmentation fault
那么这个程序(我编写的原始程序,缺少空格)是做什么的呢? int0x80
(没有空格)在 NASM 中意味着什么?
segment .text
global _start
_start:
mov eax, 1
mov ebx, 0
int0x80 ; no space...
I have a simple NASM program which only invokes sys_exit
:
segment .text
global _start
_start:
mov eax, 1 ; 1 is the system identifier for sys_exit
mov ebx, 0 ; exit code
int 0x80 ; interrupt to invoke the system call
When I first wrote it, I made a mistake and forgot the space between int
and 0x80
:
int0x80
... but the program still compiled without problem!
[prompt]> nasm -f elf MyProgram.asm
[prompt]> ld -o MyProgram MyProgram.o
It just gave me a segmentation error when I ran it!
[prompt]> ./MyProgram
Segmentation fault
So what does this program - the original one I wrote, with the missing space - do? What does int0x80
(with no space) mean in NASM?
segment .text
global _start
_start:
mov eax, 1
mov ebx, 0
int0x80 ; no space...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NASM 向我发出以下警告:
显然,拼写错误被视为标签,您可以像往常一样在程序中引用新的
int0x80
标签:NASM 支持不带冒号的标签,我经常将其用于数据声明:
NASM is giving me this warning:
Apparently the typo gets treated as a label and you can reference the new
int0x80
label in your program as usual:NASM supports labels without colon, I often use that for data declarations:
您需要在此行的末尾放置一个冒号:
You need to put a colon at the end of this line: