CWG 616, 1213 - value category of subobject references.
[official-gcc.git] / libgcc / config / rl78 / smaxdi3.S
blobfe52e21ad5af8e97b1e989eeed8b97a7177a7018
1 ;   Copyright (C) 2017 Free Software Foundation, Inc.
2 ;   Contributed by Sebastian Perta.
3
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
7 ; later version.
8
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.
13
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/>.
24 #include "vregs.h"
26     .text
28 START_FUNC ___smaxdi3
30     ; copy first argument/operand to the output registers
31     movw   ax, [sp+4]
32     movw   r8, ax
33     movw   ax, [sp+6]
34     movw   r10, ax
35     movw   ax, [sp+8]
36     movw   r12, ax
37     movw   ax, [sp+10]
38     movw   r14, ax
40     ; use 16-bit compares from the most significant words downto the least significant ones
41     movw   ax, [sp+18]
42     cmpw   ax, r14
43     xor1   CY, a.7   ; first compare accounts for the
44     xor1   CY, r15.7 ; sign bits of the two operands
45     bh     $.L1
46     bnz    $.L2
48     movw   ax, [sp+16]
49     cmpw   ax, r12
50     bh     $.L1
51     bnz    $.L2
53     movw   ax, [sp+14]
54     cmpw   ax, r10
55     bh     $.L1
56     bnz    $.L2
58     movw   ax, [sp+12]
59     cmpw   ax, r8
60     bh     $.L1
61     ret
63 .L1:
64     ; copy second argument/operand to the output registers
65     movw   ax, [sp+12]
66     movw   r8, ax
67     movw   ax, [sp+14]
68     movw   r10, ax
69     movw   ax, [sp+16]
70     movw   r12, ax
71     movw   ax, [sp+18]
72     movw   r14, ax
73 .L2:
74     ret
76 END_FUNC ___smaxdi3