1
Freebasic / Re: Simple example of using pointers to draw on the screen.
« on: March 01, 2007 »
Sorry for dragging this even farther off topic, but here's a relatively simple memory copy routine that's (possibly) faster than the CRT one (I can never resist the urge to write a bit of inline assembly
):
):Code: [Select]
sub fastmemcpy(byval dst as any ptr, byval src as any ptr, byval bytes as uinteger)
asm
mov ecx, [bytes]
mov esi, [src]
mov edx, ecx
shr ecx, 2 ' ecx = bytes / 4 = number of dwords to copy
and edx, 3 ' edx = 3, 2, 1, 0 bytes left over after dword copy
test ecx, ecx
mov edi, [dst]
jz bytecpy
rep movsd
bytecpy:
test edx, edx
jz endcpy
mov ecx, edx
rep movsb
endcpy:
end asm
end sub