+ -
当前位置:首页 → 问答吧 → 请教几句汇编语言是什么意思

请教几句汇编语言是什么意思

时间:2010-08-13

来源:互联网

0. long __res;\
1. __asm__ volatile ("int $0x80" \
2.         : "=a" (__res) \
3.         : "0" (__NR_##name)); \

本人汇编学习的不深,求教上述汇编语言第二行与第三行是什么意思。谢谢

作者: nathan10   发布时间: 2010-08-13

int $0x80

产生0x80中断,这个中断是做什么用的,查一下。剩下的估计就容易明白了

作者: Godbach   发布时间: 2010-08-13

a Use the %eax, %ax, or %al registers.

= The operand can only be written to.

0 signals the compiler to use the same register with output

作者: liying_gg   发布时间: 2010-08-13

int80是陷入系统调用的软中段,但是你程序中没有设置寄存器,不知道陷入那个系统调用

作者: liying_gg   发布时间: 2010-08-13

回复 liying_gg

这里name的值是fork

作者: nathan10   发布时间: 2010-08-13

上面的代码就是头文件unistd.h中的一部分
#define __NR_fork        2
....
#define _syscall0(type,name) \
type name(void) \
{ \
long __res; \
__asm__ volatile ("int $0x80" \
        : "=a" (__res) \
        : "0" (__NR_##name)); \
if (__res >= 0) \
        return (type) __res; \
errno = -__res; \
return -1; \
}

而init文件中的main.c中调用语句是static inline _syscall0(int,fork)

作者: nathan10   发布时间: 2010-08-13

热门下载

更多