📄 math.lst
字号:
###############################################################################
# #
# 06/Mar/2009 22:11:47 #
# IAR ANSI C/C++ Compiler V5.20.2.21007/W32 EVALUATION for ARM #
# Copyright 1999-2008 IAR Systems AB. #
# #
# Cpu mode = arm #
# Endian = little #
# Source file = E:\IAR\at91lib\utility\math.c #
# Command line = E:\IAR\at91lib\utility\math.c -D at91sam9260 -D sdram #
# -lC E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\a #
# t91sam9260_sdram\List\ --remarks --diag_suppress #
# Pe826,Pe1375 -o E:\IAR\at91sam9260-ek\basic-twi-eeprom-p #
# roject\ewp\at91sam9260_sdram\Obj\ --no_cse --no_unroll #
# --no_inline --no_code_motion --no_tbaa --no_clustering #
# --no_scheduling --debug --endian=little #
# --cpu=ARM926EJ-S -e --fpu=None --dlib_config #
# "C:\Program Files\IAR Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\DLib_Config_Full.h" -I #
# E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\..\.. #
# \..\at91lib\ -I E:\IAR\at91sam9260-ek\basic-twi-eeprom-p #
# roject\ewp\..\..\..\at91lib\boards\at91sam9260-ek\ -I #
# E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\..\.. #
# \..\at91lib\peripherals\ -I #
# E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\..\.. #
# \..\at91lib\components\ -I E:\IAR\at91sam9260-ek\basic-t #
# wi-eeprom-project\ewp\..\..\..\at91lib\usb\ -I #
# "C:\Program Files\IAR Systems\Embedded Workbench 5.0 #
# Evaluation\ARM\INC\" --interwork --cpu_mode arm -On #
# List file = E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\at91s #
# am9260_sdram\List\math.lst #
# Object file = E:\IAR\at91sam9260-ek\basic-twi-eeprom-project\ewp\at91s #
# am9260_sdram\Obj\math.o #
# #
# #
###############################################################################
E:\IAR\at91lib\utility\math.c
1 /* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2008, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
29
30 //------------------------------------------------------------------------------
31 // Headers
32 //------------------------------------------------------------------------------
33
34 #include "math.h"
35
36 //------------------------------------------------------------------------------
37 // Exported functions
38 //------------------------------------------------------------------------------
39
40 //------------------------------------------------------------------------------
41 /// Returns the minimum value between two integers.
42 /// \param a First integer to compare.
43 /// \param b Second integer to compare.
44 //------------------------------------------------------------------------------
\ In section .text, align 4, keep-with-next
45 unsigned int min(unsigned int a, unsigned int b)
46 {
\ min:
\ 00000000 0020B0E1 MOVS R2,R0
47 if (a < b) {
\ 00000004 0200B0E1 MOVS R0,R2
\ 00000008 010052E1 CMP R2,R1
\ 0000000C 0000009A BLS ??min_0
\ 00000010 0100B0E1 MOVS R0,R1
48
49 return a;
\ ??min_0:
\ 00000014 1EFF2FE1 BX LR ;; return
50 }
51 else {
52
53 return b;
54 }
55 }
56
57 //------------------------------------------------------------------------------
58 /// Returns the absolute value of an integer.
59 /// \param value Integer value.
60 //------------------------------------------------------------------------------
\ In section .text, align 4, keep-with-next
61 unsigned int abs(signed int value)
62 {
63 if (value < 0) {
\ abs:
\ 00000000 000050E3 CMP R0,#+0
\ 00000004 0100005A BPL ??abs_0
64
65 return -value;
\ 00000008 000070E2 RSBS R0,R0,#+0
\ 0000000C FFFFFFEA B ??abs_1
66 }
67 else {
68
69 return value;
\ ??abs_0:
\ ??abs_1:
\ 00000010 1EFF2FE1 BX LR ;; return
70 }
71 }
72
73 //------------------------------------------------------------------------------
74 /// Computes and returns x power of y.
75 /// \param x Value.
76 /// \param y Power.
77 //------------------------------------------------------------------------------
\ In section .text, align 4, keep-with-next
78 unsigned int power(unsigned int x, unsigned int y)
79 {
\ power:
\ 00000000 0020B0E1 MOVS R2,R0
80 unsigned int result = 1;
\ 00000004 0130A0E3 MOV R3,#+1
\ 00000008 0300B0E1 MOVS R0,R3
81 while (y > 0) {
\ ??power_0:
\ 0000000C 000051E3 CMP R1,#+0
\ 00000010 0200000A BEQ ??power_1
82
83 result *= x;
\ 00000014 920010E0 MULS R0,R2,R0
84 y--;
\ 00000018 011051E2 SUBS R1,R1,#+1
\ 0000001C FAFFFFEA B ??power_0
85 }
86
87 return result;
\ ??power_1:
\ 00000020 1EFF2FE1 BX LR ;; return
88 }
89
Maximum stack usage in bytes:
Function .cstack
-------- -------
abs 0
min 0
power 0
Section sizes:
Function/Label Bytes
-------------- -----
min 24
abs 20
power 36
80 bytes in section .text
80 bytes of CODE memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -