📄 printf_p.lst
字号:
1 .file "printf_P.c"
9 .Ltext0:
10 .align 2
11 .global PAD_0
13 PAD_0:
14 .LFB5:
15 .file 1 "printf_P.c"
1:printf_P.c **** /*
2:printf_P.c **** Copyright (C) 1993 Free Software Foundation
3:printf_P.c ****
4:printf_P.c **** This file is part of the GNU IO Library. This library is free
5:printf_P.c **** software; you can redistribute it and/or modify it under the
6:printf_P.c **** terms of the GNU General Public License as published by the
7:printf_P.c **** Free Software Foundation; either version 2, or (at your option)
8:printf_P.c **** any later version.
9:printf_P.c ****
10:printf_P.c **** This library is distributed in the hope that it will be useful,
11:printf_P.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
12:printf_P.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13:printf_P.c **** GNU General Public License for more details.
14:printf_P.c ****
15:printf_P.c **** You should have received a copy of the GNU General Public License
16:printf_P.c **** along with this library; see the file COPYING. If not, write to the Free
17:printf_P.c **** Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18:printf_P.c ****
19:printf_P.c **** As a special exception, if you link this library with files
20:printf_P.c **** compiled with a GNU compiler to produce an executable, this does not cause
21:printf_P.c **** the resulting executable to be covered by the GNU General Public License.
22:printf_P.c **** This exception does not however invalidate any other reasons why
23:printf_P.c **** the executable file might be covered by the GNU General Public License. */
24:printf_P.c ****
25:printf_P.c **** /*
26:printf_P.c **** * Copyright (c) 1990 Regents of the University of California.
27:printf_P.c **** * All rights reserved.
28:printf_P.c **** *
29:printf_P.c **** * Redistribution and use in source and binary forms, with or without
30:printf_P.c **** * modification, are permitted provided that the following conditions
31:printf_P.c **** * are met:
32:printf_P.c **** * 1. Redistributions of source code must retain the above copyright
33:printf_P.c **** * notice, this list of conditions and the following disclaimer.
34:printf_P.c **** * 2. Redistributions in binary form must reproduce the above copyright
35:printf_P.c **** * notice, this list of conditions and the following disclaimer in the
36:printf_P.c **** * documentation and/or other materials provided with the distribution.
37:printf_P.c **** * 3. [rescinded 22 July 1999]
38:printf_P.c **** * 4. Neither the name of the University nor the names of its contributors
39:printf_P.c **** * may be used to endorse or promote products derived from this software
40:printf_P.c **** * without specific prior written permission.
41:printf_P.c **** *
42:printf_P.c **** * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43:printf_P.c **** * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44:printf_P.c **** * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45:printf_P.c **** * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46:printf_P.c **** * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47:printf_P.c **** * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48:printf_P.c **** * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49:printf_P.c **** * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50:printf_P.c **** * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51:printf_P.c **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52:printf_P.c **** * SUCH DAMAGE.
53:printf_P.c **** */
54:printf_P.c ****
55:printf_P.c **** /* * ****************************************************************************
56:printf_P.c **** This file is a patched version of printf called _printf_P
57:printf_P.c **** It is made to work with avr-gcc for Atmel AVR MCUs.
58:printf_P.c **** There are some differences from standard printf:
59:printf_P.c **** 1. There is no floating point support (with fp the code is about 8K!)
60:printf_P.c **** 2. Return type is void
61:printf_P.c **** 3. Format string must be in program memory (by using macro printf this is
62:printf_P.c **** done automaticaly)
63:printf_P.c **** 4. %n is not implemented (just remove the comment around it if you need it)
64:printf_P.c **** 5. If LIGHTPRINTF is defined, the code is about 550 bytes smaller and the
65:printf_P.c **** folowing specifiers are disabled :
66:printf_P.c **** space # * . - + p s o O
67:printf_P.c **** 6. A function void uart_sendchar(char c) is used for output. The UART must
68:printf_P.c **** be initialized before using printf.
69:printf_P.c ****
70:printf_P.c **** Alexander Popov
71:printf_P.c **** sasho@vip.orbitel.bg
72:printf_P.c **** ******************************************************************************
73:printf_P.c **** Changed file to work with LPC - ARM.
74:printf_P.c **** Ingo Busker
75:printf_P.c **** busker@mikrocontroller.com 02.2005
76:printf_P.c **** ******************************************************************************/
77:printf_P.c ****
78:printf_P.c ****
79:printf_P.c **** /*
80:printf_P.c **** * Actual printf innards.
81:printf_P.c **** *
82:printf_P.c **** * This code is large and complicated...
83:printf_P.c **** */
84:printf_P.c ****
85:printf_P.c **** #include <string.h>
86:printf_P.c **** #ifdef __STDC__
87:printf_P.c **** #include <stdarg.h>
88:printf_P.c **** #else
89:printf_P.c **** #include <varargs.h>
90:printf_P.c **** #endif
91:printf_P.c ****
92:printf_P.c **** #include "uart.h"
93:printf_P.c ****
94:printf_P.c ****
95:printf_P.c **** //#define LIGHTPRINTF
96:printf_P.c ****
97:printf_P.c **** void PRINT(const char * ptr, unsigned int len) {
98:printf_P.c **** for(;len;len--)
99:printf_P.c **** uart0Putch(*ptr++);
100:printf_P.c **** }
101:printf_P.c ****
102:printf_P.c **** void PRINTP(const char * ptr, unsigned int len) {
103:printf_P.c **** for(;len;len--)
104:printf_P.c **** uart_sendchar(*ptr++);
105:printf_P.c **** }
106:printf_P.c ****
107:printf_P.c **** void PAD_SP(signed char howmany) {
108:printf_P.c **** for(;howmany>0;howmany--)
109:printf_P.c **** uart_sendchar(' ');
110:printf_P.c **** }
111:printf_P.c ****
112:printf_P.c **** void PAD_0(signed char howmany) {
16 @ args = 0, pretend = 0, frame = 0
17 @ frame_needed = 0, uses_anonymous_args = 0
18 .LVL0:
19 stmfd sp!, {r4, lr}
20 0000 10402DE9 .LCFI0:
21 .loc 1 112 0
22 and r4, r0, #255
23 0004 FF4000E2 b .L2
24 0008 020000EA .LVL1:
25 .L3:
26 .loc 1 114 0
113:printf_P.c **** for(;howmany>0;howmany--)
114:printf_P.c **** uart_sendchar('0');
27 ndchar
28 000c FEFFFFEB .loc 1 113 0
29 sub r3, r4, #1
30 0010 013044E2 and r4, r3, #255
31 0014 FF4003E2 .LVL2:
32 .L2:
33 mov r3, r4, asl #24
34 0018 043CA0E1 cmp r3, #0
35 001c 000053E3 .loc 1 114 0
36 mov r0, #48
37 0020 3000A0E3 .loc 1 113 0
38 bgt .L3
39 0024 F8FFFFCA .loc 1 115 0
115:printf_P.c **** }
40 r4, pc}
41 0028 1080BDE8 .LFE5:
43 .align 2
44 .global PAD_SP
46 PAD_SP:
47 .LFB4:
48 .loc 1 107 0
49 @ args = 0, pretend = 0, frame = 0
50 @ frame_needed = 0, uses_anonymous_args = 0
51 .LVL3:
52 stmfd sp!, {r4, lr}
53 002c 10402DE9 .LCFI1:
54 .loc 1 107 0
55 and r4, r0, #255
56 0030 FF4000E2 b .L7
57 0034 020000EA .LVL4:
58 .L8:
59 .loc 1 109 0
60 bl uart_sendchar
61 0038 FEFFFFEB .loc 1 108 0
62 sub r3, r4, #1
63 003c 013044E2 and r4, r3, #255
64 0040 FF4003E2 .LVL5:
65 .L7:
66 mov r3, r4, asl #24
67 0044 043CA0E1 cmp r3, #0
68 0048 000053E3 .loc 1 109 0
69 mov r0, #32
70 004c 2000A0E3 .loc 1 108 0
71 bgt .L8
72 0050 F8FFFFCA .loc 1 110 0
73 ldmfd sp!, {r4, pc}
74 0054 1080BDE8 .LFE4:
76 .align 2
77 .global PRINTP
79 PRINTP:
80 .LFB3:
81 .loc 1 102 0
82 @ args = 0, pretend = 0, frame = 0
83 @ frame_needed = 0, uses_anonymous_args = 0
84 .LVL6:
85 stmfd sp!, {r4, r5, lr}
86 0058 30402DE9 .LCFI2:
87 .loc 1 102 0
88 mov r5, r1
89 005c 0150A0E1 mov r4, r0
90 0060 0040A0E1 b .L12
91 0064 010000EA .LVL7:
92 .L13:
93 .loc 1 104 0
94 ldrb r0, [r4, #-1] @ zero_extendqisi2
95 0068 010054E5 .LVL8:
96 bl uart_sendchar
97 006c FEFFFFEB .LVL9:
98 .L12:
99 .loc 1 103 0
100 cmp r5, #0
101 0070 000055E3 add r4, r4, #1
102 0074 014084E2 sub r5, r5, #1
103 0078 015045E2 bne .L13
104 007c F9FFFF1A .loc 1 105 0
105 ldmfd sp!, {r4, r5, pc}
106 0080 3080BDE8 .LFE3:
108 .align 2
109 .global PRINT
111 PRINT:
112 .LFB2:
113 .loc 1 97 0
114 @ args = 0, pretend = 0, frame = 0
115 @ frame_needed = 0, uses_anonymous_args = 0
116 .LVL10:
117 stmfd sp!, {r4, r5, lr}
118 0084 30402DE9 .LCFI3:
119 .loc 1 97 0
120 mov r5, r1
121 0088 0150A0E1 mov r4, r0
122 008c 0040A0E1 b .L17
123 0090 010000EA .LVL11:
124 .L18:
125 .loc 1 99 0
126 ldrb r0, [r4, #-1] @ zero_extendqisi2
127 0094 010054E5 .LVL12:
128 bl uart0Putch
129 0098 FEFFFFEB .LVL13:
130 .L17:
131 .loc 1 98 0
132 cmp r5, #0
133 009c 000055E3 add r4, r4, #1
134 00a0 014084E2 sub r5, r5, #1
135 00a4 015045E2 bne .L18
136 00a8 F9FFFF1A .loc 1 100 0
137 ldmfd sp!, {r4, r5, pc}
138 00ac 3080BDE8 .LFE2:
140 .global __umodsi3
141 .global __udivsi3
142 .align 2
143 .global _printf_P
145 _printf_P:
146 .LFB6:
147 .loc 1 138 0
116:printf_P.c ****
117:printf_P.c **** #define BUF 40
118:printf_P.c ****
119:printf_P.c **** /*
120:printf_P.c **** * Macros for converting digits to letters and vice versa
121:printf_P.c **** */
122:printf_P.c **** #define to_digit(c) ((c) - '0')
123:printf_P.c **** #define is_digit(c) ((c)<='9' && (c)>='0')
124:printf_P.c **** #define to_char(n) ((n) + '0')
125:printf_P.c ****
126:printf_P.c **** /*
127:printf_P.c **** * Flags used during conversion.
128:printf_P.c **** */
129:printf_P.c **** #define LONGINT 0x01 /* long integer */
130:printf_P.c **** #define LONGDBL 0x02 /* long double; unimplemented */
131:printf_P.c **** #define SHORTINT 0x04 /* short integer */
132:printf_P.c **** #define ALT 0x08 /* alternate form */
133:printf_P.c **** #define LADJUST 0x10 /* left adjustment */
134:printf_P.c **** #define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
135:printf_P.c **** #define HEXPREFIX 0x40 /* add 0x or 0X prefix */
136:printf_P.c ****
137:printf_P.c **** void _printf_P (char const *fmt0, ...) /* Works with string from FLASH */
138:printf_P.c **** {
148 r1, r2, r3}
149 .LCFI4:
150 stmfd sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
151 .LCFI5:
152 00b0 0F002DE9 sub sp, sp, #60
153 .LCFI6:
154 00b4 F04F2DE9 .loc 1 164 0
155 add r3, sp, #100
156 00b8 3CD04DE2 str r3, [sp, #52]
157 .LVL15:
139:printf_P.c **** va_list ap;
140:printf_P.c **** register const char *fmt; /* format string */
141:printf_P.c **** register char ch; /* character from fmt */
142:printf_P.c **** register int n; /* handy integer (short term usage) */
143:printf_P.c **** register char *cp; /* handy char pointer (short term usage) */
144:printf_P.c **** const char *fmark; /* for remembering a place in fmt */
145:printf_P.c **** register unsigned char flags; /* flags as above */
146:printf_P.c **** signed char width; /* width from format (%8d), or 0 */
147:printf_P.c **** signed char prec; /* precision from format (%.3d), or -1 */
148:printf_P.c **** char sign; /* sign prefix (' ', '+', '-', or \0) */
149:printf_P.c **** unsigned long _ulong=0; /* integer arguments %[diouxX] */
150:printf_P.c **** #define OCT 8
151:printf_P.c **** #define DEC 10
152:printf_P.c **** #define HEX 16
153:printf_P.c **** unsigned char base; /* base for [diouxX] conversion */
154:printf_P.c **** signed char dprec; /* a copy of prec if [diouxX], 0 otherwise */
155:printf_P.c **** signed char dpad; /* extra 0 padding needed for integers */
156:printf_P.c **** signed char fieldsz; /* field size expanded by sign, dpad etc */
157:printf_P.c **** /* The initialization of 'size' is to suppress a warning that
158:printf_P.c **** 'size' might be used unitialized. It seems gcc can't
159:printf_P.c **** quite grok this spaghetti code ... */
160:printf_P.c **** signed char size = 0; /* size of converted field or string */
161:printf_P.c **** char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
162:printf_P.c **** char ox[2]; /* space for 0x hex-prefix */
163:printf_P.c ****
164:printf_P.c **** va_start(ap, fmt0);
158 sp, #96]
159 00bc 64308DE2 .LVL16:
160 00c0 34308DE5 mov fp, #0
161 .LVL17:
162 00c4 60909DE5 .LVL18:
163 .L168:
164 00c8 00B0A0E3 mov r5, r9
165 .LVL19:
166 b .L23
167 .LVL20:
168 00cc 0950A0E1 .L24:
169 .loc 1 172 0
170 00d0 000000EA add r5, r5, #1
171 .LVL21:
172 .L23:
165:printf_P.c ****
166:printf_P.c **** fmt = fmt0;
167:printf_P.c ****
168:printf_P.c **** /*
169:printf_P.c **** * Scan the format for conversions (`%' character).
170:printf_P.c **** */
171:printf_P.c **** for (;;) {
172:printf_P.c **** for (fmark = fmt; (ch = (*fmt)) != '\0' && ch != '%'; fmt++)
173 #0] @ zero_extendqisi2
174 00d4 015085E2 .LVL22:
175 cmp r4, #0
176 beq .L25
177 00d8 0040D5E5 cmp r4, #37
178 bne .L24
179 00dc 000054E3 .L25:
180 00e0 0100000A .loc 1 174 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -