stage2_asm.s

来自「newos is new operation system」· S 代码 · 共 79 行

S
79
字号
/*** Copyright 2001-2004, Travis Geiselbrecht. All rights reserved.** Distributed under the terms of the NewOS License.*/#define FUNCTION(x) .global x; .type x,@function; x/* uint64 rdtsc() */FUNCTION(rdtsc):	rdtsc	retFUNCTION(execute_n_instructions):	movl	4(%esp), %ecx	shrl	$4, %ecx.again:	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	xorl	%eax, %eax	loop	.again	retFUNCTION(system_time):   	/* load 64-bit factor into %eax (low), %edx (high) */   	/* hand-assemble rdtsc -- read time stamp counter */	rdtsc		/* time in %edx,%eax */	pushl	%ebx	movl	cv_factor, %ebx	movl	%edx, %ecx	/* save high half */	mull	%ebx 		/* truncate %eax, but keep %edx */	movl	%ecx, %eax	movl	%edx, %ecx	/* save high half of low */	mull	%ebx			/*, %eax*/	/* now compute  [%edx, %eax] + [%ecx], propagating carry */	subl	%ebx, %ebx	/* need zero to propagate carry */	addl	%ecx, %eax	adc		%ebx, %edx	popl	%ebx	retFUNCTION(cpuid): 	pushl	%ebx 	pushl	%edi 	movl	12(%esp),%eax 	movl	16(%esp),%edi 	cpuid 	movl	%eax,0(%edi) 	movl	%ebx,4(%edi) 	movl	%ecx,8(%edi) 	movl	%edx,12(%edi) 	popl	%edi 	popl	%ebx 	retFUNCTION(get_eflags): 	pushfl 	popl	%eax 	retFUNCTION(set_eflags): 	pushl	4(%esp) 	popfl	ret

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?