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

📄 fillmemsse.asm

📁 Use Asm in Visual Basic With Class Vtables demotrate with ASM Copy Memory Function
💻 ASM
字号:

[bits 32]    
    push edi                    ;Preserve edi

    mov edi, [esp+12]           ;Copy dest pointer into destination index
    mov eax, [esp+16]           ;Byte count in eax
    mov edx, [esp+20]           ;Copy fill character

; fill all four bytes of ebx with the value by shifting and or-ing
    mov 	ecx, edx
    shl 	ecx, 8
    or 	edx, ecx
    mov     ecx, edx
    shl 	edx, 16
    or 	edx, ecx

; align the destination on an 16 byte boundary
    mov     ecx, edi
    and     ecx, 15
    sub     eax, ecx
    
    jecxz 	_aligned
_align:    
    mov 	BYTE [edi],	dl
    add 	edi, 1
    sub     ecx, 1
    jnz    _align
    
_aligned:
    mov     ecx, eax
    and     eax, 15
    shr     ecx, 4
    jz	_tail1

; fill all 16 bytes of xmm0 with the fill value by pushing ebx to the stack four times and 
; then moving from memory to to the SSE register... is there a better way?
    emms
    push    edx
    push    edx
    push    edx
    push    edx
    movdqa  xmm0, [esp]
    add     esp, 16
_loop_sse:
    movq	[edi], mm0
    add     edi, 16
    sub     ecx, 1
    jnz    _loop_sse
    emms
    
_tail1:
    mov     ecx, eax
    jecxz 	_end
_tail2:    
    mov 	BYTE [edi],	dl
    add 	edi, 1
    sub     ecx, 1
    jnz    _tail2

_end:
    pop     edi
    ret     16

⌨️ 快捷键说明

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