asm - 《Linux C一站式编程》:不加 int $0x80 导致段错误
大家讲道理
大家讲道理 2017-04-17 13:12:35
0
1
484

在 《Linux C一站式编程》中有这样一个问题:

.section .data

 .section .text
 .globl _start
_start:
 movl $1, %eax  # this is the linux kernel command
        # number (system call) for exiting
        # a program

 movl $4, %ebx  # this is the status number we will
        # return to the operating system.
        # Change this around and it will
        # return different things to
        # echo $?

 int $0x80  # this wakes up the kernel to run
        # the exit command

在上面的汇编代码中,如果将 int $0x80 这一句去掉,也能够编译链接成功,但是却会导致一个段错误,请问这是为什么?

谢谢大家了~

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回覆(1)
Ty80

這是一個中斷,作業系統(這個 int 80 是在 Linux 下)定死的,現推薦用 SYSENTER. 那麼一個呼叫最後沒有 SYSENTER 或者 SYSEXIT,當然會報錯啦。

它的作用去 Google 把,我就不當搬運工啦,畢竟很長時間沒有接觸了。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!