getprocessor.s

来自「Minix比较全的源码」· S 代码 · 共 57 行

S
57
字号
!	getprocessor() - determine processor type	Author: Kees J. Bot!								26 Jan 1994.sect .text; .sect .rom; .sect .data; .sect .bss.sect .text! int getprocessor(void);!	Return 386, 486, 586, ....define	_getprocessor_getprocessor:	push	ebp	mov	ebp, esp	and	esp, 0xFFFFFFFC	! Align stack to avoid AC fault	mov	ecx, 0x00040000	! Try to flip the AC bit introduced on the 486	call	flip	mov	eax, 386	! 386 if it didn't react to "flipping"	jz	gotprocessor	mov	ecx, 0x00200000	! Try to flip the ID bit introduced on the 586	call	flip	mov	eax, 486	! 486 if it didn't react	jz	gotprocessor	pushf	pusha			! Save the world	mov	eax, 1	.data1	0x0F, 0xA2	! CPUID instruction tells the processor type	andb	ah, 0x0F	! Extract the family (5, 6, ...)	movzxb	eax, ah	cmp	eax, 15		! 15: extended family	jne	direct	mov	eax, 6		! Make it 686direct:	imul	eax, 100	! 500, 600, ...	add	eax, 86		! 586, 686, ...	mov	7*4(esp), eax	! Pass eax through	popa	popfgotprocessor:	leave	retflip:	pushf			! Push eflags	pop	eax		! eax = eflags	mov	edx, eax	! Save original eflags	xor	eax, ecx	! Flip the bit to test	push	eax		! Push modified eflags value	popf			! Load modified eflags register	pushf	pop	eax		! Get it again	push	edx	popf			! Restore original eflags register	xor	eax, edx	! See if the bit changed	test	eax, ecx	ret

⌨️ 快捷键说明

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