?? rprintf.lst
字號(hào):
1 .code 16 2 .file "rprintf.c" 10 .Ltext0: 11 .align 2 12 .code 16 13 .thumb_func 15 myputchar: 16 .LFB2: 17 .file 1 "usart/rprintf.c" 1:usart/rprintf.c **** //#########################################################################
2:usart/rprintf.c **** // (r)printf.c
3:usart/rprintf.c **** //
4:usart/rprintf.c **** // code based on sprintf() from gcctest9.c by Volker Oth
5:usart/rprintf.c **** //
6:usart/rprintf.c **** // Changes made by Holger Klabunde:
7:usart/rprintf.c **** // Now takes format strings from FLASH (was into RAM ! before)
8:usart/rprintf.c **** // Fixed bug for %i, %I. u_val was used before it had the right value
9:usart/rprintf.c **** // Added %d, %D (is same as %i, %I)
10:usart/rprintf.c **** // Support for long variables %li, %ld, %Lu, %LX ....
11:usart/rprintf.c **** // %x, %X now gives upper case hex characters A,B,C,D,E,F
12:usart/rprintf.c **** // Output can be redirected in a single function: myputchar()
13:usart/rprintf.c **** // Make printf() smaller by commenting out a few #defines
14:usart/rprintf.c **** // Added some SPACE and ZERO padding %02x or % 3u up to 9 characters
15:usart/rprintf.c **** //
16:usart/rprintf.c **** // Changes made by Martin Thomas:
17:usart/rprintf.c **** // LPC2000 port using the R O Software UART-Interface (see myputchar)
18:usart/rprintf.c **** // ARM7S port using minimal uart interface
19:usart/rprintf.c **** // reverted Klabundes "from flash" since only useful for AVR "Harvard"
20:usart/rprintf.c **** //
21:usart/rprintf.c **** // Todo:
22:usart/rprintf.c **** // %f, %F for floating point numbers
23:usart/rprintf.c **** //
24:usart/rprintf.c **** //#########################################################################
25:usart/rprintf.c ****
26:usart/rprintf.c **** #include <stdarg.h>
27:usart/rprintf.c **** #include <string.h>
28:usart/rprintf.c **** #include "include/rprintf.h"
29:usart/rprintf.c **** #include "include/include.h"
30:usart/rprintf.c ****
31:usart/rprintf.c **** #define SCRATCH 12 //32Bits go up to 4GB + 1 Byte for \0
32:usart/rprintf.c ****
33:usart/rprintf.c **** //Spare some program space by making a comment of all not used format flag lines
34:usart/rprintf.c **** #define USE_LONG // %lx, %Lu and so on, else only 16 bit integer is allowed
35:usart/rprintf.c **** //#define USE_OCTAL // %o, %O Octal output. Who needs this ?
36:usart/rprintf.c **** #define USE_STRING // %s, %S Strings as parameters
37:usart/rprintf.c **** #define USE_CHAR // %c, %C Chars as parameters
38:usart/rprintf.c **** #define USE_INTEGER // %i, %I Remove this format flag. %d, %D does the same
39:usart/rprintf.c **** #define USE_HEX // %x, %X Hexadezimal output
40:usart/rprintf.c **** #define USE_UPPERHEX // %x, %X outputs A,B,C... else a,b,c...
41:usart/rprintf.c **** #ifndef USE_HEX
42:usart/rprintf.c **** #undef USE_UPPERHEX // ;)
43:usart/rprintf.c **** #endif
44:usart/rprintf.c **** #define USE_UPPER // uncommenting this removes %C,%D,%I,%O,%S,%U,%X and %L..
45:usart/rprintf.c **** // only lowercase format flags are used
46:usart/rprintf.c **** #define PADDING //SPACE and ZERO padding
47:usart/rprintf.c ****
48:usart/rprintf.c **** #include "include/serial.h"
49:usart/rprintf.c **** #include "include/include.h"
50:usart/rprintf.c ****
51:usart/rprintf.c **** //extern char data[MSG_SIZE];
52:usart/rprintf.c **** extern unsigned int length;
53:usart/rprintf.c ****
54:usart/rprintf.c **** static void myputchar(unsigned char c)
55:usart/rprintf.c **** {
18 .loc 1 55 0 19 0000 10B5 push {r4, lr} 20 .LCFI0: 21 .LVL0: 22 .loc 1 55 0 23 0002 0006 lsl r0, r0, #24 24 .LVL1: 25 0004 040E lsr r4, r0, #24 26 .LVL2: 56:usart/rprintf.c **** if(c == '\n') uart0_putc('\r');
27 .loc 1 56 0 28 0006 0A2C cmp r4, #10 29 0008 02D1 bne .L2 30 000a 0D20 mov r0, #13 31 000c FFF7FEFF bl uart0_putc 32 .L2: 57:usart/rprintf.c **** uart0_putc(c); // see serial.c //FOR USART
33 .loc 1 57 0 34 0010 201C mov r0, r4 35 0012 FFF7FEFF bl uart0_putc 58:usart/rprintf.c ****
59:usart/rprintf.c **** //data[length]=(char)c;
60:usart/rprintf.c **** //length++;
61:usart/rprintf.c **** }
36 .loc 1 61 0 37 @ sp needed for prologue 38 .LVL3: 39 0016 10BC pop {r4} 40 0018 01BC pop {r0} 41 001a 0047 bx r0 42 .LFE2: 44 .global __umodsi3 45 .global __udivsi3 46 .align 2 47 .global rprintf 48 .code 16 49 .thumb_func 51 rprintf: 52 .LFB3: 62:usart/rprintf.c ****
63:usart/rprintf.c ****
64:usart/rprintf.c **** #if 0
65:usart/rprintf.c ****
66:usart/rprintf.c **** #include "softuart.h"
67:usart/rprintf.c ****
68:usart/rprintf.c **** static void myputchar(unsigned char c)
69:usart/rprintf.c **** {
70:usart/rprintf.c **** if(c == '\n') softuart_putchar('\r');
71:usart/rprintf.c **** softuart_putchar(c); // see softuart.c
72:usart/rprintf.c **** }
73:usart/rprintf.c **** #endif
74:usart/rprintf.c ****
75:usart/rprintf.c **** #if 0
76:usart/rprintf.c **** static void myputchar(unsigned char c)
77:usart/rprintf.c **** {
78:usart/rprintf.c **** while ( uart0Space() < 2 );
79:usart/rprintf.c **** if(c == '\n') uart0Putch('\r');
80:usart/rprintf.c **** uart0Putch(c); // see uart.c
81:usart/rprintf.c **** }
82:usart/rprintf.c **** #endif
83:usart/rprintf.c ****
84:usart/rprintf.c **** void rprintf(char const *format, ...)
85:usart/rprintf.c **** {
53 .loc 1 85 0 54 001c 0FB4 push {r0, r1, r2, r3} 55 .LCFI1: 56 001e F0B5 push {r4, r5, r6, r7, lr} 57 .LCFI2: 58 .LVL4: 59 0020 86B0 sub sp, sp, #24 60 .LCFI3: 61 .LVL5: 62 .loc 1 85 0 63 0022 0BAB add r3, sp, #44 64 0024 04CB ldmia r3!, {r2} 86:usart/rprintf.c **** unsigned char scratch[SCRATCH];
87:usart/rprintf.c **** unsigned char format_flag;
88:usart/rprintf.c **** unsigned short base;
89:usart/rprintf.c **** unsigned char *ptr;
90:usart/rprintf.c **** unsigned char issigned=0;
91:usart/rprintf.c **** va_list ap;
92:usart/rprintf.c ****
93:usart/rprintf.c **** #ifdef USE_LONG
94:usart/rprintf.c **** unsigned char islong=0;
95:usart/rprintf.c **** unsigned long u_val=0;
96:usart/rprintf.c **** long s_val=0;
97:usart/rprintf.c **** #else
98:usart/rprintf.c **** unsigned int u_val=0;
99:usart/rprintf.c **** int s_val=0;
100:usart/rprintf.c **** #endif
101:usart/rprintf.c ****
102:usart/rprintf.c **** unsigned char fill;
103:usart/rprintf.c **** unsigned char width;
104:usart/rprintf.c ****
105:usart/rprintf.c **** va_start (ap, format);
65 .loc 1 105 0 66 0026 0593 str r3, [sp, #20] 67 .LVL6: 68 0028 05E0 b .L6 69 .LVL7: 70 .L7: 106:usart/rprintf.c **** for (;;){
107:usart/rprintf.c **** while ((format_flag = *(format++)) != '%'){ // Until '%' or '\0'
108:usart/rprintf.c **** if (!format_flag){va_end (ap); return;}
71 .loc 1 108 0 72 002a 0028 cmp r0, #0 73 002c 00D1 bne .LCB56 74 002e A1E0 b .L52 @long jump 75 .LCB56: 76 .LVL8: 77 .L56: 109:usart/rprintf.c **** myputchar(format_flag);
78 .loc 1 109 0 79 0030 FFF7FEFF bl myputchar 80 .LVL9: 81 .L10: 82 0034 321C mov r2, r6 83 .LVL10: 84 .L6: 85 .loc 1 107 0 86 0036 1078 ldrb r0, [r2] 87 .LVL11: 88 0038 561C add r6, r2, #1 89 003a 2528 cmp r0, #37 90 003c F5D1 bne .L7 110:usart/rprintf.c **** }
111:usart/rprintf.c ****
112:usart/rprintf.c **** issigned=0; //default unsigned
113:usart/rprintf.c **** base = 10;
114:usart/rprintf.c ****
115:usart/rprintf.c **** format_flag = *format++; //get char after '%'
91 .loc 1 115 0 92 003e 5078 ldrb r0, [r2, #1] 93 .LVL12: 94 0040 961C add r6, r2, #2 116:usart/rprintf.c ****
117:usart/rprintf.c **** #ifdef PADDING
118:usart/rprintf.c **** width=0; //no formatting
119:usart/rprintf.c **** fill=0; //no formatting
120:usart/rprintf.c **** if(format_flag=='0' || format_flag==' ') //SPACE or ZERO padding ?
95 .loc 1 120 0 96 0042 3028 cmp r0, #48 97 0044 05D0 beq .L12 98 0046 2028 cmp r0, #32 99 0048 03D0 beq .L12 100 004a 0022 mov r2, #0 101 .LVL13: 102 004c 0192 str r2, [sp, #4] 103 004e 0092 str r2, [sp] 104 0050 10E0 b .L15 105 .LVL14: 106 .L12: 121:usart/rprintf.c **** {
122:usart/rprintf.c **** fill=format_flag;
123:usart/rprintf.c **** format_flag = *format++; //get char after padding char
107 .loc 1 123 0 108 0052 3178 ldrb r1, [r6] 124:usart/rprintf.c **** if(format_flag>='0' && format_flag<='9')
109 .loc 1 124 0 110 0054 0B1C mov r3, r1 111 0056 303B sub r3, r3, #48 112 0058 1B06 lsl r3, r3, #24 113 005a 1B0E lsr r3, r3, #24 114 .loc 1 123 0 115 005c D61C add r6, r2, #3 116 .loc 1 124 0 117 005e 092B cmp r3, #9 118 0060 04D9 bls .L16 119 0062 0090 str r0, [sp] 120 0064 0023 mov r3, #0 121 0066 081C mov r0, r1 122 0068 0193 str r3, [sp, #4] 123 006a 03E0 b .L15 124 .L16: 125:usart/rprintf.c **** {
126:usart/rprintf.c **** width=format_flag-'0';
125 .loc 1 126 0 126 006c 0193 str r3, [sp, #4] 127:usart/rprintf.c **** format_flag = *format++; //get char after width char
127 .loc 1 127 0 128 006e 0090 str r0, [sp] 129 0070 D078 ldrb r0, [r2, #3] 130 0072 161D add r6, r2, #4 131 .LVL15: 132 .L15: 128:usart/rprintf.c **** }
129:usart/rprintf.c **** }
130:usart/rprintf.c **** #endif
131:usart/rprintf.c ****
132:usart/rprintf.c **** #ifdef USE_LONG
133:usart/rprintf.c **** islong=0; //default int value
134:usart/rprintf.c **** #ifdef USE_UPPER
135:usart/rprintf.c **** if(format_flag=='l' || format_flag=='L') //Long value
133 .loc 1 135 0 134 0074 6C28 cmp r0, #108 135 0076 01D0 beq .L18 136 0078 4C28 cmp r0, #76 137 007a 01D1 bne .L21 138 .L18: 136:usart/rprintf.c **** #else
137:usart/rprintf.c **** if(format_flag=='l') //Long value
138:usart/rprintf.c **** #endif
139:usart/rprintf.c **** {
140:usart/rprintf.c **** islong=1;
141:usart/rprintf.c **** format_flag = *format++; //get char after 'l' or 'L'
139 .loc 1 141 0 140 007c 3078 ldrb r0, [r6] 141 007e 0136 add r6, r6, #1 142 .L21: 142:usart/rprintf.c **** }
143:usart/rprintf.c **** #endif
144:usart/rprintf.c ****
145:usart/rprintf.c **** switch (format_flag)
143 .loc 1 145 0 144 0080 5828 cmp r0, #88 145 0082 30D0 beq .L27 146 0084 5828 cmp r0, #88 147 0086 0DD8 bhi .L28 148 0088 4928 cmp r0, #73 149 008a 2ED0 beq .L24 150 008c 4928 cmp r0, #73 151 008e 04D8 bhi .L29 152 0090 4328 cmp r0, #67 153 0092 17D0 beq .L23 154 0094 4428 cmp r0, #68 155 0096 CBD1 bne .L56 156 0098 27E0 b .L24 157 .L29: 158 009a 5328 cmp r0, #83 159 009c 17D0 beq .L25 160 009e 5528 cmp r0, #85 161 00a0 C6D1 bne .L56 162 00a2 2EE0 b .L26 163 .L28: 164 00a4 6928 cmp r0, #105 165 00a6 20D0 beq .L24 166 00a8 6928 cmp r0, #105 167 00aa 04D8 bhi .L30 168 00ac 6328 cmp r0, #99 169 00ae 09D0 beq .L23 170 00b0 6428 cmp r0, #100
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -