]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | ; Copyright (C) 2011-2022 Free Software Foundation, Inc. |
85b8555e DD |
2 | ; Contributed by Red Hat. |
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 | ||
5c0029de | 23 | #include "vregs.h" |
85b8555e | 24 | |
8410904a | 25 | START_FUNC ___lshrsi3 |
85b8555e DD |
26 | ;; input: |
27 | ;; | |
28 | ;; [zero] | |
29 | ;; [count] <= $sp+8 | |
30 | ;; [in MSB] | |
31 | ;; [in] | |
32 | ;; [in] | |
33 | ;; [in LSB] <- $sp+4 | |
34 | ||
35 | ;; output: | |
36 | ;; | |
37 | ;; [r8..r11] result | |
38 | ||
39 | ;; registers: | |
40 | ;; | |
41 | ;; AX - temp for shift/rotate | |
42 | ;; B - count | |
43 | ||
44 | mov a, [sp+8] ; A now contains the count | |
85b8555e DD |
45 | cmp a, #0x20 |
46 | bc $.Lcount_is_normal | |
47 | ||
48 | ;; count is out of bounds, just return zero. | |
49 | movw r8, #0 | |
50 | movw r10, #0 | |
51 | ret | |
52 | ||
53 | .Lcount_is_normal: | |
54 | cmp0 a | |
55 | bnz $.Lcount_is_nonzero | |
56 | ||
57 | ;; count is zero, just copy IN to OUT | |
58 | movw ax, [sp+4] | |
59 | movw r8, ax | |
60 | movw ax, [sp+6] | |
61 | movw r10, ax | |
62 | ret | |
63 | ||
64 | .Lcount_is_nonzero: | |
65 | mov b, a ; B now contains the count also | |
66 | bf a.4, $.Lcount_lt_16 | |
67 | ||
68 | ;; count >= 16, shift 16 at a time. | |
69 | movw r10, #0 | |
70 | movw ax, [sp+6] | |
71 | movw r8, ax | |
72 | mov a, b | |
73 | and a, #0x0f | |
74 | sknz | |
75 | ret | |
76 | ||
77 | mov b, a ; B now contains the remaining count | |
78 | inc b | |
79 | br $.Lloop_top | |
80 | ||
81 | .Lcount_lt_16: | |
82 | ;; count is nonzero. Do one | |
83 | movw ax, [sp+6] | |
84 | shrw ax,1 | |
85 | movw r10, ax | |
86 | mov a, [sp+5] | |
87 | rorc a,1 | |
88 | mov r9, a | |
89 | mov a, [sp+4] | |
90 | rorc a,1 | |
91 | mov r8, a | |
92 | ||
93 | ;; we did one shift above; do as many more as we need now. | |
94 | .Lloop_top: | |
95 | dec b | |
96 | sknz | |
97 | ret | |
98 | ||
99 | movw ax, r10 | |
100 | shrw ax,1 | |
101 | movw r10, ax | |
102 | mov a, r9 | |
103 | rorc a,1 | |
104 | mov r9, a | |
105 | mov a, r8 | |
106 | rorc a,1 | |
107 | mov r8, a | |
108 | ||
109 | br $.Lloop_top | |
110 | ||
8410904a | 111 | END_FUNC ___lshrsi3 |