3 // Support for 32-bit signed division/modulus.
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)
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
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
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.
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.
39 _picoMark_FUNCTION_BEGIN=
40 // picoChip Function Prologue : &__divmodsi4 = 8 bytes
42 // Note: optimising for size is preferred over optimising for speed.
44 // Note: the frame is setup throughout the following instructions,
45 // and is complete at the point the udivmodsi4 function is called.
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
54 // If dividend is negative, invert the dividend and flag.
56 BEQ dividendNotNegative
59 // Dividend is negative - negate dividend.
65 // If divisor is negative, invert the divisor.
66 AND.0 [lsr r3,15],1,r5
68 BGE divisorNotNegative
71 // Divisor is negative - negate divisor.
77 STL R[13:12],(FP)-1 \ JL (&__udivmodsi4)
78 =-> SUB.0 FP,8,FP // udivmodsi expects the frame to be valid still.
80 // The LSB of R9 indicates whether the quotient should be negated.
82 BEQ skipQuotientNegation
83 =-> LDL (FP)1,R[13:12] // Convenient point to restore link/fp
90 // The MSB of R9 indicates whether the remainder should be negated.
100 =-> LDL (FP)-2,R[9:8]
102 _picoMark_FUNCTION_END=
103 // picoChip Function Epilogue : __divmodsi4
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 //============================================================================
114 //============================================================================
115 // Frame information.
116 //============================================================================
118 .section .debug_frame
119 _picoMark_DebugFrame=
121 // Common CIE header.
122 .unalignedInitLong _picoMark_CieEnd-_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
137 _picoMark_LSFDE0I900821033007563=
138 .unalignedInitLong _picoMark_FdeEnd-_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
152 //============================================================================
153 // Abbrevation information.
154 //============================================================================
156 .section .debug_abbrev
157 _picoMark_ABBREVIATIONS=
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)
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)
192 //============================================================================
193 // Line information. DwarfLib requires this to be present, but it can
195 //============================================================================
200 //============================================================================
202 //============================================================================
206 .unalignedInitLong _picoMark_DEBUG_INFO_END-_picoMark_DEBUG_INFO_BEGIN
207 _picoMark_DEBUG_INFO_BEGIN=
208 .unalignedInitWord 0x2
209 .unalignedInitLong _picoMark_ABBREVIATIONS
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.
222 .uleb128 0x2 ;# (DIE DW_TAG_subprogram)
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
230 .initByte 0x0 // end of compile unit children.
232 _picoMark_DEBUG_INFO_END=
234 //============================================================================
236 //============================================================================
239 // End of picoChip ASM file