ashldi3.S revision 1.1 1 1.1 isaki /* $NetBSD: ashldi3.S,v 1.1 2020/08/16 06:43:43 isaki Exp $ */
2 1.1 isaki
3 1.1 isaki /*
4 1.1 isaki * Copyright (C) 2020 Tetsuya Isaki. All rights reserved.
5 1.1 isaki * Copyright (C) 2020 Y.Sugahara (moveccr). All rights reserved.
6 1.1 isaki *
7 1.1 isaki * Redistribution and use in source and binary forms, with or without
8 1.1 isaki * modification, are permitted provided that the following conditions
9 1.1 isaki * are met:
10 1.1 isaki * 1. Redistributions of source code must retain the above copyright
11 1.1 isaki * notice, this list of conditions and the following disclaimer.
12 1.1 isaki * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 isaki * notice, this list of conditions and the following disclaimer in the
14 1.1 isaki * documentation and/or other materials provided with the distribution.
15 1.1 isaki *
16 1.1 isaki * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 isaki * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 isaki * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 isaki * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 isaki * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 isaki * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 isaki * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 isaki * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 isaki * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 isaki * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 isaki * SUCH DAMAGE.
27 1.1 isaki */
28 1.1 isaki
29 1.1 isaki /*
30 1.1 isaki * Size optimized version for primary bootloader.
31 1.1 isaki */
32 1.1 isaki
33 1.1 isaki #include <machine/asm.h>
34 1.1 isaki
35 1.1 isaki ASENTRY_NOPROFILE(__ashldi3)
36 1.1 isaki moveml %sp@(4),%d0-%d1/%a0 | %d0:%d1 = quad value
37 1.1 isaki | %a0 = shift count
38 1.1 isaki jbra start
39 1.1 isaki loop:
40 1.1 isaki lsll #1,%d1 | X:%d1 =<< 1
41 1.1 isaki roxll #1,%d0 | %d0:X =<< 1
42 1.1 isaki start:
43 1.1 isaki subql #1,%a0 | sub %a0 doesn't affect ccr,
44 1.1 isaki tstl %a0 | but this extra TST op is
45 1.1 isaki | smaller than push/pop %d2.
46 1.1 isaki jpl loop
47 1.1 isaki rts
48 1.1 isaki
49 1.1 isaki
50 1.1 isaki #if defined(SELFTEST)
51 1.1 isaki #include "iocscall.h"
52 1.1 isaki .macro PRINT msg
53 1.1 isaki leal \msg,%a1
54 1.1 isaki IOCS(__B_PRINT)
55 1.1 isaki .endm
56 1.1 isaki
57 1.1 isaki .macro TEST name
58 1.1 isaki leal \name,%a2
59 1.1 isaki jbsr test
60 1.1 isaki .endm
61 1.1 isaki
62 1.1 isaki ASENTRY_NOPROFILE(selftest_ashldi3)
63 1.1 isaki moveml %d2-%d7/%a2-%a6,%sp@-
64 1.1 isaki PRINT %pc@(msg_testname)
65 1.1 isaki
66 1.1 isaki TEST test0
67 1.1 isaki TEST test1
68 1.1 isaki TEST test2
69 1.1 isaki TEST test63
70 1.1 isaki
71 1.1 isaki PRINT %pc@(msg_crlf)
72 1.1 isaki moveml %sp@+,%d2-%d7/%a2-%a6
73 1.1 isaki rts
74 1.1 isaki
75 1.1 isaki test:
76 1.1 isaki moveml %a2@+,%d0-%d2 | %d0:%d1 = value
77 1.1 isaki | %d2 = count
78 1.1 isaki moveml %d0-%d2,%sp@-
79 1.1 isaki jbsr __ashldi3
80 1.1 isaki leal %sp@(12),%sp
81 1.1 isaki
82 1.1 isaki cmpl %a2@+,%d0 | compare high word
83 1.1 isaki jne fail
84 1.1 isaki cmpl %a2@+,%d1 | compare low word
85 1.1 isaki jne fail
86 1.1 isaki PRINT %pc@(msg_ok)
87 1.1 isaki rts
88 1.1 isaki fail:
89 1.1 isaki PRINT %pc@(msg_fail)
90 1.1 isaki rts
91 1.1 isaki
92 1.1 isaki test0: | count = 0
93 1.1 isaki .long 0x11223344, 0x55667788
94 1.1 isaki .long 0
95 1.1 isaki .long 0x11223344, 0x55667788
96 1.1 isaki
97 1.1 isaki test1: | count = 1
98 1.1 isaki .long 0x11223344, 0x55667788
99 1.1 isaki .long 1
100 1.1 isaki .long 0x22446688, 0xaaccef10
101 1.1 isaki
102 1.1 isaki test2: | count = 2
103 1.1 isaki .long 0x11223344, 0x55667788
104 1.1 isaki .long 2
105 1.1 isaki .long 0x4488cd11, 0x5599de20
106 1.1 isaki
107 1.1 isaki test63: | count = 63
108 1.1 isaki .long 0x11223344, 0x55667789
109 1.1 isaki .long 63
110 1.1 isaki .long 0x80000000, 0x00000000
111 1.1 isaki
112 1.1 isaki msg_testname:
113 1.1 isaki .asciz "__ashldi3"
114 1.1 isaki msg_ok:
115 1.1 isaki .asciz " ok"
116 1.1 isaki msg_fail:
117 1.1 isaki .asciz " fail"
118 1.1 isaki msg_crlf:
119 1.1 isaki .asciz "\r\n"
120 1.1 isaki
121 1.1 isaki #endif
122