/* @args: r1 => pointer to the string @returns: r0 => string length @clobbers: r2 */ bytelen: mov r0, #0 1: ldrb r2, [r1, r0] cmp r2, #0 bxle lr add r0, r0, #1 b 1b /* @args: r1 => pointer to first string r2 => pointer to second string @returns: r0 => 0 if equal, -1 if a < b, 1 if a > b @clobbers: r1, r2, r3 */ strcmp_ascii: @ comparison loop 1: ldrb r0, [r1], #1 ldrb r3, [r2], #1 cmp r0, r3 bne 2f cmp r0, #0 bne 1b @ strings are equal mov r0, #0 bx lr @ if we found a different byte then return the appropriate integer 2: sub r0, r0, r3 cmp r0, #0 movlt r0, #-1 movgt r0, #1 bx lr