implement _cu_memcmp in ARMv7
This commit is contained in:
parent
3cca1f83ce
commit
13b40a44d3
2 changed files with 31 additions and 2 deletions
29
arch/ARMv7.S
29
arch/ARMv7.S
|
|
@ -77,6 +77,35 @@ _cu_memmove:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
_cu_memcmp:
|
_cu_memcmp:
|
||||||
|
push {r4, r5}
|
||||||
|
|
||||||
|
mov r3, r2, lsr #2
|
||||||
|
tst r3, r3
|
||||||
|
beq .cmp1_
|
||||||
|
.cmp4:
|
||||||
|
ldr r4, [r0], #4
|
||||||
|
ldr r5, [r1], #4
|
||||||
|
cmp r4, r5
|
||||||
|
bne .cmpnot
|
||||||
|
subs r3, r3, #1
|
||||||
|
bne .cmp4
|
||||||
|
.cmp1_:
|
||||||
|
ands r3, r2, #3
|
||||||
|
beq .cmpok
|
||||||
|
.cmp1:
|
||||||
|
ldrb r4, [r0], #1
|
||||||
|
ldrb r5, [r1], #1
|
||||||
|
cmp r4, r5
|
||||||
|
bne .cmpnot
|
||||||
|
subs r3, r3, #1
|
||||||
|
bne .cmp1
|
||||||
|
.cmpok:
|
||||||
|
eor r0, r0, r0
|
||||||
|
pop {r4, r5}
|
||||||
|
bx lr
|
||||||
|
.cmpnot:
|
||||||
|
mov r0, #1
|
||||||
|
pop {r4, r5}
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
_cu_memset:
|
_cu_memset:
|
||||||
|
|
|
||||||
4
test.c
4
test.c
|
|
@ -162,7 +162,7 @@ int main()
|
||||||
printf("%x\t%x\n", 0x12345678, cu_bswap32(0x12345678));
|
printf("%x\t%x\n", 0x12345678, cu_bswap32(0x12345678));
|
||||||
printf("%lx\t%lx\n", 0x12345678abcd8765, cu_bswap64(0x12345678abcd8765));
|
printf("%lx\t%lx\n", 0x12345678abcd8765, cu_bswap64(0x12345678abcd8765));
|
||||||
|
|
||||||
printf("[struct]\n");
|
/*printf("[struct]\n");
|
||||||
printf("value_offset\t%u\n", value_offset(CU_STRUCT(test_s), 4, &test));
|
printf("value_offset\t%u\n", value_offset(CU_STRUCT(test_s), 4, &test));
|
||||||
printf("value_size\t%u\n", value_size(CU_STRUCT(test_s), 4, &test));
|
printf("value_size\t%u\n", value_size(CU_STRUCT(test_s), 4, &test));
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
|
|
@ -172,7 +172,7 @@ int main()
|
||||||
struct_size(CU_STRUCT(test_s), &test));
|
struct_size(CU_STRUCT(test_s), &test));
|
||||||
printf("value_offset\t%u\n", value_offset(CU_STRUCT(test_s), 5, &test));
|
printf("value_offset\t%u\n", value_offset(CU_STRUCT(test_s), 5, &test));
|
||||||
printf("value_size\t%u\n", value_size(CU_STRUCT(test_s), 5, &test));
|
printf("value_size\t%u\n", value_size(CU_STRUCT(test_s), 5, &test));
|
||||||
|
*/
|
||||||
char c0 = 0;
|
char c0 = 0;
|
||||||
printf("cu_memset\tc0\t%p\n", cu_memtest(&c0, 1));
|
printf("cu_memset\tc0\t%p\n", cu_memtest(&c0, 1));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue