Skip to content

Commit e74298a

Browse files
committed
shrinked function
1 parent 5765d9c commit e74298a

11 files changed

+423
-215
lines changed

build7dadea4ec5c47a9be4550e81267f0286.tmp/asm.txt

Lines changed: 103 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Disassembly of section .text:
3333
64: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
3434

3535
00000068 <__ctors_start>:
36-
68: ba 00 .word 0x00ba ; ????
36+
68: 97 00 .word 0x0097 ; ????
3737

3838
0000006a <__ctors_end>:
3939
6a: 11 24 eor r1, r1
@@ -64,12 +64,12 @@ Disassembly of section .text:
6464
8c: 04 c0 rjmp .+8 ; 0x96 <__do_global_ctors+0x10>
6565
8e: 22 97 sbiw r28, 0x02 ; 2
6666
90: fe 01 movw r30, r28
67-
92: 0e 94 d8 00 call 0x1b0 ; 0x1b0 <__tablejump__>
67+
92: 0e 94 b5 00 call 0x16a ; 0x16a <__tablejump__>
6868
96: c8 36 cpi r28, 0x68 ; 104
6969
98: d1 07 cpc r29, r17
7070
9a: c9 f7 brne .-14 ; 0x8e <__do_global_ctors+0x8>
71-
9c: 0e 94 d1 00 call 0x1a2 ; 0x1a2 <main>
72-
a0: 0c 94 dc 00 jmp 0x1b8 ; 0x1b8 <_exit>
71+
9c: 0e 94 ae 00 call 0x15c ; 0x15c <main>
72+
a0: 0c 94 b9 00 jmp 0x172 ; 0x172 <_exit>
7373

7474
000000a4 <__bad_interrupt>:
7575
a4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
@@ -101,187 +101,137 @@ void HardwareSerial::_tx_udr_empty_irq(void)
101101
000000c2 <_ZN14HardwareSerial5writeEh>:
102102
}
103103

104-
size_t HardwareSerial::write(uint8_t c)
104+
void HardwareSerial::write(uint8_t c)
105105
{
106-
c2: cf 92 push r12
107-
c4: df 92 push r13
108-
c6: ff 92 push r15
109-
c8: 0f 93 push r16
110-
ca: 1f 93 push r17
111-
cc: cf 93 push r28
112-
ce: df 93 push r29
113-
d0: 1f 92 push r1
114-
d2: cd b7 in r28, 0x3d ; 61
115-
d4: de b7 in r29, 0x3e ; 62
116-
d6: 6c 01 movw r12, r24
106+
c2: 0f 93 push r16
107+
c4: 1f 93 push r17
108+
c6: cf 93 push r28
109+
c8: df 93 push r29
110+
ca: 1f 92 push r1
111+
cc: cd b7 in r28, 0x3d ; 61
112+
ce: de b7 in r29, 0x3e ; 62
113+
d0: 8c 01 movw r16, r24
117114
// If the buffer and the data register is empty, just write the byte
118115
// to the data register and be done. This shortcut helps
119116
// significantly improve the effective datarate at high (>
120117
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
121118
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
122-
d8: dc 01 movw r26, r24
123-
da: 16 96 adiw r26, 0x06 ; 6
124-
dc: 9c 91 ld r25, X
125-
de: 16 97 sbiw r26, 0x06 ; 6
126-
e0: 17 96 adiw r26, 0x07 ; 7
127-
e2: 8c 91 ld r24, X
128-
e4: 17 97 sbiw r26, 0x07 ; 7
129-
e6: 98 13 cpse r25, r24
130-
e8: 05 c0 rjmp .+10 ; 0xf4 <_ZN14HardwareSerial5writeEh+0x32>
131-
ea: ed 91 ld r30, X+
132-
ec: fc 91 ld r31, X
133-
ee: 80 81 ld r24, Z
134-
f0: 85 fd sbrc r24, 5
135-
f2: 2a c0 rjmp .+84 ; 0x148 <_ZN14HardwareSerial5writeEh+0x86>
119+
d2: dc 01 movw r26, r24
120+
d4: 16 96 adiw r26, 0x06 ; 6
121+
d6: 9c 91 ld r25, X
122+
d8: 16 97 sbiw r26, 0x06 ; 6
123+
da: 17 96 adiw r26, 0x07 ; 7
124+
dc: 8c 91 ld r24, X
125+
de: 17 97 sbiw r26, 0x07 ; 7
126+
e0: 98 13 cpse r25, r24
127+
e2: 05 c0 rjmp .+10 ; 0xee <_ZN14HardwareSerial5writeEh+0x2c>
128+
e4: ed 91 ld r30, X+
129+
e6: fc 91 ld r31, X
130+
e8: 80 81 ld r24, Z
131+
ea: 85 fd sbrc r24, 5
132+
ec: 0f c0 rjmp .+30 ; 0x10c <_ZN14HardwareSerial5writeEh+0x4a>
136133
*_udr = c;
137134
sbi(*_ucsra, TXC0);
138-
return 1;
135+
return;
139136
}
140137

141-
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
142-
f4: f6 01 movw r30, r12
143-
f6: 06 81 ldd r16, Z+6 ; 0x06
144-
f8: 10 e0 ldi r17, 0x00 ; 0
145-
fa: 0f 5f subi r16, 0xFF ; 255
146-
fc: 1f 4f sbci r17, 0xFF ; 255
147-
fe: 0f 73 andi r16, 0x3F ; 63
148-
100: 11 27 eor r17, r17
149-
102: f0 2e mov r15, r16
150-
151-
// If the output buffer is full, there's nothing for it other than to
152-
// wait for the interrupt handler to empty it a bit
153-
while (i == _tx_buffer_tail) {
154-
104: f6 01 movw r30, r12
155-
106: 87 81 ldd r24, Z+7 ; 0x07
156-
108: f8 12 cpse r15, r24
157-
10a: 0f c0 rjmp .+30 ; 0x12a <_ZN14HardwareSerial5writeEh+0x68>
158-
if (bit_is_clear(SREG, SREG_I)) {
159-
10c: 0f b6 in r0, 0x3f ; 63
160-
10e: 07 fc sbrc r0, 7
161-
110: f9 cf rjmp .-14 ; 0x104 <_ZN14HardwareSerial5writeEh+0x42>
162-
// Interrupts are disabled, so we'll have to poll the data
163-
// register empty flag ourselves. If it is set, pretend an
164-
// interrupt has happened and call the handler to free up
165-
// space for us.
166-
if(bit_is_set(*_ucsra, UDRE0))
167-
112: d6 01 movw r26, r12
168-
114: ed 91 ld r30, X+
169-
116: fc 91 ld r31, X
170-
118: 80 81 ld r24, Z
171-
11a: 85 ff sbrs r24, 5
172-
11c: f3 cf rjmp .-26 ; 0x104 <_ZN14HardwareSerial5writeEh+0x42>
173-
_tx_udr_empty_irq();
174-
11e: c6 01 movw r24, r12
175-
120: 69 83 std Y+1, r22 ; 0x01
176-
122: 0e 94 5a 00 call 0xb4 ; 0xb4 <_ZN14HardwareSerial17_tx_udr_empty_irqEv>
177-
126: 69 81 ldd r22, Y+1 ; 0x01
178-
128: ed cf rjmp .-38 ; 0x104 <_ZN14HardwareSerial5writeEh+0x42>
179-
} else {
180-
// nop, the interrupt handler will free up space for us
181-
}
138+
while (0== _tx_buffer_tail) {
139+
ee: f8 01 movw r30, r16
140+
f0: 87 81 ldd r24, Z+7 ; 0x07
141+
f2: 81 11 cpse r24, r1
142+
f4: 06 c0 rjmp .+12 ; 0x102 <_ZN14HardwareSerial5writeEh+0x40>
143+
_tx_udr_empty_irq();
144+
f6: c8 01 movw r24, r16
145+
f8: 69 83 std Y+1, r22 ; 0x01
146+
fa: 0e 94 5a 00 call 0xb4 ; 0xb4 <_ZN14HardwareSerial17_tx_udr_empty_irqEv>
147+
fe: 69 81 ldd r22, Y+1 ; 0x01
148+
100: f6 cf rjmp .-20 ; 0xee <_ZN14HardwareSerial5writeEh+0x2c>
182149
}
183-
184150
_tx_buffer[_tx_buffer_head] = c;
185-
12a: 86 81 ldd r24, Z+6 ; 0x06
186-
12c: e8 0f add r30, r24
187-
12e: f1 1d adc r31, r1
188-
130: 60 87 std Z+8, r22 ; 0x08
189-
_tx_buffer_head = i;
190-
132: d6 01 movw r26, r12
191-
134: 16 96 adiw r26, 0x06 ; 6
192-
136: 0c 93 st X, r16
193-
138: 16 97 sbiw r26, 0x06 ; 6
194-
195-
sbi(*_ucsrb, UDRIE0);
196-
13a: 12 96 adiw r26, 0x02 ; 2
197-
13c: ed 91 ld r30, X+
198-
13e: fc 91 ld r31, X
199-
140: 13 97 sbiw r26, 0x03 ; 3
200-
142: 80 81 ld r24, Z
201-
144: 80 62 ori r24, 0x20 ; 32
202-
146: 0a c0 rjmp .+20 ; 0x15c <_ZN14HardwareSerial5writeEh+0x9a>
151+
102: 86 81 ldd r24, Z+6 ; 0x06
152+
104: e8 0f add r30, r24
153+
106: f1 1d adc r31, r1
154+
108: 60 87 std Z+8, r22 ; 0x08
155+
156+
return;
157+
10a: 0b c0 rjmp .+22 ; 0x122 <_ZN14HardwareSerial5writeEh+0x60>
203158
// If the buffer and the data register is empty, just write the byte
204159
// to the data register and be done. This shortcut helps
205160
// significantly improve the effective datarate at high (>
206161
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
207162
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
208163
*_udr = c;
209-
148: d6 01 movw r26, r12
210-
14a: 14 96 adiw r26, 0x04 ; 4
211-
14c: ed 91 ld r30, X+
212-
14e: fc 91 ld r31, X
213-
150: 15 97 sbiw r26, 0x05 ; 5
214-
152: 60 83 st Z, r22
164+
10c: d8 01 movw r26, r16
165+
10e: 14 96 adiw r26, 0x04 ; 4
166+
110: ed 91 ld r30, X+
167+
112: fc 91 ld r31, X
168+
114: 15 97 sbiw r26, 0x05 ; 5
169+
116: 60 83 st Z, r22
215170
sbi(*_ucsra, TXC0);
216-
154: ed 91 ld r30, X+
217-
156: fc 91 ld r31, X
218-
158: 80 81 ld r24, Z
219-
15a: 80 64 ori r24, 0x40 ; 64
220-
15c: 80 83 st Z, r24
221-
_tx_buffer_head = i;
222-
223-
sbi(*_ucsrb, UDRIE0);
171+
118: ed 91 ld r30, X+
172+
11a: fc 91 ld r31, X
173+
11c: 80 81 ld r24, Z
174+
11e: 80 64 ori r24, 0x40 ; 64
175+
120: 80 83 st Z, r24
176+
_tx_udr_empty_irq();
177+
}
178+
_tx_buffer[_tx_buffer_head] = c;
224179

