File: asm_memcpy.asmu

package info (click to toggle)
dgen 1.23-7
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 2,168 kB
  • ctags: 3,086
  • sloc: ansic: 45,404; cpp: 4,405; sh: 1,960; makefile: 116
file content (35 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
bits 32
section .text
;extern "C" int asm_memcpy
;  (unsigned char *dest, unsigned char *src, int len);

global _asm_memcpy

times ($$-$) & 3 db 0

_asm_memcpy:

pushad			; save registers
mov edi,[esp+36]	; get 1st argument
mov esi,[esp+40]	; ...2nd
mov eax,[esp+44]	; ...3rd

mov edx, eax
shr eax, 2		; figure out how many 4 byte chunks we have
and edx, 3		; also figure out slack
test eax, eax		; Do we have any big chunks?
push edx
jz .slack		; If not, just do slack

mov ecx,eax

rep movsd		; move 4 byte chunks

.slack:
pop ecx
rep movsb		; move 1 byte slack

popad			; clean up
ret

; --------------------------------------