linux内核研究笔记2(关于asm.s中call函数的说明)

asm.s程序第39行中(以下片段第21行处),有个call函数调用代码,如下:

_divide_error:
	pushl $_do_divide_error
no_error_code:
	xchgl %eax,(%esp)
	pushl %ebx
	pushl %ecx
	pushl %edx
	pushl %edi
	pushl %esi
	pushl %ebp
	push %ds
	push %es
	push %fs
	pushl $0		# "error code"
	lea 44(%esp),%edx
	pushl %edx
	movl $0x10,%edx
	mov %dx,%ds
	mov %dx,%es
	mov %dx,%fs
	call *%eax
	addl $8,%esp
	pop %fs
	pop %es
	pop %ds
	popl %ebp
	popl %esi
	popl %edi
	popl %edx
	popl %ecx
	popl %ebx
	popl %eax
	iret

对于这条函数调用指令,很奇怪为啥会有个'*'前缀。在GNU《using as-The GNU Assembler》文档8.10.6节中,找到一句话,如下:

这段话是说,绝对地址的call和jump操作,需要加上'*'前缀,如果没有'*'前缀,as始终选择PC相对寻址。也就是说,如果没有这个'*'前缀,最终调用地址会加上PC寄存器里面的值。这当然就不是我们想要的了。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值