3 ms·
IDK anything about GBA dev. But on x86_64, memcpy is traditionally implemented by copying 64-bit data until len / 8 == 0, and then copying the remaining bytes[0
by roblabla 10y ago
IDK anything about GBA dev. But on x86_64, memcpy is traditionally implemented by copying 64-bit data until len / 8 == 0, and then copying the remaining bytes[0]. I suppose this is faster because accessing data with the proper cpu alignment is faster.
0: https://github.com/lattera/glibc/blob/master/string/memcpy.c#L39 https://github.com/lattera/glibc/blob/master/string/memcpy.c...
- juliangoldsmith 10y agoI'd imagine that the GBA's memcpy works in a similar way. In the tutorial, Kyle already aligns the array to 4 bytes, so using ints instead of chars really isn't doing much.
- pmalynin 10y agoI'd contend that the in this day and age the most space efficient and fast way to implement memcpy on x86_64 is to "rep movsb", which triggers internal memcpy on the CPU anyway as per Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1 Section 7.3.9.3
- monocasa 10y agoLast time I checked, the movs variants were microcoded slow path; you used SSE to get the fastest memcpy.
- bluedino 10y agoThat's the most straightforward and simple way, but it might not be the fastest due to the way caches work - look up the old Apple BlockMove() function for an example