OSDN Git Service

Update Copyright years for files modified in 2008 and/or 2009.
[pf3gnuchains/gcc-fork.git] / gcc / config / picochip / libgccExtras / divmodsi4.asm
1 // picoChip ASM file
2 //
3 //   Support for 32-bit signed division/modulus.
4 //
5 //   Copyright (C) 2003, 2004, 2005, 2008  Free Software Foundation, Inc.
6 //   Contributed by picoChip Designs Ltd.
7 //   Maintained by Daniel Towner (daniel.towner@picochip.com)
8 //
9 //   This file is free software; you can redistribute it and/or modify it
10 //   under the terms of the GNU General Public License as published by the
11 //   Free Software Foundation; either version 2, or (at your option) any
12 //   later version.
13 //
14 //   In addition to the permissions in the GNU General Public License, the
15 //   Free Software Foundation gives you unlimited permission to link the
16 //   compiled version of this file into combinations with other programs,
17 //   and to distribute those combinations without any restriction coming
18 //   from the use of this file.  (The General Public License restrictions
19 //   do apply in other respects; for example, they cover modification of
20 //   the file, and distribution when not linked into a combine
21 //   executable.)
22 //
23 //   This file is distributed in the hope that it will be useful, but
24 //   WITHOUT ANY WARRANTY; without even the implied warranty of
25 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26 //   General Public License for more details.
27 //
28 //   You should have received a copy of the GNU General Public License
29 //   along with this program; see the file COPYING.  If not, write to
30 //   the Free Software Foundation, 51 Franklin Street, Fifth Floor,
31 //   Boston, MA 02110-1301, USA.
32
33 //      
34 .section .text
35
36 .align 8
37 .global __divmodsi4
38 __divmodsi4:
39 _picoMark_FUNCTION_BEGIN=
40 // picoChip Function Prologue : &__divmodsi4 = 8 bytes
41
42         // Note: optimising for size is preferred over optimising for speed.
43
44         // Note: the frame is setup throughout the following instructions,
45         // and is complete at the point the udivmodsi4 function is called.      
46
47         // Note that R9 is encoded with a pattern which indicates
48         // whether the remainder and quotient should be negated on
49         // completion. The MSB is set to the sign of the dividend
50         // (i.e., the sign of the remainder), while the LSB encodes
51         // the XOR of the two input's signs (i.e., the sign of the
52         // quotient.
53         
54         // If dividend is negative, invert the dividend and flag.
55         ASR.0 r1,15,r4
56         BEQ dividendNotNegative
57 =->     STL R[9:8],(FP)-2
58
59         // Dividend is negative - negate dividend.
60         SUB.0 0,R0,R0
61         SUBB.0 0,R1,R1
62
63 dividendNotNegative:
64                         
65         // If divisor is negative, invert the divisor.
66         AND.0 [lsr r3,15],1,r5
67         SUB.0 R3,0, r15
68         BGE divisorNotNegative
69 =->     XOR.0 r4,r5,r9
70
71         // Divisor is negative - negate divisor.
72         SUB.0 0,R2,R2
73         SUBB.0 0,R3,R3
74
75 divisorNotNegative:
76         
77         STL R[13:12],(FP)-1 \ JL (&__udivmodsi4)
78 =->     SUB.0 FP,8,FP  // udivmodsi expects the frame to be valid still.
79         
80         // The LSB of R9 indicates whether the quotient should be negated.
81         AND.0 r9,1,r15
82         BEQ skipQuotientNegation
83 =->     LDL (FP)1,R[13:12]      // Convenient point to restore link/fp
84         
85         SUB.0 0,R4,R4
86         SUBB.0 0,R5,R5  
87
88 skipQuotientNegation:           
89
90         // The MSB of R9 indicates whether the remainder should be negated.
91         ASR.0 R9,15,r15
92         BEQ epilogue
93
94         SUB.0 0,R6,R6
95         SUBB.0 0,R7,R7
96
97 epilogue:       
98
99         JR (R12)
100 =->     LDL (FP)-2,R[9:8]
101
102 _picoMark_FUNCTION_END=
103 // picoChip Function Epilogue : __divmodsi4
104
105 //============================================================================
106 // All DWARF information between this marker, and the END OF DWARF
107 // marker should be included in the source file. Search for
108 // FUNCTION_STACK_SIZE_GOES_HERE and FUNCTION NAME GOES HERE, and
109 // provide the relevent information. Add markers called
110 // _picoMark_FUNCTION_BEGIN and _picoMark_FUNCTION_END around the
111 // function in question.
112 //============================================================================
113
114 //============================================================================
115 // Frame information. 
116 //============================================================================
117
118 .section .debug_frame
119 _picoMark_DebugFrame=
120
121 // Common CIE header.
122 .unalignedInitLong _picoMark_CieEnd-_picoMark_CieBegin
123 _picoMark_CieBegin=
124 .unalignedInitLong 0xffffffff
125 .initByte 0x1   // CIE Version
126 .ascii 16#0#    // CIE Augmentation
127 .uleb128 0x1    // CIE Code Alignment Factor
128 .sleb128 2      // CIE Data Alignment Factor
129 .initByte 0xc   // CIE RA Column
130 .initByte 0xc   // DW_CFA_def_cfa
131 .uleb128 0xd
132 .uleb128 0x0
133 .align 2
134 _picoMark_CieEnd=
135
136 // FDE 
137 _picoMark_LSFDE0I900821033007563=
138 .unalignedInitLong _picoMark_FdeEnd-_picoMark_FdeBegin
139 _picoMark_FdeBegin=
140 .unalignedInitLong _picoMark_DebugFrame // FDE CIE offset
141 .unalignedInitWord _picoMark_FUNCTION_BEGIN     // FDE initial location
142 .unalignedInitWord _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
143 .initByte 0xe   // DW_CFA_def_cfa_offset
144 .uleb128 0x8    // <-- FUNCTION_STACK_SIZE_GOES_HERE
145 .initByte 0x4   // DW_CFA_advance_loc4
146 .unalignedInitLong _picoMark_FUNCTION_END-_picoMark_FUNCTION_BEGIN
147 .initByte 0xe   // DW_CFA_def_cfa_offset
148 .uleb128 0x0
149 .align 2
150 _picoMark_FdeEnd=
151
152 //============================================================================
153 // Abbrevation information.
154 //============================================================================
155
156 .section .debug_abbrev
157 _picoMark_ABBREVIATIONS=
158
159 .section .debug_abbrev
160         .uleb128 0x1    // (abbrev code)
161         .uleb128 0x11   // (TAG: DW_TAG_compile_unit)
162         .initByte 0x1   // DW_children_yes
163         .uleb128 0x10   // (DW_AT_stmt_list)
164         .uleb128 0x6    // (DW_FORM_data4)
165         .uleb128 0x12   // (DW_AT_high_pc)
166         .uleb128 0x1    // (DW_FORM_addr)
167         .uleb128 0x11   // (DW_AT_low_pc)
168         .uleb128 0x1    // (DW_FORM_addr)
169         .uleb128 0x25   // (DW_AT_producer)
170         .uleb128 0x8    // (DW_FORM_string)
171         .uleb128 0x13   // (DW_AT_language)
172         .uleb128 0x5    // (DW_FORM_data2)
173         .uleb128 0x3    // (DW_AT_name)
174         .uleb128 0x8    // (DW_FORM_string)
175 .initByte 0x0
176 .initByte 0x0
177
178         .uleb128 0x2    ;# (abbrev code)
179         .uleb128 0x2e   ;# (TAG: DW_TAG_subprogram)
180 .initByte 0x0   ;# DW_children_no
181         .uleb128 0x3    ;# (DW_AT_name)
182         .uleb128 0x8    ;# (DW_FORM_string)
183         .uleb128 0x11   ;# (DW_AT_low_pc)
184         .uleb128 0x1    ;# (DW_FORM_addr)
185         .uleb128 0x12   ;# (DW_AT_high_pc)
186         .uleb128 0x1    ;# (DW_FORM_addr)
187 .initByte 0x0
188 .initByte 0x0
189
190 .initByte 0x0
191
192 //============================================================================
193 // Line information. DwarfLib requires this to be present, but it can
194 // be empty.
195 //============================================================================
196
197 .section .debug_line
198 _picoMark_LINES=
199
200 //============================================================================
201 // Debug Information
202 //============================================================================
203 .section .debug_info
204
205 //Fixed header.
206 .unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
207 _picoMark_DEBUG_INFO_BEGIN=
208 .unalignedInitWord 0x2
209 .unalignedInitLong _picoMark_ABBREVIATIONS
210 .initByte 0x2
211
212 // Compile unit information.
213 .uleb128 0x1    // (DIE 0xb) DW_TAG_compile_unit)
214 .unalignedInitLong _picoMark_LINES
215 .unalignedInitWord _picoMark_FUNCTION_END
216 .unalignedInitWord _picoMark_FUNCTION_BEGIN
217 // Producer is `picoChip'
218 .ascii 16#70# 16#69# 16#63# 16#6f# 16#43# 16#68# 16#69# 16#70# 16#00#
219 .unalignedInitWord 0xcafe // ASM language
220 .ascii 16#0# // Name. DwarfLib expects this to be present.
221
222 .uleb128 0x2    ;# (DIE DW_TAG_subprogram)
223
224 // FUNCTION NAME GOES HERE. Use `echo name | od -t x1' to get the hex. Each hex
225 // digit is specified using the format 16#XX#
226 .ascii 16#5f# 16#64# 16#69# 16#76# 16#6d# 16#6f# 16#64# 16#73# 16#69# 16#34# 16#0# // Function name `_divmodsi4'
227 .unalignedInitWord _picoMark_FUNCTION_BEGIN     // DW_AT_low_pc
228 .unalignedInitWord _picoMark_FUNCTION_END       // DW_AT_high_pc
229
230 .initByte 0x0   // end of compile unit children.
231
232 _picoMark_DEBUG_INFO_END=
233
234 //============================================================================
235 // END OF DWARF
236 //============================================================================
237
238 .section .endFile
239 // End of picoChip ASM file