1;   Copyright (C) 2017-2020 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.
17;
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/>.
22
23
24#include "vregs.h"
25
26    .text
27
28START_FUNC ___umaxdi3
29
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
39
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    bh     $.L1
44    bnz    $.L2
45
46    movw   ax, [sp+16]
47    cmpw   ax, r12
48    bh     $.L1
49    bnz    $.L2
50
51    movw   ax, [sp+14]
52    cmpw   ax, r10
53    bh     $.L1
54    bnz    $.L2
55
56    movw   ax, [sp+12]
57    cmpw   ax, r8
58    bh     $.L1
59    ret
60
61.L1:
62    ; copy second argument/operand to the output registers
63    movw   ax, [sp+12]
64    movw   r8, ax
65    movw   ax, [sp+14]
66    movw   r10, ax
67    movw   ax, [sp+16]
68    movw   r12, ax
69    movw   ax, [sp+18]
70    movw   r14, ax
71.L2:
72    ret
73
74END_FUNC ___umaxdi3
75