diff --git a/agb/src/agbabi/memcpy.s b/agb/src/agbabi/memcpy.s index 8f6b601..a812654 100644 --- a/agb/src/agbabi/memcpy.s +++ b/agb/src/agbabi/memcpy.s @@ -29,11 +29,11 @@ __aeabi_memcpy: bmi .Lcopy1 bcs .Lcopy2 - // If the number of bytes to copy is less than 4, we should just copy one byte at a time - cmp r2, #4 - bmi .Lcopy1 - .Lcopy4: + // Handle <= 2 byte copies byte-by-byte + cmp r2, #2 + ble .Lcopy1 + // Copy half and byte head rsb r3, r0, #4 movs r3, r3, lsl #31 diff --git a/agb/src/agbabi/memset.s b/agb/src/agbabi/memset.s index b1a934c..87ba689 100644 --- a/agb/src/agbabi/memset.s +++ b/agb/src/agbabi/memset.s @@ -34,6 +34,17 @@ __aeabi_memset: // Fallthrough .LskipShifts: + // Handle <= 2 byte set byte-by-byte + cmp r1, #2 + bgt .LskipShortHead + movs r1, r1, lsl #31 + // Set byte and half + strmib r2, [r0], #1 + strcsb r2, [r0], #1 + strcsb r2, [r0] + bx lr + +.LskipShortHead: // JoaoBapt carry & sign bit test rsb r3, r0, #4 movs r3, r3, lsl #31