1 ; Copyright (C) 2011-2013 Free Software Foundation, Inc.
2 ; Contributed by Red Hat.
4 ; This file is free software; you can redistribute it and/or modify it
5 ; under the terms of the GNU General Public License as published by the
6 ; Free Software Foundation; either version 3, or (at your option) any
9 ; This file is distributed in the hope that it will be useful, but
10 ; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ; General Public License for more details.
14 ; Under Section 7 of GPL version 3, you are granted additional
15 ; permissions described in the GCC Runtime Library Exception, version
16 ; 3.1, as published by the Free Software Foundation.
18 ; You should have received a copy of the GNU General Public License and
19 ; a copy of the GCC Runtime Library Exception along with this program;
20 ; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
21 ; <http://www.gnu.org/licenses/>.
29 ;; int __cmpsi2 (signed long A, signed long B)
31 ;; Performs a signed comparison of A and B.
32 ;; If A is less than B it returns 0. If A is greater
33 ;; than B it returns 2. If they are equal it returns 1.
36 .type ___cmpsi2, @function
42 ;; Initialise default return value.
45 ;; Compare the high words.
51 br !!.Lconvert_to_signed
53 .Lcompare_bottom_words:
54 ;; The top words are equal - compare the bottom words.
55 ;; Note - code from __ucmpsi2 branches into here.
61 br !!.Lless_than_or_greater_than
62 ;; The words are equal - return 1.
63 ;; Note - we could branch to the return code at the end of the
64 ;; function but a branch instruction takes 4 bytes, and the
65 ;; return sequence itself is only 4 bytes long...
71 ;; The top words are different. Unfortunately the comparison
72 ;; is always unsigned, so to get a signed result we XOR the CY
73 ;; flag with the top bits of AX and DE.
79 .Lless_than_or_greater_than:
80 ;; We now have a signed less than/greater than result in CY.
81 ;; Return 0 for less than, 2 for greater than.
82 ;; Note - code from __ucmpsi2 branches into here.
87 ;; Get the result value, currently in BC, into r8
92 .size ___cmpsi2, . - ___cmpsi2
95 ;; int __ucmpsi2 (unsigned long A, unsigned long B)
97 ;; Performs an unsigned comparison of A and B.
98 ;; If A is less than B it returns 0. If A is greater
99 ;; than B it returns 2. If they are equal it returns 1.
102 .type ___ucmpsi2, @function
106 ;; Result put in R8..R9
108 ;; Initialise default return value.
111 ;; Compare the high words.
117 ;; Note: These branches go into the __cmpsi2 code!
118 br !!.Lless_than_or_greater_than
119 br !!.Lcompare_bottom_words
121 .size ___ucmpsi2, . - ___ucmpsi2