diff --git a/arch/AArch64.S b/arch/AArch64.S index a002b0d..c7d7f4f 100644 --- a/arch/AArch64.S +++ b/arch/AArch64.S @@ -149,6 +149,29 @@ cu_memzero: ret cu_memtest: + // x0 - src, x1 - size + mov x2, x1, lsr #3 + tst x2, x2 + beq .test1_ +.test8: + ldr x3, [x0], #8 + cmp x3, xzr + bne .testnot + subs x2, x2, #1 + bne .test8 +.test1_: + and x2, x1, #7 + beq .testok +.test1: + ldrb w3, [x0], #1 + cmp w3, wzr + bne .testnot + subs x2, x2, #1 + bne .test1 +.testok: + mov x0, xzr + ret +.testnot: ret cu_va_start: diff --git a/test.c b/test.c index 3f4aee3..02a81b2 100644 --- a/test.c +++ b/test.c @@ -163,6 +163,9 @@ int main() 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)); + char c0 = 0; + printf("cu_memset\tc0\t%p\n", cu_memtest(&c0, 1)); + printf("[va_list]\n"); va_test(1337, 1, 2, 3, 4, 5);