⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 memmove_asm.s

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 S
字号:
/* 
 * $Id: memmove_asm.s 21683 2006-04-21 15:15:18Z peterw $
 */

/*
 * void *memmove (void *to, const void *from, size_t count)
 */

.globl	_memmove

_memmove:
	push	%ebp
	mov	%esp,%ebp
	
	push	%esi
	push	%edi
	
	mov	8(%ebp),%edi
	mov	12(%ebp),%esi
	mov	16(%ebp),%ecx
	
	cmp	%esi,%edi
	jbe	.CopyUp
	mov	%ecx,%eax
	add	%esi,%eax
	cmp	%eax,%edi
	jb	.CopyDown
	
.CopyUp:	
	cld
	
	cmp	$16,%ecx
	jb	.L1
	mov	%ecx,%edx
	test	$3,%edi
	je	.L2
/*
 * Make the destination dword aligned
 */
        mov	%edi,%ecx
        and	$3,%ecx
        sub	$5,%ecx
        not	%ecx
        sub	%ecx,%edx
        rep	movsb
        mov	%edx,%ecx	
.L2:
	shr	$2,%ecx
	rep	movsl
	mov	%edx,%ecx
	and	$3,%ecx
.L1:	
	test	%ecx,%ecx
	je	.L3
	rep	movsb
.L3:
	mov	8(%ebp),%eax
	pop	%edi
	pop	%esi
	leave
	ret

.CopyDown:
        std
        
	add	%ecx,%edi
	add	%ecx,%esi
	
	cmp	$16,%ecx
	jb	.L4
        mov	%ecx,%edx
	test	$3,%edi
	je	.L5
	
/*
 * Make the destination dword aligned
 */
	mov	%edi,%ecx
	and	$3,%ecx
	sub	%ecx,%edx
	dec	%esi
	dec	%edi
	rep	movsb
	mov	%edx,%ecx
	
	sub	$3,%esi
	sub	$3,%edi
.L6:	
	shr	$2,%ecx
	rep	movsl
	mov	%edx,%ecx
	and	$3,%ecx
	je	.L7
	add	$3,%esi
	add	$3,%edi
.L8:	
	rep	movsb
.L7:
	cld
	mov	8(%ebp),%eax
	pop	%edi
	pop	%esi
	leave
	ret
.L5:
	sub	$4,%edi
	sub	$4,%esi
	jmp	.L6
		
.L4:
	test	%ecx,%ecx
	je	.L7	
	dec	%esi
	dec	%edi
	jmp	.L8

⌨️ 快捷键说明

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