225-
return 1;
180+
return;
226181
}
227-
15e: 81 e0 ldi r24, 0x01 ; 1
228-
160: 90 e0 ldi r25, 0x00 ; 0
229-
162: 0f 90 pop r0
230-
164: df 91 pop r29
231-
166: cf 91 pop r28
232-
168: 1f 91 pop r17
233-
16a: 0f 91 pop r16
234-
16c: ff 90 pop r15
235-
16e: df 90 pop r13
236-
170: cf 90 pop r12
237-
172: 08 95 ret
238-
239-
00000174 <_GLOBAL__sub_I__ZN14HardwareSerial17_tx_udr_empty_irqEv>:
182+
122: 0f 90 pop r0
183+
124: df 91 pop r29
184+
126: cf 91 pop r28
185+
128: 1f 91 pop r17
186+
12a: 0f 91 pop r16
187+
12c: 08 95 ret
188+
189+
0000012e <_GLOBAL__sub_I__ZN14HardwareSerial17_tx_udr_empty_irqEv>:
190+
191+
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
240192
volatile uint8_t *udr):
241193
_ucsra(ucsra), _ucsrb(ucsrb),
242194
_udr(udr),
243195
_tx_buffer_head(0), _tx_buffer_tail(0)
244-
{
245-
}
246-
174: 80 ec ldi r24, 0xC0 ; 192
247-
176: 90 e0 ldi r25, 0x00 ; 0
248-
178: 90 93 01 01 sts 0x0101, r25
249-
17c: 80 93 00 01 sts 0x0100, r24
250-
180: 81 ec ldi r24, 0xC1 ; 193
251-
182: 90 e0 ldi r25, 0x00 ; 0
252-
184: 90 93 03 01 sts 0x0103, r25
253-
188: 80 93 02 01 sts 0x0102, r24
254-
18c: 86 ec ldi r24, 0xC6 ; 198
255-
18e: 90 e0 ldi r25, 0x00 ; 0
256-
190: 90 93 05 01 sts 0x0105, r25
257-
194: 80 93 04 01 sts 0x0104, r24
258-
198: 10 92 06 01 sts 0x0106, r1
259-
19c: 10 92 07 01 sts 0x0107, r1
260-
1a0: 08 95 ret
261-
262-
000001a2 <main>:
196+
12e: 80 ec ldi r24, 0xC0 ; 192
197+
130: 90 e0 ldi r25, 0x00 ; 0
198+
132: 90 93 01 01 sts 0x0101, r25
199+
136: 80 93 00 01 sts 0x0100, r24
200+
13a: 81 ec ldi r24, 0xC1 ; 193
201+
13c: 90 e0 ldi r25, 0x00 ; 0
202+
13e: 90 93 03 01 sts 0x0103, r25
203+
142: 80 93 02 01 sts 0x0102, r24
204+
146: 86 ec ldi r24, 0xC6 ; 198
205+
148: 90 e0 ldi r25, 0x00 ; 0
206+
14a: 90 93 05 01 sts 0x0105, r25
207+
14e: 80 93 04 01 sts 0x0104, r24
208+
152: 10 92 06 01 sts 0x0106, r1
209+
156: 10 92 07 01 sts 0x0107, r1
210+
15a: 08 95 ret
211+
212+
0000015c <main>:
263213
#include <Arduino.h>
264214
int main(void)
265215
{
266216
setup();
267-
1a2: 0e 94 54 00 call 0xa8 ; 0xa8 <setup>
217+
15c: 0e 94 54 00 call 0xa8 ; 0xa8 <setup>
268218
for (;;) {
269219
loop();
270-
1a6: 0e 94 59 00 call 0xb2 ; 0xb2 <loop>
271-
1aa: fd cf rjmp .-6 ; 0x1a6 <main+0x4>
220+
160: 0e 94 59 00 call 0xb2 ; 0xb2 <loop>
221+
164: fd cf rjmp .-6 ; 0x160 <main+0x4>
272222

273-
000001ac <__tablejump2__>:
274-
1ac: ee 0f add r30, r30
275-
1ae: ff 1f adc r31, r31
223+
00000166 <__tablejump2__>:
224+
166: ee 0f add r30, r30
225+
168: ff 1f adc r31, r31
276226

277-
000001b0 <__tablejump__>:
278-
1b0: 05 90 lpm r0, Z+
279-
1b2: f4 91 lpm r31, Z
280-
1b4: e0 2d mov r30, r0
281-
1b6: 09 94 ijmp
227+
0000016a <__tablejump__>:
228+
16a: 05 90 lpm r0, Z+
229+
16c: f4 91 lpm r31, Z
230+
16e: e0 2d mov r30, r0
231+
170: 09 94 ijmp
282232

283-
000001b8 <_exit>:
284-
1b8: f8 94 cli
233+
00000172 <_exit>:
234+
172: f8 94 cli
285235

286-
000001ba <__stop_program>:
287-
1ba: ff cf rjmp .-2 ; 0x1ba <__stop_program>
236+
00000174 <__stop_program>:
237+
174: ff cf rjmp .-2 ; 0x174 <__stop_program>

0 commit comments

Comments
 (0)