summaryrefslogtreecommitdiffstats
path: root/newlib/libc/machine/arm
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-11-30 09:31:38 +0000
committerCorinna Vinschen <corinna@vinschen.de>2012-11-30 09:31:38 +0000
commitb8637f43b08b1407cde47fc0477a1100b617f71f (patch)
tree357fd0f56dcc9e9b6bb050ef7240642d1d587d7e /newlib/libc/machine/arm
parentd551cb9226153a6855bde55aa8f0a7b0b8e688ab (diff)
downloadcygnal-b8637f43b08b1407cde47fc0477a1100b617f71f.tar.gz
cygnal-b8637f43b08b1407cde47fc0477a1100b617f71f.tar.bz2
cygnal-b8637f43b08b1407cde47fc0477a1100b617f71f.zip
* libc/machine/arm/strcmp.S (compute_return_value): Fix return value.
* testsuite/newlib.string/strcmp-1.c (main): Add new test cases.
Diffstat (limited to 'newlib/libc/machine/arm')
-rw-r--r--newlib/libc/machine/arm/strcmp.S12
1 files changed, 11 insertions, 1 deletions
diff --git a/newlib/libc/machine/arm/strcmp.S b/newlib/libc/machine/arm/strcmp.S
index 6298bc98d..0a4057e3b 100644
--- a/newlib/libc/machine/arm/strcmp.S
+++ b/newlib/libc/machine/arm/strcmp.S
@@ -396,7 +396,17 @@ do_return:
lsr r2, r2, r0
compute_return_value:
- subs r0, r1, r2
+ movs r0, #1
+ cmp r1, r2
+ /* The return value is computed as follows.
+ If r1>r2 then (C==1 and Z==0) and LS doesn't hold and r0 is #1 at return.
+ If r1<r2 then (C==0 and Z==0) and we execute SBC with carry_in=0,
+ which means r0:=r0-r0-1 and r0 is #-1 at return.
+ If r1=r2 then (C==1 and Z==1) and we execute SBC with carry_in=1,
+ which means r0:=r0-r0 and r0 is #0 at return.
+ (C==0 and Z==1) cannot happen because the carry bit is "not borrow". */
+ it ls
+ sbcls r0, r0, r0
bx lr