~ubuntu-branches/ubuntu/breezy/avr-libc/breezy

« back to all changes in this revision

Viewing changes to libc/misc/mul10.S

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2002-04-15 14:53:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020415145338-c8hi0tn5bx74w7o3
Tags: upstream-20020203
ImportĀ upstreamĀ versionĀ 20020203

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   mul10.S - optimized 16-bit multiply by 10
 
3
 
 
4
   Contributors:
 
5
     Created by Marek Michalkiewicz <marekm@linux.org.pl>
 
6
 
 
7
   THIS SOFTWARE IS NOT COPYRIGHTED
 
8
 
 
9
   This source code is offered for use in the public domain.  You may
 
10
   use, modify or distribute it freely.
 
11
 
 
12
   This code is distributed in the hope that it will be useful, but
 
13
   WITHOUT ANY WARRANTY.  ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 
14
   DISCLAIMED.  This includes but is not limited to warranties of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
16
 */
 
17
 
 
18
#include "macros.inc"
 
19
 
 
20
#define r_hi r25
 
21
#define r_lo r24
 
22
#define r_tmp1 __tmp_reg__
 
23
#define r_tmp2 r23
 
24
 
 
25
/* 
 
26
   r_hi:r_lo *= 10
 
27
 
 
28
   Optimized version, without calling __mulhi3 (which is slow for
 
29
   non-enhanced core, and not present in libgcc.a for enhanced core).
 
30
 */
 
31
 
 
32
        .section .text
 
33
        .global _U(__mulhi_const_10)
 
34
 
 
35
_U(__mulhi_const_10):
 
36
#if __AVR_ENHANCED__
 
37
        ldi r_tmp2,10
 
38
        mul r_hi,r_tmp2
 
39
        mov r_hi,r0
 
40
        mul r_lo,r_tmp2
 
41
        mov r_lo,r0
 
42
        add r_hi,r1
 
43
        clr r1  ; __zero_reg__
 
44
#else
 
45
        mov r_tmp2,r_lo
 
46
        mov r_tmp1,r_hi
 
47
        add r_lo,r_lo
 
48
        adc r_hi,r_hi
 
49
        add r_lo,r_lo
 
50
        adc r_hi,r_hi
 
51
        add r_lo,r_tmp2
 
52
        adc r_hi,r_tmp1
 
53
        add r_lo,r_lo
 
54
        adc r_hi,r_hi
 
55
#endif
 
56
        ret
 
57