Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Make your Arduino speak Morse code. Hook it up to an LED or a buzzer in series with a small resistor, and then write in text over the serial port. Done. This gist now includes an object code dump.
int led_pin = 2;
#define PERIOD (100)
void setup() {
pinMode(led_pin, OUTPUT);
Serial.begin(9600);
}
void writeMorse(char *code) {
int i = 0;
while (true) {
char currentChar = code[i];
if (currentChar == '\0') {
break;
}
else if (currentChar == '.') {
digitalWrite(led_pin, HIGH);
delay(PERIOD);
digitalWrite(led_pin, LOW);
delay(PERIOD);
}
else if (currentChar == '-') {
digitalWrite(led_pin, HIGH);
delay(PERIOD * 2);
digitalWrite(led_pin, LOW);
delay(PERIOD);
}
else if (currentChar == ' ') {
digitalWrite(led_pin, LOW);
delay(PERIOD * 2);
}
else if (currentChar == '/') {
digitalWrite(led_pin, LOW);
delay(PERIOD * 7);
}
i += 1;
}
}
void loop () {
// noop.
}
void serialEvent () {
char c = Serial.read();
switch (c) {
case 'A':
case 'a':
writeMorse(".- "); break;
case 'B':
case 'b':
writeMorse("-... "); break;
case 'C':
case 'c':
writeMorse("-.-. "); break;
case 'D':
case 'd':
writeMorse("-.. "); break;
case 'E':
case 'e':
writeMorse(". "); break;
case 'F':
case 'f':
writeMorse("..-. "); break;
case 'G':
case 'g':
writeMorse("--. "); break;
case 'H':
case 'h':
writeMorse(".... "); break;
case 'I':
case 'i':
writeMorse(".. "); break;
case 'J':
case 'j':
writeMorse(".--- "); break;
case 'K':
case 'k':
writeMorse("-.- "); break;
case 'L':
case 'l':
writeMorse(".-.. "); break;
case 'M':
case 'm':
writeMorse("-- "); break;
case 'N':
case 'n':
writeMorse("-. "); break;
case 'O':
case 'o':
writeMorse("--- "); break;
case 'P':
case 'p':
writeMorse(".--. "); break;
case 'Q':
case 'q':
writeMorse("--.- "); break;
case 'R':
case 'r':
writeMorse(".-. "); break;
case 'S':
case 's':
writeMorse("... "); break;
case 'T':
case 't':
writeMorse("- "); break;
case 'U':
case 'u':
writeMorse("..- "); break;
case 'V':
case 'v':
writeMorse("...- "); break;
case 'W':
case 'w':
writeMorse(".-- "); break;
case 'X':
case 'x':
writeMorse("-..- "); break;
case 'Y':
case 'y':
writeMorse("-.-- "); break;
case 'Z':
case 'z':
writeMorse("--.. "); break;
case ' ':
writeMorse("/"); break;
case '1':
writeMorse(".---- "); break;
case '2':
writeMorse("..--- "); break;
case '3':
writeMorse("...-- "); break;
case '4':
writeMorse("....- "); break;
case '5':
writeMorse("..... "); break;
case '6':
writeMorse("-.... "); break;
case '7':
writeMorse("--... "); break;
case '8':
writeMorse("---.. "); break;
case '9':
writeMorse("----. "); break;
case '0':
writeMorse("----- "); break;
default:
break;
}
}
/var/folders/3s/70md0ygx2jq18jxg_6_13rd40000gn/T/build1988031117167001169.tmp/sketch_mar02a.cpp.elf: file format elf32-avr
Disassembly of section .text:
00000000 <__vectors>:
timer0_millis = m;
timer0_overflow_count++;
}
unsigned long millis()
{
0: 0c 94 bd 00 jmp 0x17a ; 0x17a <__ctors_end>
SREG = oldSREG;
}
int digitalRead(uint8_t pin)
{
4: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
!defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \
!defined(SIG_UART_RECV)
#error "Don't know what the Data Received vector is called for the first UART"
#else
void serialEvent() __attribute__((weak));
void serialEvent() {}
8: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
n += write(*buffer++);
}
return n;
}
size_t Print::print(const __FlashStringHelper *ifsh)
c: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
10: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
14: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
18: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
1c: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
20: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
24: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
28: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
2c: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
30: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
34: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
38: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
3c: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
40: 0c 94 c7 01 jmp 0x38e ; 0x38e <__vector_16>
44: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
48: 0c 94 45 03 jmp 0x68a ; 0x68a <__vector_18>
4c: 0c 94 93 03 jmp 0x726 ; 0x726 <__vector_19>
50: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
54: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
58: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
5c: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
60: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
64: 0c 94 e5 00 jmp 0x1ca ; 0x1ca <__bad_interrupt>
68: 94 01 movw r18, r8
6a: b8 01 movw r22, r16
6c: b8 01 movw r22, r16
6e: b8 01 movw r22, r16
70: b8 01 movw r22, r16
72: b8 01 movw r22, r16
74: b8 01 movw r22, r16
76: b8 01 movw r22, r16
78: b8 01 movw r22, r16
7a: b8 01 movw r22, r16
7c: b8 01 movw r22, r16
7e: b8 01 movw r22, r16
80: b8 01 movw r22, r16
82: b8 01 movw r22, r16
84: b8 01 movw r22, r16
86: b8 01 movw r22, r16
88: b4 01 movw r22, r8
8a: 97 01 movw r18, r14
8c: 9a 01 movw r18, r20
8e: 9d 01 movw r18, r26
90: a0 01 movw r20, r0
92: a3 01 movw r20, r6
94: a6 01 movw r20, r12
96: a9 01 movw r20, r18
98: ac 01 movw r20, r24
9a: af 01 movw r20, r30
9c: b8 01 movw r22, r16
9e: b8 01 movw r22, r16
a0: b8 01 movw r22, r16
a2: b8 01 movw r22, r16
a4: b8 01 movw r22, r16
a6: b8 01 movw r22, r16
a8: b8 01 movw r22, r16
aa: 46 01 movw r8, r12
ac: 49 01 movw r8, r18
ae: 4c 01 movw r8, r24
b0: 4f 01 movw r8, r30
b2: 52 01 movw r10, r4
b4: 55 01 movw r10, r10
b6: 58 01 movw r10, r16
b8: 5b 01 movw r10, r22
ba: 5e 01 movw r10, r28
bc: 61 01 movw r12, r2
be: 64 01 movw r12, r8
c0: 67 01 movw r12, r14
c2: 6a 01 movw r12, r20
c4: 6d 01 movw r12, r26
c6: 70 01 movw r14, r0
c8: 73 01 movw r14, r6
ca: 76 01 movw r14, r12
cc: 79 01 movw r14, r18
ce: 7c 01 movw r14, r24
d0: 7f 01 movw r14, r30
d2: 82 01 movw r16, r4
d4: 85 01 movw r16, r10
d6: 88 01 movw r16, r16
d8: 8b 01 movw r16, r22
da: 8e 01 movw r16, r28
dc: 91 01 movw r18, r2
de: b8 01 movw r22, r16
e0: b8 01 movw r22, r16
e2: b8 01 movw r22, r16
e4: b8 01 movw r22, r16
e6: b8 01 movw r22, r16
e8: b8 01 movw r22, r16
ea: 46 01 movw r8, r12
ec: 49 01 movw r8, r18
ee: 4c 01 movw r8, r24
f0: 4f 01 movw r8, r30
f2: 52 01 movw r10, r4
f4: 55 01 movw r10, r10
f6: 58 01 movw r10, r16
f8: 5b 01 movw r10, r22
fa: 5e 01 movw r10, r28
fc: 61 01 movw r12, r2
fe: 64 01 movw r12, r8
100: 67 01 movw r12, r14
102: 6a 01 movw r12, r20
104: 6d 01 movw r12, r26
106: 70 01 movw r14, r0
108: 73 01 movw r14, r6
10a: 76 01 movw r14, r12
10c: 79 01 movw r14, r18
10e: 7c 01 movw r14, r24
110: 7f 01 movw r14, r30
112: 82 01 movw r16, r4
114: 85 01 movw r16, r10
116: 88 01 movw r16, r16
118: 8b 01 movw r16, r22
11a: 8e 01 movw r16, r28
11c: 91 01 movw r18, r2
0000011e <port_to_mode_PGM>:
11e: 00 00 00 00 24 00 27 00 2a 00 ....$.'.*.
00000128 <port_to_output_PGM>:
128: 00 00 00 00 25 00 28 00 2b 00 ....%.(.+.
00000132 <port_to_input_PGM>:
132: 00 00 00 00 23 00 26 00 29 00 ....#.&.).
0000013c <digital_pin_to_port_PGM>:
13c: 04 04 04 04 04 04 04 04 02 02 02 02 02 02 03 03 ................
14c: 03 03 03 03 ....
00000150 <digital_pin_to_bit_mask_PGM>:
150: 01 02 04 08 10 20 40 80 01 02 04 08 10 20 01 02 ..... @...... ..
160: 04 08 10 20 ...
00000164 <digital_pin_to_timer_PGM>:
164: 00 00 00 07 00 02 01 00 00 03 04 06 00 00 00 00 ................
174: 00 00 00 00 ....
00000178 <__ctors_start>:
178: ff 04 cpc r15, r15
0000017a <__ctors_end>:
17a: 11 24 eor r1, r1
17c: 1f be out 0x3f, r1 ; 63
17e: cf ef ldi r28, 0xFF ; 255
180: d8 e0 ldi r29, 0x08 ; 8
182: de bf out 0x3e, r29 ; 62
184: cd bf out 0x3d, r28 ; 61
00000186 <__do_copy_data>:
186: 11 e0 ldi r17, 0x01 ; 1
188: a0 e0 ldi r26, 0x00 ; 0
18a: b1 e0 ldi r27, 0x01 ; 1
18c: e2 e7 ldi r30, 0x72 ; 114
18e: fb e0 ldi r31, 0x0B ; 11
190: 02 c0 rjmp .+4 ; 0x196 <.do_copy_data_start>
00000192 <.do_copy_data_loop>:
192: 05 90 lpm r0, Z+
194: 0d 92 st X+, r0
00000196 <.do_copy_data_start>:
196: a0 3e cpi r26, 0xE0 ; 224
198: b1 07 cpc r27, r17
19a: d9 f7 brne .-10 ; 0x192 <.do_copy_data_loop>
0000019c <__do_clear_bss>:
19c: 12 e0 ldi r17, 0x02 ; 2
19e: a0 ee ldi r26, 0xE0 ; 224
1a0: b1 e0 ldi r27, 0x01 ; 1
1a2: 01 c0 rjmp .+2 ; 0x1a6 <.do_clear_bss_start>
000001a4 <.do_clear_bss_loop>:
1a4: 1d 92 st X+, r1
000001a6 <.do_clear_bss_start>:
1a6: a3 39 cpi r26, 0x93 ; 147
1a8: b1 07 cpc r27, r17
1aa: e1 f7 brne .-8 ; 0x1a4 <.do_clear_bss_loop>
000001ac <__do_global_ctors>:
1ac: 11 e0 ldi r17, 0x01 ; 1
1ae: ca e7 ldi r28, 0x7A ; 122
1b0: d1 e0 ldi r29, 0x01 ; 1
1b2: 04 c0 rjmp .+8 ; 0x1bc <.do_global_ctors_start>
000001b4 <.do_global_ctors_loop>:
1b4: 22 97 sbiw r28, 0x02 ; 2
1b6: fe 01 movw r30, r28
1b8: 0e 94 b3 05 call 0xb66 ; 0xb66 <__tablejump__>
000001bc <.do_global_ctors_start>:
1bc: c8 37 cpi r28, 0x78 ; 120
1be: d1 07 cpc r29, r17
1c0: c9 f7 brne .-14 ; 0x1b4 <.do_global_ctors_loop>
1c2: 0e 94 55 05 call 0xaaa ; 0xaaa <main>
1c6: 0c 94 b7 05 jmp 0xb6e ; 0xb6e <_exit>
000001ca <__bad_interrupt>:
1ca: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
000001ce <loop>:
1ce: 08 95 ret
000001d0 <_Z10writeMorsePc>:
1d0: cf 93 push r28
1d2: df 93 push r29
1d4: ec 01 movw r28, r24
1d6: 88 81 ld r24, Y
1d8: 88 23 and r24, r24
1da: f1 f1 breq .+124 ; 0x258 <_Z10writeMorsePc+0x88>
1dc: 8e 32 cpi r24, 0x2E ; 46
1de: 51 f4 brne .+20 ; 0x1f4 <_Z10writeMorsePc+0x24>
1e0: 80 91 ce 01 lds r24, 0x01CE
1e4: 61 e0 ldi r22, 0x01 ; 1
1e6: 0e 94 f1 02 call 0x5e2 ; 0x5e2 <digitalWrite>
1ea: 64 e6 ldi r22, 0x64 ; 100
1ec: 70 e0 ldi r23, 0x00 ; 0
1ee: 80 e0 ldi r24, 0x00 ; 0
1f0: 90 e0 ldi r25, 0x00 ; 0
1f2: 0b c0 rjmp .+22 ; 0x20a <_Z10writeMorsePc+0x3a>
1f4: 8d 32 cpi r24, 0x2D ; 45
1f6: a9 f4 brne .+42 ; 0x222 <_Z10writeMorsePc+0x52>
1f8: 80 91 ce 01 lds r24, 0x01CE
1fc: 61 e0 ldi r22, 0x01 ; 1
1fe: 0e 94 f1 02 call 0x5e2 ; 0x5e2 <digitalWrite>
202: 68 ec ldi r22, 0xC8 ; 200
204: 70 e0 ldi r23, 0x00 ; 0
206: 80 e0 ldi r24, 0x00 ; 0
208: 90 e0 ldi r25, 0x00 ; 0
20a: 0e 94 4a 02 call 0x494 ; 0x494 <delay>
20e: 80 91 ce 01 lds r24, 0x01CE
212: 60 e0 ldi r22, 0x00 ; 0
214: 0e 94 f1 02 call 0x5e2 ; 0x5e2 <digitalWrite>
218: 64 e6 ldi r22, 0x64 ; 100
21a: 70 e0 ldi r23, 0x00 ; 0
21c: 80 e0 ldi r24, 0x00 ; 0
21e: 90 e0 ldi r25, 0x00 ; 0
220: 17 c0 rjmp .+46 ; 0x250 <_Z10writeMorsePc+0x80>
222: 80 32 cpi r24, 0x20 ; 32
224: 51 f4 brne .+20 ; 0x23a <_Z10writeMorsePc+0x6a>
226: 80 91 ce 01 lds r24, 0x01CE
22a: 60 e0 ldi r22, 0x00 ; 0
22c: 0e 94 f1 02 call 0x5e2 ; 0x5e2 <digitalWrite>
230: 68 ec ldi r22, 0xC8 ; 200
232: 70 e0 ldi r23, 0x00 ; 0
234: 80 e0 ldi r24, 0x00 ; 0
236: 90 e0 ldi r25, 0x00 ; 0
238: 0b c0 rjmp .+22 ; 0x250 <_Z10writeMorsePc+0x80>
23a: 8f 32 cpi r24, 0x2F ; 47
23c: 59 f4 brne .+22 ; 0x254 <_Z10writeMorsePc+0x84>
23e: 80 91 ce 01 lds r24, 0x01CE
242: 60 e0 ldi r22, 0x00 ; 0
244: 0e 94 f1 02 call 0x5e2 ; 0x5e2 <digitalWrite>
248: 6c eb ldi r22, 0xBC ; 188
24a: 72 e0 ldi r23, 0x02 ; 2
24c: 80 e0 ldi r24, 0x00 ; 0
24e: 90 e0 ldi r25, 0x00 ; 0
250: 0e 94 4a 02 call 0x494 ; 0x494 <delay>
254: 21 96 adiw r28, 0x01 ; 1
256: bf cf rjmp .-130 ; 0x1d6 <_Z10writeMorsePc+0x6>
258: df 91 pop r29
25a: cf 91 pop r28
25c: 08 95 ret
0000025e <_Z11serialEventv>:
25e: 81 e7 ldi r24, 0x71 ; 113
260: 92 e0 ldi r25, 0x02 ; 2
262: 0e 94 86 04 call 0x90c ; 0x90c <_ZN14HardwareSerial4readEv>
266: 99 27 eor r25, r25
268: 87 fd sbrc r24, 7
26a: 90 95 com r25
26c: a9 2f mov r26, r25
26e: b9 2f mov r27, r25
270: fc 01 movw r30, r24
272: b0 97 sbiw r30, 0x20 ; 32
274: eb 35 cpi r30, 0x5B ; 91
276: f1 05 cpc r31, r1
278: 08 f0 brcs .+2 ; 0x27c <_Z11serialEventv+0x1e>
27a: 7a c0 rjmp .+244 ; 0x370 <_Z11serialEventv+0x112>
27c: ec 5c subi r30, 0xCC ; 204
27e: ff 4f sbci r31, 0xFF ; 255
280: ee 0f add r30, r30
282: ff 1f adc r31, r31
284: 05 90 lpm r0, Z+
286: f4 91 lpm r31, Z+
288: e0 2d mov r30, r0
28a: 09 94 ijmp
28c: 80 e0 ldi r24, 0x00 ; 0
28e: 91 e0 ldi r25, 0x01 ; 1
290: 68 c0 rjmp .+208 ; 0x362 <_Z11serialEventv+0x104>
292: 84 e0 ldi r24, 0x04 ; 4
294: 91 e0 ldi r25, 0x01 ; 1
296: 65 c0 rjmp .+202 ; 0x362 <_Z11serialEventv+0x104>
298: 8a e0 ldi r24, 0x0A ; 10
29a: 91 e0 ldi r25, 0x01 ; 1
29c: 62 c0 rjmp .+196 ; 0x362 <_Z11serialEventv+0x104>
29e: 80 e1 ldi r24, 0x10 ; 16
2a0: 91 e0 ldi r25, 0x01 ; 1
2a2: 5f c0 rjmp .+190 ; 0x362 <_Z11serialEventv+0x104>
2a4: 85 e1 ldi r24, 0x15 ; 21
2a6: 91 e0 ldi r25, 0x01 ; 1
2a8: 5c c0 rjmp .+184 ; 0x362 <_Z11serialEventv+0x104>
2aa: 88 e1 ldi r24, 0x18 ; 24
2ac: 91 e0 ldi r25, 0x01 ; 1
2ae: 59 c0 rjmp .+178 ; 0x362 <_Z11serialEventv+0x104>
2b0: 8e e1 ldi r24, 0x1E ; 30
2b2: 91 e0 ldi r25, 0x01 ; 1
2b4: 56 c0 rjmp .+172 ; 0x362 <_Z11serialEventv+0x104>
2b6: 83 e2 ldi r24, 0x23 ; 35
2b8: 91 e0 ldi r25, 0x01 ; 1
2ba: 53 c0 rjmp .+166 ; 0x362 <_Z11serialEventv+0x104>
2bc: 89 e2 ldi r24, 0x29 ; 41
2be: 91 e0 ldi r25, 0x01 ; 1
2c0: 50 c0 rjmp .+160 ; 0x362 <_Z11serialEventv+0x104>
2c2: 8d e2 ldi r24, 0x2D ; 45
2c4: 91 e0 ldi r25, 0x01 ; 1
2c6: 4d c0 rjmp .+154 ; 0x362 <_Z11serialEventv+0x104>
2c8: 83 e3 ldi r24, 0x33 ; 51
2ca: 91 e0 ldi r25, 0x01 ; 1
2cc: 4a c0 rjmp .+148 ; 0x362 <_Z11serialEventv+0x104>
2ce: 88 e3 ldi r24, 0x38 ; 56
2d0: 91 e0 ldi r25, 0x01 ; 1
2d2: 47 c0 rjmp .+142 ; 0x362 <_Z11serialEventv+0x104>
2d4: 8e e3 ldi r24, 0x3E ; 62
2d6: 91 e0 ldi r25, 0x01 ; 1
2d8: 44 c0 rjmp .+136 ; 0x362 <_Z11serialEventv+0x104>
2da: 82 e4 ldi r24, 0x42 ; 66
2dc: 91 e0 ldi r25, 0x01 ; 1
2de: 41 c0 rjmp .+130 ; 0x362 <_Z11serialEventv+0x104>
2e0: 86 e4 ldi r24, 0x46 ; 70
2e2: 91 e0 ldi r25, 0x01 ; 1
2e4: 3e c0 rjmp .+124 ; 0x362 <_Z11serialEventv+0x104>
2e6: 8b e4 ldi r24, 0x4B ; 75
2e8: 91 e0 ldi r25, 0x01 ; 1
2ea: 3b c0 rjmp .+118 ; 0x362 <_Z11serialEventv+0x104>
2ec: 81 e5 ldi r24, 0x51 ; 81
2ee: 91 e0 ldi r25, 0x01 ; 1
2f0: 38 c0 rjmp .+112 ; 0x362 <_Z11serialEventv+0x104>
2f2: 87 e5 ldi r24, 0x57 ; 87
2f4: 91 e0 ldi r25, 0x01 ; 1
2f6: 35 c0 rjmp .+106 ; 0x362 <_Z11serialEventv+0x104>
2f8: 8c e5 ldi r24, 0x5C ; 92
2fa: 91 e0 ldi r25, 0x01 ; 1
2fc: 32 c0 rjmp .+100 ; 0x362 <_Z11serialEventv+0x104>
2fe: 81 e6 ldi r24, 0x61 ; 97
300: 91 e0 ldi r25, 0x01 ; 1
302: 2f c0 rjmp .+94 ; 0x362 <_Z11serialEventv+0x104>
304: 84 e6 ldi r24, 0x64 ; 100
306: 91 e0 ldi r25, 0x01 ; 1
308: 2c c0 rjmp .+88 ; 0x362 <_Z11serialEventv+0x104>
30a: 89 e6 ldi r24, 0x69 ; 105
30c: 91 e0 ldi r25, 0x01 ; 1
30e: 29 c0 rjmp .+82 ; 0x362 <_Z11serialEventv+0x104>
310: 8f e6 ldi r24, 0x6F ; 111
312: 91 e0 ldi r25, 0x01 ; 1
314: 26 c0 rjmp .+76 ; 0x362 <_Z11serialEventv+0x104>
316: 84 e7 ldi r24, 0x74 ; 116
318: 91 e0 ldi r25, 0x01 ; 1
31a: 23 c0 rjmp .+70 ; 0x362 <_Z11serialEventv+0x104>
31c: 8a e7 ldi r24, 0x7A ; 122
31e: 91 e0 ldi r25, 0x01 ; 1
320: 20 c0 rjmp .+64 ; 0x362 <_Z11serialEventv+0x104>
322: 80 e8 ldi r24, 0x80 ; 128
324: 91 e0 ldi r25, 0x01 ; 1
326: 1d c0 rjmp .+58 ; 0x362 <_Z11serialEventv+0x104>
328: 86 e8 ldi r24, 0x86 ; 134
32a: 91 e0 ldi r25, 0x01 ; 1
32c: 1a c0 rjmp .+52 ; 0x362 <_Z11serialEventv+0x104>
32e: 88 e8 ldi r24, 0x88 ; 136
330: 91 e0 ldi r25, 0x01 ; 1
332: 17 c0 rjmp .+46 ; 0x362 <_Z11serialEventv+0x104>
334: 8f e8 ldi r24, 0x8F ; 143
336: 91 e0 ldi r25, 0x01 ; 1
338: 14 c0 rjmp .+40 ; 0x362 <_Z11serialEventv+0x104>
33a: 86 e9 ldi r24, 0x96 ; 150
33c: 91 e0 ldi r25, 0x01 ; 1
33e: 11 c0 rjmp .+34 ; 0x362 <_Z11serialEventv+0x104>
340: 8d e9 ldi r24, 0x9D ; 157
342: 91 e0 ldi r25, 0x01 ; 1
344: 0e c0 rjmp .+28 ; 0x362 <_Z11serialEventv+0x104>
346: 84 ea ldi r24, 0xA4 ; 164
348: 91 e0 ldi r25, 0x01 ; 1
34a: 0b c0 rjmp .+22 ; 0x362 <_Z11serialEventv+0x104>
34c: 8b ea ldi r24, 0xAB ; 171
34e: 91 e0 ldi r25, 0x01 ; 1
350: 08 c0 rjmp .+16 ; 0x362 <_Z11serialEventv+0x104>
352: 82 eb ldi r24, 0xB2 ; 178
354: 91 e0 ldi r25, 0x01 ; 1
356: 05 c0 rjmp .+10 ; 0x362 <_Z11serialEventv+0x104>
358: 89 eb ldi r24, 0xB9 ; 185
35a: 91 e0 ldi r25, 0x01 ; 1
35c: 02 c0 rjmp .+4 ; 0x362 <_Z11serialEventv+0x104>
35e: 80 ec ldi r24, 0xC0 ; 192
360: 91 e0 ldi r25, 0x01 ; 1
362: 0e 94 e8 00 call 0x1d0 ; 0x1d0 <_Z10writeMorsePc>
366: 08 95 ret
368: 87 ec ldi r24, 0xC7 ; 199
36a: 91 e0 ldi r25, 0x01 ; 1
36c: 0e 94 e8 00 call 0x1d0 ; 0x1d0 <_Z10writeMorsePc>
370: 08 95 ret
00000372 <setup>:
372: 80 91 ce 01 lds r24, 0x01CE
376: 61 e0 ldi r22, 0x01 ; 1
378: 0e 94 b2 02 call 0x564 ; 0x564 <pinMode>
37c: 81 e7 ldi r24, 0x71 ; 113
37e: 92 e0 ldi r25, 0x02 ; 2
380: 40 e8 ldi r20, 0x80 ; 128
382: 55 e2 ldi r21, 0x25 ; 37
384: 60 e0 ldi r22, 0x00 ; 0
386: 70 e0 ldi r23, 0x00 ; 0
388: 0e 94 ce 03 call 0x79c ; 0x79c <_ZN14HardwareSerial5beginEm>
38c: 08 95 ret
0000038e <__vector_16>:
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
SIGNAL(TIM0_OVF_vect)
#else
SIGNAL(TIMER0_OVF_vect)
#endif
{
38e: 1f 92 push r1
390: 0f 92 push r0
392: 0f b6 in r0, 0x3f ; 63
394: 0f 92 push r0
396: 11 24 eor r1, r1
398: 2f 93 push r18
39a: 3f 93 push r19
39c: 8f 93 push r24
39e: 9f 93 push r25
3a0: af 93 push r26
3a2: bf 93 push r27
// copy these to local variables so they can be stored in registers
// (volatile variables must be read from memory on every access)
unsigned long m = timer0_millis;
3a4: 80 91 e4 01 lds r24, 0x01E4
3a8: 90 91 e5 01 lds r25, 0x01E5
3ac: a0 91 e6 01 lds r26, 0x01E6
3b0: b0 91 e7 01 lds r27, 0x01E7
unsigned char f = timer0_fract;
3b4: 30 91 e8 01 lds r19, 0x01E8
m += MILLIS_INC;
3b8: 01 96 adiw r24, 0x01 ; 1
3ba: a1 1d adc r26, r1
3bc: b1 1d adc r27, r1
f += FRACT_INC;
3be: 23 2f mov r18, r19
3c0: 2d 5f subi r18, 0xFD ; 253
if (f >= FRACT_MAX) {
3c2: 2d 37 cpi r18, 0x7D ; 125
3c4: 20 f0 brcs .+8 ; 0x3ce <__vector_16+0x40>
f -= FRACT_MAX;
3c6: 2d 57 subi r18, 0x7D ; 125
m += 1;
3c8: 01 96 adiw r24, 0x01 ; 1
3ca: a1 1d adc r26, r1
3cc: b1 1d adc r27, r1
}
timer0_fract = f;
3ce: 20 93 e8 01 sts 0x01E8, r18
timer0_millis = m;
3d2: 80 93 e4 01 sts 0x01E4, r24
3d6: 90 93 e5 01 sts 0x01E5, r25
3da: a0 93 e6 01 sts 0x01E6, r26
3de: b0 93 e7 01 sts 0x01E7, r27
timer0_overflow_count++;
3e2: 80 91 e0 01 lds r24, 0x01E0
3e6: 90 91 e1 01 lds r25, 0x01E1
3ea: a0 91 e2 01 lds r26, 0x01E2
3ee: b0 91 e3 01 lds r27, 0x01E3
3f2: 01 96 adiw r24, 0x01 ; 1
3f4: a1 1d adc r26, r1
3f6: b1 1d adc r27, r1
3f8: 80 93 e0 01 sts 0x01E0, r24
3fc: 90 93 e1 01 sts 0x01E1, r25
400: a0 93 e2 01 sts 0x01E2, r26
404: b0 93 e3 01 sts 0x01E3, r27
}
408: bf 91 pop r27
40a: af 91 pop r26
40c: 9f 91 pop r25
40e: 8f 91 pop r24
410: 3f 91 pop r19
412: 2f 91 pop r18
414: 0f 90 pop r0
416: 0f be out 0x3f, r0 ; 63
418: 0f 90 pop r0
41a: 1f 90 pop r1
41c: 18 95 reti
0000041e <init>:
void init()
{
// this needs to be called before setup() or some functions won't
// work there
sei();
41e: 78 94 sei
// on the ATmega168, timer 0 is also used for fast hardware pwm
// (using phase-correct PWM would mean that timer 0 overflowed half as often
// resulting in different millis() behavior on the ATmega8 and ATmega168)
#if defined(TCCR0A) && defined(WGM01)
sbi(TCCR0A, WGM01);
420: 84 b5 in r24, 0x24 ; 36
422: 82 60 ori r24, 0x02 ; 2
424: 84 bd out 0x24, r24 ; 36
sbi(TCCR0A, WGM00);
426: 84 b5 in r24, 0x24 ; 36
428: 81 60 ori r24, 0x01 ; 1
42a: 84 bd out 0x24, r24 ; 36
// this combination is for the standard atmega8
sbi(TCCR0, CS01);
sbi(TCCR0, CS00);
#elif defined(TCCR0B) && defined(CS01) && defined(CS00)
// this combination is for the standard 168/328/1280/2560
sbi(TCCR0B, CS01);
42c: 85 b5 in r24, 0x25 ; 37
42e: 82 60 ori r24, 0x02 ; 2
430: 85 bd out 0x25, r24 ; 37
sbi(TCCR0B, CS00);
432: 85 b5 in r24, 0x25 ; 37
434: 81 60 ori r24, 0x01 ; 1
436: 85 bd out 0x25, r24 ; 37
// enable timer 0 overflow interrupt
#if defined(TIMSK) && defined(TOIE0)
sbi(TIMSK, TOIE0);
#elif defined(TIMSK0) && defined(TOIE0)
sbi(TIMSK0, TOIE0);
438: ee e6 ldi r30, 0x6E ; 110
43a: f0 e0 ldi r31, 0x00 ; 0
43c: 80 81 ld r24, Z
43e: 81 60 ori r24, 0x01 ; 1
440: 80 83 st Z, r24
// this is better for motors as it ensures an even waveform
// note, however, that fast pwm mode can achieve a frequency of up
// 8 MHz (with a 16 MHz clock) at 50% duty cycle
#if defined(TCCR1B) && defined(CS11) && defined(CS10)
TCCR1B = 0;
442: e1 e8 ldi r30, 0x81 ; 129
444: f0 e0 ldi r31, 0x00 ; 0
446: 10 82 st Z, r1
// set timer 1 prescale factor to 64
sbi(TCCR1B, CS11);
448: 80 81 ld r24, Z
44a: 82 60 ori r24, 0x02 ; 2
44c: 80 83 st Z, r24
#if F_CPU >= 8000000L
sbi(TCCR1B, CS10);
44e: 80 81 ld r24, Z
450: 81 60 ori r24, 0x01 ; 1
452: 80 83 st Z, r24
sbi(TCCR1, CS10);
#endif
#endif
// put timer 1 in 8-bit phase correct pwm mode
#if defined(TCCR1A) && defined(WGM10)
sbi(TCCR1A, WGM10);
454: e0 e8 ldi r30, 0x80 ; 128
456: f0 e0 ldi r31, 0x00 ; 0
458: 80 81 ld r24, Z
45a: 81 60 ori r24, 0x01 ; 1
45c: 80 83 st Z, r24
// set timer 2 prescale factor to 64
#if defined(TCCR2) && defined(CS22)
sbi(TCCR2, CS22);
#elif defined(TCCR2B) && defined(CS22)
sbi(TCCR2B, CS22);
45e: e1 eb ldi r30, 0xB1 ; 177
460: f0 e0 ldi r31, 0x00 ; 0
462: 80 81 ld r24, Z
464: 84 60 ori r24, 0x04 ; 4
466: 80 83 st Z, r24
// configure timer 2 for phase correct pwm (8-bit)
#if defined(TCCR2) && defined(WGM20)
sbi(TCCR2, WGM20);
#elif defined(TCCR2A) && defined(WGM20)
sbi(TCCR2A, WGM20);
468: e0 eb ldi r30, 0xB0 ; 176
46a: f0 e0 ldi r31, 0x00 ; 0
46c: 80 81 ld r24, Z
46e: 81 60 ori r24, 0x01 ; 1
470: 80 83 st Z, r24
#if defined(ADCSRA)
// set a2d prescale factor to 128
// 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
// XXX: this will not work properly for other clock speeds, and
// this code should use F_CPU to determine the prescale factor.
sbi(ADCSRA, ADPS2);
472: ea e7 ldi r30, 0x7A ; 122
474: f0 e0 ldi r31, 0x00 ; 0
476: 80 81 ld r24, Z
478: 84 60 ori r24, 0x04 ; 4
47a: 80 83 st Z, r24
sbi(ADCSRA, ADPS1);
47c: 80 81 ld r24, Z
47e: 82 60 ori r24, 0x02 ; 2
480: 80 83 st Z, r24
sbi(ADCSRA, ADPS0);
482: 80 81 ld r24, Z
484: 81 60 ori r24, 0x01 ; 1
486: 80 83 st Z, r24
// enable a2d conversions
sbi(ADCSRA, ADEN);
488: 80 81 ld r24, Z
48a: 80 68 ori r24, 0x80 ; 128
48c: 80 83 st Z, r24
// here so they can be used as normal digital i/o; they will be
// reconnected in Serial.begin()
#if defined(UCSRB)
UCSRB = 0;
#elif defined(UCSR0B)
UCSR0B = 0;
48e: 10 92 c1 00 sts 0x00C1, r1
#endif
}
492: 08 95 ret
00000494 <delay>:
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}
void delay(unsigned long ms)
{
494: ef 92 push r14
496: ff 92 push r15
498: 0f 93 push r16
49a: 1f 93 push r17
49c: cf 93 push r28
49e: df 93 push r29
4a0: 7b 01 movw r14, r22
4a2: 8c 01 movw r16, r24
return m;
}
unsigned long micros() {
unsigned long m;
uint8_t oldSREG = SREG, t;
4a4: 3f b7 in r19, 0x3f ; 63
cli();
4a6: f8 94 cli
m = timer0_overflow_count;
4a8: 80 91 e0 01 lds r24, 0x01E0
4ac: 90 91 e1 01 lds r25, 0x01E1
4b0: a0 91 e2 01 lds r26, 0x01E2
4b4: b0 91 e3 01 lds r27, 0x01E3
#if defined(TCNT0)
t = TCNT0;
4b8: 26 b5 in r18, 0x26 ; 38
#error TIMER 0 not defined
#endif
#ifdef TIFR0
if ((TIFR0 & _BV(TOV0)) && (t < 255))
4ba: a8 9b sbis 0x15, 0 ; 21
4bc: 05 c0 rjmp .+10 ; 0x4c8 <delay+0x34>
4be: 2f 3f cpi r18, 0xFF ; 255
4c0: 19 f0 breq .+6 ; 0x4c8 <delay+0x34>
m++;
4c2: 01 96 adiw r24, 0x01 ; 1
4c4: a1 1d adc r26, r1
4c6: b1 1d adc r27, r1
#else
if ((TIFR & _BV(TOV0)) && (t < 255))
m++;
#endif
SREG = oldSREG;
4c8: 3f bf out 0x3f, r19 ; 63
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}
void delay(unsigned long ms)
{
uint16_t start = (uint16_t)micros();
4ca: ba 2f mov r27, r26
4cc: a9 2f mov r26, r25
4ce: 98 2f mov r25, r24
4d0: 88 27 eor r24, r24
4d2: 82 0f add r24, r18
4d4: 91 1d adc r25, r1
4d6: a1 1d adc r26, r1
4d8: b1 1d adc r27, r1
4da: 52 e0 ldi r21, 0x02 ; 2
4dc: 88 0f add r24, r24
4de: 99 1f adc r25, r25
4e0: aa 1f adc r26, r26
4e2: bb 1f adc r27, r27
4e4: 5a 95 dec r21
4e6: d1 f7 brne .-12 ; 0x4dc <delay+0x48>
4e8: ec 01 movw r28, r24
4ea: 30 c0 rjmp .+96 ; 0x54c <delay+0xb8>
while (ms > 0) {
yield();
4ec: 0e 94 8e 05 call 0xb1c ; 0xb1c <yield>
return m;
}
unsigned long micros() {
unsigned long m;
uint8_t oldSREG = SREG, t;
4f0: 3f b7 in r19, 0x3f ; 63
cli();
4f2: f8 94 cli
m = timer0_overflow_count;
4f4: 80 91 e0 01 lds r24, 0x01E0
4f8: 90 91 e1 01 lds r25, 0x01E1
4fc: a0 91 e2 01 lds r26, 0x01E2
500: b0 91 e3 01 lds r27, 0x01E3
#if defined(TCNT0)
t = TCNT0;
504: 26 b5 in r18, 0x26 ; 38
#error TIMER 0 not defined
#endif
#ifdef TIFR0
if ((TIFR0 & _BV(TOV0)) && (t < 255))
506: a8 9b sbis 0x15, 0 ; 21
508: 05 c0 rjmp .+10 ; 0x514 <delay+0x80>
50a: 2f 3f cpi r18, 0xFF ; 255
50c: 19 f0 breq .+6 ; 0x514 <delay+0x80>
m++;
50e: 01 96 adiw r24, 0x01 ; 1
510: a1 1d adc r26, r1
512: b1 1d adc r27, r1
#else
if ((TIFR & _BV(TOV0)) && (t < 255))
m++;
#endif
SREG = oldSREG;
514: 3f bf out 0x3f, r19 ; 63
{
uint16_t start = (uint16_t)micros();
while (ms > 0) {
yield();
if (((uint16_t)micros() - start) >= 1000) {
516: ba 2f mov r27, r26
518: a9 2f mov r26, r25
51a: 98 2f mov r25, r24
51c: 88 27 eor r24, r24
51e: 82 0f add r24, r18
520: 91 1d adc r25, r1
522: a1 1d adc r26, r1
524: b1 1d adc r27, r1
526: 32 e0 ldi r19, 0x02 ; 2
528: 88 0f add r24, r24
52a: 99 1f adc r25, r25
52c: aa 1f adc r26, r26
52e: bb 1f adc r27, r27
530: 3a 95 dec r19
532: d1 f7 brne .-12 ; 0x528 <delay+0x94>
534: 8c 1b sub r24, r28
536: 9d 0b sbc r25, r29
538: 88 5e subi r24, 0xE8 ; 232
53a: 93 40 sbci r25, 0x03 ; 3
53c: b8 f2 brcs .-82 ; 0x4ec <delay+0x58>
ms--;
53e: 08 94 sec
540: e1 08 sbc r14, r1
542: f1 08 sbc r15, r1
544: 01 09 sbc r16, r1
546: 11 09 sbc r17, r1
start += 1000;
548: c8 51 subi r28, 0x18 ; 24
54a: dc 4f sbci r29, 0xFC ; 252
void delay(unsigned long ms)
{
uint16_t start = (uint16_t)micros();
while (ms > 0) {
54c: e1 14 cp r14, r1
54e: f1 04 cpc r15, r1
550: 01 05 cpc r16, r1
552: 11 05 cpc r17, r1
554: 59 f6 brne .-106 ; 0x4ec <delay+0x58>
if (((uint16_t)micros() - start) >= 1000) {
ms--;
start += 1000;
}
}
}
556: df 91 pop r29
558: cf 91 pop r28
55a: 1f 91 pop r17
55c: 0f 91 pop r16
55e: ff 90 pop r15
560: ef 90 pop r14
562: 08 95 ret
00000564 <pinMode>:
#define ARDUINO_MAIN
#include "wiring_private.h"
#include "pins_arduino.h"
void pinMode(uint8_t pin, uint8_t mode)
{
564: cf 93 push r28
566: df 93 push r29
uint8_t bit = digitalPinToBitMask(pin);
568: 48 2f mov r20, r24
56a: 50 e0 ldi r21, 0x00 ; 0
56c: ca 01 movw r24, r20
56e: 80 5b subi r24, 0xB0 ; 176
570: 9e 4f sbci r25, 0xFE ; 254
572: fc 01 movw r30, r24
574: 34 91 lpm r19, Z+
uint8_t port = digitalPinToPort(pin);
576: 44 5c subi r20, 0xC4 ; 196
578: 5e 4f sbci r21, 0xFE ; 254
57a: fa 01 movw r30, r20
57c: 84 91 lpm r24, Z+
volatile uint8_t *reg, *out;
if (port == NOT_A_PIN) return;
57e: 88 23 and r24, r24
580: 69 f1 breq .+90 ; 0x5dc <pinMode+0x78>
// JWS: can I let the optimizer do this?
reg = portModeRegister(port);
582: 90 e0 ldi r25, 0x00 ; 0
584: 88 0f add r24, r24
586: 99 1f adc r25, r25
588: fc 01 movw r30, r24
58a: e2 5e subi r30, 0xE2 ; 226
58c: fe 4f sbci r31, 0xFE ; 254
58e: a5 91 lpm r26, Z+
590: b4 91 lpm r27, Z+
out = portOutputRegister(port);
592: fc 01 movw r30, r24
594: e8 5d subi r30, 0xD8 ; 216
596: fe 4f sbci r31, 0xFE ; 254
598: c5 91 lpm r28, Z+
59a: d4 91 lpm r29, Z+
if (mode == INPUT) {
59c: 66 23 and r22, r22
59e: 51 f4 brne .+20 ; 0x5b4 <pinMode+0x50>
uint8_t oldSREG = SREG;
5a0: 2f b7 in r18, 0x3f ; 63
cli();
5a2: f8 94 cli
*reg &= ~bit;
5a4: 8c 91 ld r24, X
5a6: 93 2f mov r25, r19
5a8: 90 95 com r25
5aa: 89 23 and r24, r25
5ac: 8c 93 st X, r24
*out &= ~bit;
5ae: 88 81 ld r24, Y
5b0: 89 23 and r24, r25
5b2: 0b c0 rjmp .+22 ; 0x5ca <pinMode+0x66>
SREG = oldSREG;
} else if (mode == INPUT_PULLUP) {
5b4: 62 30 cpi r22, 0x02 ; 2
5b6: 61 f4 brne .+24 ; 0x5d0 <pinMode+0x6c>
uint8_t oldSREG = SREG;
5b8: 2f b7 in r18, 0x3f ; 63
cli();
5ba: f8 94 cli
*reg &= ~bit;
5bc: 8c 91 ld r24, X
5be: 93 2f mov r25, r19
5c0: 90 95 com r25
5c2: 89 23 and r24, r25
5c4: 8c 93 st X, r24
*out |= bit;
5c6: 88 81 ld r24, Y
5c8: 83 2b or r24, r19
5ca: 88 83 st Y, r24
SREG = oldSREG;
5cc: 2f bf out 0x3f, r18 ; 63
5ce: 06 c0 rjmp .+12 ; 0x5dc <pinMode+0x78>
} else {
uint8_t oldSREG = SREG;
5d0: 9f b7 in r25, 0x3f ; 63
cli();
5d2: f8 94 cli
*reg |= bit;
5d4: 8c 91 ld r24, X
5d6: 83 2b or r24, r19
5d8: 8c 93 st X, r24
SREG = oldSREG;
5da: 9f bf out 0x3f, r25 ; 63
}
}
5dc: df 91 pop r29
5de: cf 91 pop r28
5e0: 08 95 ret
000005e2 <digitalWrite>:
}
}
void digitalWrite(uint8_t pin, uint8_t val)
{
uint8_t timer = digitalPinToTimer(pin);
5e2: 48 2f mov r20, r24
5e4: 50 e0 ldi r21, 0x00 ; 0
5e6: ca 01 movw r24, r20
5e8: 8c 59 subi r24, 0x9C ; 156
5ea: 9e 4f sbci r25, 0xFE ; 254
5ec: fc 01 movw r30, r24
5ee: 24 91 lpm r18, Z+
uint8_t bit = digitalPinToBitMask(pin);
5f0: ca 01 movw r24, r20
5f2: 80 5b subi r24, 0xB0 ; 176
5f4: 9e 4f sbci r25, 0xFE ; 254
5f6: fc 01 movw r30, r24
5f8: 94 91 lpm r25, Z+
uint8_t port = digitalPinToPort(pin);
5fa: 44 5c subi r20, 0xC4 ; 196
5fc: 5e 4f sbci r21, 0xFE ; 254
5fe: fa 01 movw r30, r20
600: 34 91 lpm r19, Z+
volatile uint8_t *out;
if (port == NOT_A_PIN) return;
602: 33 23 and r19, r19
604: 09 f4 brne .+2 ; 0x608 <digitalWrite+0x26>
606: 40 c0 rjmp .+128 ; 0x688 <digitalWrite+0xa6>
// If the pin that support PWM output, we need to turn it off
// before doing a digital write.
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
608: 22 23 and r18, r18
60a: 51 f1 breq .+84 ; 0x660 <digitalWrite+0x7e>
//
//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline));
//static inline void turnOffPWM(uint8_t timer)
static void turnOffPWM(uint8_t timer)
{
switch (timer)
60c: 23 30 cpi r18, 0x03 ; 3
60e: 71 f0 breq .+28 ; 0x62c <digitalWrite+0x4a>
610: 24 30 cpi r18, 0x04 ; 4
612: 28 f4 brcc .+10 ; 0x61e <digitalWrite+0x3c>
614: 21 30 cpi r18, 0x01 ; 1
616: a1 f0 breq .+40 ; 0x640 <digitalWrite+0x5e>
618: 22 30 cpi r18, 0x02 ; 2
61a: 11 f5 brne .+68 ; 0x660 <digitalWrite+0x7e>
61c: 14 c0 rjmp .+40 ; 0x646 <digitalWrite+0x64>
61e: 26 30 cpi r18, 0x06 ; 6
620: b1 f0 breq .+44 ; 0x64e <digitalWrite+0x6c>
622: 27 30 cpi r18, 0x07 ; 7
624: c1 f0 breq .+48 ; 0x656 <digitalWrite+0x74>
626: 24 30 cpi r18, 0x04 ; 4
628: d9 f4 brne .+54 ; 0x660 <digitalWrite+0x7e>
62a: 04 c0 rjmp .+8 ; 0x634 <digitalWrite+0x52>
{
#if defined(TCCR1A) && defined(COM1A1)
case TIMER1A: cbi(TCCR1A, COM1A1); break;
62c: 80 91 80 00 lds r24, 0x0080
630: 8f 77 andi r24, 0x7F ; 127
632: 03 c0 rjmp .+6 ; 0x63a <digitalWrite+0x58>
#endif
#if defined(TCCR1A) && defined(COM1B1)
case TIMER1B: cbi(TCCR1A, COM1B1); break;
634: 80 91 80 00 lds r24, 0x0080
638: 8f 7d andi r24, 0xDF ; 223
63a: 80 93 80 00 sts 0x0080, r24
63e: 10 c0 rjmp .+32 ; 0x660 <digitalWrite+0x7e>
#if defined(TCCR2) && defined(COM21)
case TIMER2: cbi(TCCR2, COM21); break;
#endif
#if defined(TCCR0A) && defined(COM0A1)
case TIMER0A: cbi(TCCR0A, COM0A1); break;
640: 84 b5 in r24, 0x24 ; 36
642: 8f 77 andi r24, 0x7F ; 127
644: 02 c0 rjmp .+4 ; 0x64a <digitalWrite+0x68>
#endif
#if defined(TIMER0B) && defined(COM0B1)
case TIMER0B: cbi(TCCR0A, COM0B1); break;
646: 84 b5 in r24, 0x24 ; 36
648: 8f 7d andi r24, 0xDF ; 223
64a: 84 bd out 0x24, r24 ; 36
64c: 09 c0 rjmp .+18 ; 0x660 <digitalWrite+0x7e>
#endif
#if defined(TCCR2A) && defined(COM2A1)
case TIMER2A: cbi(TCCR2A, COM2A1); break;
64e: 80 91 b0 00 lds r24, 0x00B0
652: 8f 77 andi r24, 0x7F ; 127
654: 03 c0 rjmp .+6 ; 0x65c <digitalWrite+0x7a>
#endif
#if defined(TCCR2A) && defined(COM2B1)
case TIMER2B: cbi(TCCR2A, COM2B1); break;
656: 80 91 b0 00 lds r24, 0x00B0
65a: 8f 7d andi r24, 0xDF ; 223
65c: 80 93 b0 00 sts 0x00B0, r24
// If the pin that support PWM output, we need to turn it off
// before doing a digital write.
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
out = portOutputRegister(port);
660: e3 2f mov r30, r19
662: f0 e0 ldi r31, 0x00 ; 0
664: ee 0f add r30, r30
666: ff 1f adc r31, r31
668: e8 5d subi r30, 0xD8 ; 216
66a: fe 4f sbci r31, 0xFE ; 254
66c: a5 91 lpm r26, Z+
66e: b4 91 lpm r27, Z+
uint8_t oldSREG = SREG;
670: 2f b7 in r18, 0x3f ; 63
cli();
672: f8 94 cli
if (val == LOW) {
674: 66 23 and r22, r22
676: 21 f4 brne .+8 ; 0x680 <digitalWrite+0x9e>
*out &= ~bit;
678: 8c 91 ld r24, X
67a: 90 95 com r25
67c: 89 23 and r24, r25
67e: 02 c0 rjmp .+4 ; 0x684 <digitalWrite+0xa2>
} else {
*out |= bit;
680: 8c 91 ld r24, X
682: 89 2b or r24, r25
684: 8c 93 st X, r24
}
SREG = oldSREG;
686: 2f bf out 0x3f, r18 ; 63
688: 08 95 ret
0000068a <__vector_18>:
#define serialEvent_implemented
#if defined(USART_RX_vect)
SIGNAL(USART_RX_vect)
68a: 1f 92 push r1
68c: 0f 92 push r0
68e: 0f b6 in r0, 0x3f ; 63
690: 0f 92 push r0
692: 11 24 eor r1, r1
694: 2f 93 push r18
696: 3f 93 push r19
698: 4f 93 push r20
69a: 8f 93 push r24
69c: 9f 93 push r25
69e: ef 93 push r30
6a0: ff 93 push r31
#elif defined(SIG_UART_RECV)
SIGNAL(SIG_UART_RECV)
#endif
{
#if defined(UDR0)
if (bit_is_clear(UCSR0A, UPE0)) {
6a2: 80 91 c0 00 lds r24, 0x00C0
6a6: 82 fd sbrc r24, 2
6a8: 1d c0 rjmp .+58 ; 0x6e4 <__vector_18+0x5a>
unsigned char c = UDR0;
6aa: 40 91 c6 00 lds r20, 0x00C6
ring_buffer tx_buffer3 = { { 0 }, 0, 0 };
#endif
inline void store_char(unsigned char c, ring_buffer *buffer)
{
int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
6ae: 20 91 29 02 lds r18, 0x0229
6b2: 30 91 2a 02 lds r19, 0x022A
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != buffer->tail) {
6b6: 2f 5f subi r18, 0xFF ; 255
6b8: 3f 4f sbci r19, 0xFF ; 255
6ba: 2f 73 andi r18, 0x3F ; 63
6bc: 30 70 andi r19, 0x00 ; 0
6be: 80 91 2b 02 lds r24, 0x022B
6c2: 90 91 2c 02 lds r25, 0x022C
6c6: 28 17 cp r18, r24
6c8: 39 07 cpc r19, r25
6ca: 71 f0 breq .+28 ; 0x6e8 <__vector_18+0x5e>
buffer->buffer[buffer->head] = c;
6cc: e0 91 29 02 lds r30, 0x0229
6d0: f0 91 2a 02 lds r31, 0x022A
6d4: e7 51 subi r30, 0x17 ; 23
6d6: fe 4f sbci r31, 0xFE ; 254
6d8: 40 83 st Z, r20
buffer->head = i;
6da: 30 93 2a 02 sts 0x022A, r19
6de: 20 93 29 02 sts 0x0229, r18
6e2: 02 c0 rjmp .+4 ; 0x6e8 <__vector_18+0x5e>
#if defined(UDR0)
if (bit_is_clear(UCSR0A, UPE0)) {
unsigned char c = UDR0;
store_char(c, &rx_buffer);
} else {
unsigned char c = UDR0;
6e4: 80 91 c6 00 lds r24, 0x00C6
unsigned char c = UDR;
};
#else
#error UDR not defined
#endif
}
6e8: ff 91 pop r31
6ea: ef 91 pop r30
6ec: 9f 91 pop r25
6ee: 8f 91 pop r24
6f0: 4f 91 pop r20
6f2: 3f 91 pop r19
6f4: 2f 91 pop r18
6f6: 0f 90 pop r0
6f8: 0f be out 0x3f, r0 ; 63
6fa: 0f 90 pop r0
6fc: 1f 90 pop r1
6fe: 18 95 reti
00000700 <_Z14serialEventRunv>:
_rx_buffer->head = _rx_buffer->tail;
}
int HardwareSerial::available(void)
{
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
700: e0 91 7d 02 lds r30, 0x027D
704: f0 91 7e 02 lds r31, 0x027E
708: e0 5c subi r30, 0xC0 ; 192
70a: ff 4f sbci r31, 0xFF ; 255
70c: 81 91 ld r24, Z+
70e: 91 91 ld r25, Z+
710: 20 81 ld r18, Z
712: 31 81 ldd r19, Z+1 ; 0x01
#endif
void serialEventRun(void)
{
#ifdef serialEvent_implemented
if (Serial.available()) serialEvent();
714: 82 1b sub r24, r18
716: 93 0b sbc r25, r19
718: 8f 73 andi r24, 0x3F ; 63
71a: 90 70 andi r25, 0x00 ; 0
71c: 89 2b or r24, r25
71e: 11 f0 breq .+4 ; 0x724 <_Z14serialEventRunv+0x24>
720: 0e 94 2f 01 call 0x25e ; 0x25e <_Z11serialEventv>
724: 08 95 ret
00000726 <__vector_19>:
#elif defined(UART_UDRE_vect)
ISR(UART_UDRE_vect)
#elif defined(USART0_UDRE_vect)
ISR(USART0_UDRE_vect)
#elif defined(USART_UDRE_vect)
ISR(USART_UDRE_vect)
726: 1f 92 push r1
728: 0f 92 push r0
72a: 0f b6 in r0, 0x3f ; 63
72c: 0f 92 push r0
72e: 11 24 eor r1, r1
730: 2f 93 push r18
732: 3f 93 push r19
734: 8f 93 push r24
736: 9f 93 push r25
738: ef 93 push r30
73a: ff 93 push r31
#endif
{
if (tx_buffer.head == tx_buffer.tail) {
73c: 20 91 6d 02 lds r18, 0x026D
740: 30 91 6e 02 lds r19, 0x026E
744: 80 91 6f 02 lds r24, 0x026F
748: 90 91 70 02 lds r25, 0x0270
74c: 28 17 cp r18, r24
74e: 39 07 cpc r19, r25
750: 31 f4 brne .+12 ; 0x75e <__vector_19+0x38>
// Buffer empty, so disable interrupts
#if defined(UCSR0B)
cbi(UCSR0B, UDRIE0);
752: 80 91 c1 00 lds r24, 0x00C1
756: 8f 7d andi r24, 0xDF ; 223
758: 80 93 c1 00 sts 0x00C1, r24
75c: 14 c0 rjmp .+40 ; 0x786 <__vector_19+0x60>
cbi(UCSRB, UDRIE);
#endif
}
else {
// There is more data in the output buffer. Send the next byte
unsigned char c = tx_buffer.buffer[tx_buffer.tail];
75e: e0 91 6f 02 lds r30, 0x026F
762: f0 91 70 02 lds r31, 0x0270
766: e3 5d subi r30, 0xD3 ; 211
768: fd 4f sbci r31, 0xFD ; 253
76a: 20 81 ld r18, Z
tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE;
76c: 80 91 6f 02 lds r24, 0x026F
770: 90 91 70 02 lds r25, 0x0270
774: 01 96 adiw r24, 0x01 ; 1
776: 8f 73 andi r24, 0x3F ; 63
778: 90 70 andi r25, 0x00 ; 0
77a: 90 93 70 02 sts 0x0270, r25
77e: 80 93 6f 02 sts 0x026F, r24
#if defined(UDR0)
UDR0 = c;
782: 20 93 c6 00 sts 0x00C6, r18
UDR = c;
#else
#error UDR not defined
#endif
}
}
786: ff 91 pop r31
788: ef 91 pop r30
78a: 9f 91 pop r25
78c: 8f 91 pop r24
78e: 3f 91 pop r19
790: 2f 91 pop r18
792: 0f 90 pop r0
794: 0f be out 0x3f, r0 ; 63
796: 0f 90 pop r0
798: 1f 90 pop r1
79a: 18 95 reti
0000079c <_ZN14HardwareSerial5beginEm>:
_u2x = u2x;
}
// Public Methods //////////////////////////////////////////////////////////////
void HardwareSerial::begin(unsigned long baud)
79c: af 92 push r10
79e: bf 92 push r11
7a0: df 92 push r13
7a2: ef 92 push r14
7a4: ff 92 push r15
7a6: 0f 93 push r16
7a8: 1f 93 push r17
7aa: cf 93 push r28
7ac: df 93 push r29
7ae: ec 01 movw r28, r24
7b0: 7a 01 movw r14, r20
7b2: 8b 01 movw r16, r22
7b4: dd 24 eor r13, r13
7b6: 40 30 cpi r20, 0x00 ; 0
7b8: 81 ee ldi r24, 0xE1 ; 225
7ba: 58 07 cpc r21, r24
7bc: 80 e0 ldi r24, 0x00 ; 0
7be: 68 07 cpc r22, r24
7c0: 80 e0 ldi r24, 0x00 ; 0
7c2: 78 07 cpc r23, r24
7c4: 11 f0 breq .+4 ; 0x7ca <_ZN14HardwareSerial5beginEm+0x2e>
7c6: dd 24 eor r13, r13
7c8: d3 94 inc r13
#endif
try_again:
if (use_u2x) {
*_ucsra = 1 << _u2x;
7ca: 91 e0 ldi r25, 0x01 ; 1
7cc: a9 2e mov r10, r25
7ce: b1 2c mov r11, r1
7d0: ec 89 ldd r30, Y+20 ; 0x14
7d2: fd 89 ldd r31, Y+21 ; 0x15
}
#endif
try_again:
if (use_u2x) {
7d4: dd 20 and r13, r13
7d6: 69 f0 breq .+26 ; 0x7f2 <_ZN14HardwareSerial5beginEm+0x56>
*_ucsra = 1 << _u2x;
7d8: c5 01 movw r24, r10
7da: 08 a0 ldd r0, Y+32 ; 0x20
7dc: 02 c0 rjmp .+4 ; 0x7e2 <_ZN14HardwareSerial5beginEm+0x46>
7de: 88 0f add r24, r24
7e0: 99 1f adc r25, r25
7e2: 0a 94 dec r0
7e4: e2 f7 brpl .-8 ; 0x7de <_ZN14HardwareSerial5beginEm+0x42>
7e6: 80 83 st Z, r24
baud_setting = (F_CPU / 4 / baud - 1) / 2;
7e8: 60 e0 ldi r22, 0x00 ; 0
7ea: 79 e0 ldi r23, 0x09 ; 9
7ec: 8d e3 ldi r24, 0x3D ; 61
7ee: 90 e0 ldi r25, 0x00 ; 0
7f0: 05 c0 rjmp .+10 ; 0x7fc <_ZN14HardwareSerial5beginEm+0x60>
} else {
*_ucsra = 0;
7f2: 10 82 st Z, r1
baud_setting = (F_CPU / 8 / baud - 1) / 2;
7f4: 60 e8 ldi r22, 0x80 ; 128
7f6: 74 e8 ldi r23, 0x84 ; 132
7f8: 8e e1 ldi r24, 0x1E ; 30
7fa: 90 e0 ldi r25, 0x00 ; 0
7fc: a8 01 movw r20, r16
7fe: 97 01 movw r18, r14
800: 0e 94 8f 05 call 0xb1e ; 0xb1e <__udivmodsi4>
804: 21 50 subi r18, 0x01 ; 1
806: 30 40 sbci r19, 0x00 ; 0
808: 40 40 sbci r20, 0x00 ; 0
80a: 50 40 sbci r21, 0x00 ; 0
80c: 56 95 lsr r21
80e: 47 95 ror r20
810: 37 95 ror r19
812: 27 95 ror r18
}
if ((baud_setting > 4095) && use_u2x)
814: 80 e1 ldi r24, 0x10 ; 16
816: 20 30 cpi r18, 0x00 ; 0
818: 38 07 cpc r19, r24
81a: 20 f0 brcs .+8 ; 0x824 <_ZN14HardwareSerial5beginEm+0x88>
81c: dd 20 and r13, r13
81e: 11 f0 breq .+4 ; 0x824 <_ZN14HardwareSerial5beginEm+0x88>
820: dd 24 eor r13, r13
822: d6 cf rjmp .-84 ; 0x7d0 <_ZN14HardwareSerial5beginEm+0x34>
use_u2x = false;
goto try_again;
}
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
*_ubrrh = baud_setting >> 8;
824: e8 89 ldd r30, Y+16 ; 0x10
826: f9 89 ldd r31, Y+17 ; 0x11
828: 30 83 st Z, r19
*_ubrrl = baud_setting;
82a: ea 89 ldd r30, Y+18 ; 0x12
82c: fb 89 ldd r31, Y+19 ; 0x13
82e: 20 83 st Z, r18
transmitting = false;
830: 19 a2 std Y+33, r1 ; 0x21
sbi(*_ucsrb, _rxen);
832: ee 89 ldd r30, Y+22 ; 0x16
834: ff 89 ldd r31, Y+23 ; 0x17
836: 40 81 ld r20, Z
838: 21 e0 ldi r18, 0x01 ; 1
83a: 30 e0 ldi r19, 0x00 ; 0
83c: c9 01 movw r24, r18
83e: 0c 8c ldd r0, Y+28 ; 0x1c
840: 02 c0 rjmp .+4 ; 0x846 <_ZN14HardwareSerial5beginEm+0xaa>
842: 88 0f add r24, r24
844: 99 1f adc r25, r25
846: 0a 94 dec r0
848: e2 f7 brpl .-8 ; 0x842 <_ZN14HardwareSerial5beginEm+0xa6>
84a: 48 2b or r20, r24
84c: 40 83 st Z, r20
sbi(*_ucsrb, _txen);
84e: ee 89 ldd r30, Y+22 ; 0x16
850: ff 89 ldd r31, Y+23 ; 0x17
852: 40 81 ld r20, Z
854: c9 01 movw r24, r18
856: 0d 8c ldd r0, Y+29 ; 0x1d
858: 02 c0 rjmp .+4 ; 0x85e <_ZN14HardwareSerial5beginEm+0xc2>
85a: 88 0f add r24, r24
85c: 99 1f adc r25, r25
85e: 0a 94 dec r0
860: e2 f7 brpl .-8 ; 0x85a <_ZN14HardwareSerial5beginEm+0xbe>
862: 48 2b or r20, r24
864: 40 83 st Z, r20
sbi(*_ucsrb, _rxcie);
866: ee 89 ldd r30, Y+22 ; 0x16
868: ff 89 ldd r31, Y+23 ; 0x17
86a: 40 81 ld r20, Z
86c: c9 01 movw r24, r18
86e: 0e 8c ldd r0, Y+30 ; 0x1e
870: 02 c0 rjmp .+4 ; 0x876 <_ZN14HardwareSerial5beginEm+0xda>
872: 88 0f add r24, r24
874: 99 1f adc r25, r25
876: 0a 94 dec r0
878: e2 f7 brpl .-8 ; 0x872 <_ZN14HardwareSerial5beginEm+0xd6>
87a: 48 2b or r20, r24
87c: 40 83 st Z, r20
cbi(*_ucsrb, _udrie);
87e: ee 89 ldd r30, Y+22 ; 0x16
880: ff 89 ldd r31, Y+23 ; 0x17
882: 80 81 ld r24, Z
884: 0f 8c ldd r0, Y+31 ; 0x1f
886: 02 c0 rjmp .+4 ; 0x88c <_ZN14HardwareSerial5beginEm+0xf0>
888: 22 0f add r18, r18
88a: 33 1f adc r19, r19
88c: 0a 94 dec r0
88e: e2 f7 brpl .-8 ; 0x888 <_ZN14HardwareSerial5beginEm+0xec>
890: 20 95 com r18
892: 28 23 and r18, r24
894: 20 83 st Z, r18
}
896: df 91 pop r29
898: cf 91 pop r28
89a: 1f 91 pop r17
89c: 0f 91 pop r16
89e: ff 90 pop r15
8a0: ef 90 pop r14
8a2: df 90 pop r13
8a4: bf 90 pop r11
8a6: af 90 pop r10
8a8: 08 95 ret
000008aa <_ZN14HardwareSerial9availableEv>:
_rx_buffer->head = _rx_buffer->tail;
}
int HardwareSerial::available(void)
{
return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE;
8aa: dc 01 movw r26, r24
8ac: 1c 96 adiw r26, 0x0c ; 12
8ae: ed 91 ld r30, X+
8b0: fc 91 ld r31, X
8b2: 1d 97 sbiw r26, 0x0d ; 13
8b4: e0 5c subi r30, 0xC0 ; 192
8b6: ff 4f sbci r31, 0xFF ; 255
8b8: 21 91 ld r18, Z+
8ba: 31 91 ld r19, Z+
8bc: 80 81 ld r24, Z
8be: 91 81 ldd r25, Z+1 ; 0x01
8c0: 28 1b sub r18, r24
8c2: 39 0b sbc r19, r25
8c4: 2f 73 andi r18, 0x3F ; 63
8c6: 30 70 andi r19, 0x00 ; 0
}
8c8: c9 01 movw r24, r18
8ca: 08 95 ret
000008cc <_ZN14HardwareSerial4peekEv>:
int HardwareSerial::peek(void)
{
if (_rx_buffer->head == _rx_buffer->tail) {
8cc: dc 01 movw r26, r24
8ce: 1c 96 adiw r26, 0x0c ; 12
8d0: ed 91 ld r30, X+
8d2: fc 91 ld r31, X
8d4: 1d 97 sbiw r26, 0x0d ; 13
8d6: e0 5c subi r30, 0xC0 ; 192
8d8: ff 4f sbci r31, 0xFF ; 255
8da: 20 81 ld r18, Z
8dc: 31 81 ldd r19, Z+1 ; 0x01
8de: e0 54 subi r30, 0x40 ; 64
8e0: f0 40 sbci r31, 0x00 ; 0
8e2: df 01 movw r26, r30
8e4: ae 5b subi r26, 0xBE ; 190
8e6: bf 4f sbci r27, 0xFF ; 255
8e8: 8d 91 ld r24, X+
8ea: 9c 91 ld r25, X
8ec: 11 97 sbiw r26, 0x01 ; 1
8ee: 28 17 cp r18, r24
8f0: 39 07 cpc r19, r25
8f2: 19 f4 brne .+6 ; 0x8fa <_ZN14HardwareSerial4peekEv+0x2e>
8f4: 2f ef ldi r18, 0xFF ; 255
8f6: 3f ef ldi r19, 0xFF ; 255
8f8: 07 c0 rjmp .+14 ; 0x908 <__stack+0x9>
return -1;
} else {
return _rx_buffer->buffer[_rx_buffer->tail];
8fa: 8d 91 ld r24, X+
8fc: 9c 91 ld r25, X
8fe: e8 0f add r30, r24
900: f9 1f adc r31, r25
902: 80 81 ld r24, Z
904: 28 2f mov r18, r24
906: 30 e0 ldi r19, 0x00 ; 0
}
}
908: c9 01 movw r24, r18
90a: 08 95 ret
0000090c <_ZN14HardwareSerial4readEv>:
int HardwareSerial::read(void)
{
// if the head isn't ahead of the tail, we don't have any characters
if (_rx_buffer->head == _rx_buffer->tail) {
90c: dc 01 movw r26, r24
90e: 1c 96 adiw r26, 0x0c ; 12
910: ed 91 ld r30, X+
912: fc 91 ld r31, X
914: 1d 97 sbiw r26, 0x0d ; 13
916: e0 5c subi r30, 0xC0 ; 192
918: ff 4f sbci r31, 0xFF ; 255
91a: 20 81 ld r18, Z
91c: 31 81 ldd r19, Z+1 ; 0x01
91e: e0 54 subi r30, 0x40 ; 64
920: f0 40 sbci r31, 0x00 ; 0
922: df 01 movw r26, r30
924: ae 5b subi r26, 0xBE ; 190
926: bf 4f sbci r27, 0xFF ; 255
928: 8d 91 ld r24, X+
92a: 9c 91 ld r25, X
92c: 11 97 sbiw r26, 0x01 ; 1
92e: 28 17 cp r18, r24
930: 39 07 cpc r19, r25
932: 19 f4 brne .+6 ; 0x93a <_ZN14HardwareSerial4readEv+0x2e>
934: 2f ef ldi r18, 0xFF ; 255
936: 3f ef ldi r19, 0xFF ; 255
938: 10 c0 rjmp .+32 ; 0x95a <_ZN14HardwareSerial4readEv+0x4e>
return -1;
} else {
unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
93a: 8d 91 ld r24, X+
93c: 9c 91 ld r25, X
93e: 11 97 sbiw r26, 0x01 ; 1
940: e8 0f add r30, r24
942: f9 1f adc r31, r25
944: 20 81 ld r18, Z
_rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE;
946: 8d 91 ld r24, X+
948: 9c 91 ld r25, X
94a: 11 97 sbiw r26, 0x01 ; 1
94c: 01 96 adiw r24, 0x01 ; 1
94e: 8f 73 andi r24, 0x3F ; 63
950: 90 70 andi r25, 0x00 ; 0
952: 11 96 adiw r26, 0x01 ; 1
954: 9c 93 st X, r25
956: 8e 93 st -X, r24
return c;
958: 30 e0 ldi r19, 0x00 ; 0
}
}
95a: c9 01 movw r24, r18
95c: 08 95 ret
0000095e <_ZN14HardwareSerial5flushEv>:
void HardwareSerial::flush()
95e: dc 01 movw r26, r24
{
// UDR is kept full while the buffer is not empty, so TXC triggers when EMPTY && SENT
while (transmitting && ! (*_ucsra & _BV(TXC0)));
960: 91 96 adiw r26, 0x21 ; 33
962: 8c 91 ld r24, X
964: 91 97 sbiw r26, 0x21 ; 33
966: 88 23 and r24, r24
968: 39 f0 breq .+14 ; 0x978 <_ZN14HardwareSerial5flushEv+0x1a>
96a: 54 96 adiw r26, 0x14 ; 20
96c: ed 91 ld r30, X+
96e: fc 91 ld r31, X
970: 55 97 sbiw r26, 0x15 ; 21
972: 80 81 ld r24, Z
974: 86 ff sbrs r24, 6
976: f9 cf rjmp .-14 ; 0x96a <_ZN14HardwareSerial5flushEv+0xc>
transmitting = false;
978: 91 96 adiw r26, 0x21 ; 33
97a: 1c 92 st X, r1
}
97c: 08 95 ret
0000097e <_ZN14HardwareSerial5writeEh>:
size_t HardwareSerial::write(uint8_t c)
97e: cf 93 push r28
980: df 93 push r29
982: ec 01 movw r28, r24
{
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
984: ee 85 ldd r30, Y+14 ; 0x0e
986: ff 85 ldd r31, Y+15 ; 0x0f
988: e0 5c subi r30, 0xC0 ; 192
98a: ff 4f sbci r31, 0xFF ; 255
98c: 20 81 ld r18, Z
98e: 31 81 ldd r19, Z+1 ; 0x01
990: e0 54 subi r30, 0x40 ; 64
992: f0 40 sbci r31, 0x00 ; 0
994: 2f 5f subi r18, 0xFF ; 255
996: 3f 4f sbci r19, 0xFF ; 255
998: 2f 73 andi r18, 0x3F ; 63
99a: 30 70 andi r19, 0x00 ; 0
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
// ???: return 0 here instead?
while (i == _tx_buffer->tail)
99c: df 01 movw r26, r30
99e: ae 5b subi r26, 0xBE ; 190
9a0: bf 4f sbci r27, 0xFF ; 255
9a2: 8d 91 ld r24, X+
9a4: 9c 91 ld r25, X
9a6: 11 97 sbiw r26, 0x01 ; 1
9a8: 28 17 cp r18, r24
9aa: 39 07 cpc r19, r25
9ac: d1 f3 breq .-12 ; 0x9a2 <_ZN14HardwareSerial5writeEh+0x24>
;
_tx_buffer->buffer[_tx_buffer->head] = c;
9ae: e0 5c subi r30, 0xC0 ; 192
9b0: ff 4f sbci r31, 0xFF ; 255
9b2: 80 81 ld r24, Z
9b4: 91 81 ldd r25, Z+1 ; 0x01
9b6: e0 54 subi r30, 0x40 ; 64
9b8: f0 40 sbci r31, 0x00 ; 0
9ba: e8 0f add r30, r24
9bc: f9 1f adc r31, r25
9be: 60 83 st Z, r22
_tx_buffer->head = i;
9c0: ee 85 ldd r30, Y+14 ; 0x0e
9c2: ff 85 ldd r31, Y+15 ; 0x0f
9c4: e0 5c subi r30, 0xC0 ; 192
9c6: ff 4f sbci r31, 0xFF ; 255
9c8: 31 83 std Z+1, r19 ; 0x01
9ca: 20 83 st Z, r18
sbi(*_ucsrb, _udrie);
9cc: ee 89 ldd r30, Y+22 ; 0x16
9ce: ff 89 ldd r31, Y+23 ; 0x17
9d0: 20 81 ld r18, Z
9d2: 81 e0 ldi r24, 0x01 ; 1
9d4: 90 e0 ldi r25, 0x00 ; 0
9d6: 0f 8c ldd r0, Y+31 ; 0x1f
9d8: 02 c0 rjmp .+4 ; 0x9de <_ZN14HardwareSerial5writeEh+0x60>
9da: 88 0f add r24, r24
9dc: 99 1f adc r25, r25
9de: 0a 94 dec r0
9e0: e2 f7 brpl .-8 ; 0x9da <_ZN14HardwareSerial5writeEh+0x5c>
9e2: 28 2b or r18, r24
9e4: 20 83 st Z, r18
// clear the TXC bit -- "can be cleared by writing a one to its bit location"
transmitting = true;
9e6: 81 e0 ldi r24, 0x01 ; 1
9e8: 89 a3 std Y+33, r24 ; 0x21
sbi(*_ucsra, TXC0);
9ea: ec 89 ldd r30, Y+20 ; 0x14
9ec: fd 89 ldd r31, Y+21 ; 0x15
9ee: 80 81 ld r24, Z
9f0: 80 64 ori r24, 0x40 ; 64
9f2: 80 83 st Z, r24
return 1;
}
9f4: 81 e0 ldi r24, 0x01 ; 1
9f6: 90 e0 ldi r25, 0x00 ; 0
9f8: df 91 pop r29
9fa: cf 91 pop r28
9fc: 08 95 ret
000009fe <_GLOBAL__I_rx_buffer>:
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
9fe: 10 92 74 02 sts 0x0274, r1
a02: 10 92 73 02 sts 0x0273, r1
virtual int available() = 0;
virtual int read() = 0;
virtual int peek() = 0;
virtual void flush() = 0;
Stream() {_timeout=1000;}
a06: 88 ee ldi r24, 0xE8 ; 232
a08: 93 e0 ldi r25, 0x03 ; 3
a0a: a0 e0 ldi r26, 0x00 ; 0
a0c: b0 e0 ldi r27, 0x00 ; 0
a0e: 80 93 75 02 sts 0x0275, r24
a12: 90 93 76 02 sts 0x0276, r25
a16: a0 93 77 02 sts 0x0277, r26
a1a: b0 93 78 02 sts 0x0278, r27
HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr,
uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x)
a1e: 84 ed ldi r24, 0xD4 ; 212
a20: 91 e0 ldi r25, 0x01 ; 1
a22: 90 93 72 02 sts 0x0272, r25
a26: 80 93 71 02 sts 0x0271, r24
{
_rx_buffer = rx_buffer;
a2a: 89 ee ldi r24, 0xE9 ; 233
a2c: 91 e0 ldi r25, 0x01 ; 1
a2e: 90 93 7e 02 sts 0x027E, r25
a32: 80 93 7d 02 sts 0x027D, r24
_tx_buffer = tx_buffer;
a36: 8d e2 ldi r24, 0x2D ; 45
a38: 92 e0 ldi r25, 0x02 ; 2
a3a: 90 93 80 02 sts 0x0280, r25
a3e: 80 93 7f 02 sts 0x027F, r24
_ubrrh = ubrrh;
a42: 85 ec ldi r24, 0xC5 ; 197
a44: 90 e0 ldi r25, 0x00 ; 0
a46: 90 93 82 02 sts 0x0282, r25
a4a: 80 93 81 02 sts 0x0281, r24
_ubrrl = ubrrl;
a4e: 84 ec ldi r24, 0xC4 ; 196
a50: 90 e0 ldi r25, 0x00 ; 0
a52: 90 93 84 02 sts 0x0284, r25
a56: 80 93 83 02 sts 0x0283, r24
_ucsra = ucsra;
a5a: 80 ec ldi r24, 0xC0 ; 192
a5c: 90 e0 ldi r25, 0x00 ; 0
a5e: 90 93 86 02 sts 0x0286, r25
a62: 80 93 85 02 sts 0x0285, r24
_ucsrb = ucsrb;
a66: 81 ec ldi r24, 0xC1 ; 193
a68: 90 e0 ldi r25, 0x00 ; 0
a6a: 90 93 88 02 sts 0x0288, r25
a6e: 80 93 87 02 sts 0x0287, r24
_ucsrc = ucsrc;
a72: 82 ec ldi r24, 0xC2 ; 194
a74: 90 e0 ldi r25, 0x00 ; 0
a76: 90 93 8a 02 sts 0x028A, r25
a7a: 80 93 89 02 sts 0x0289, r24
_udr = udr;
a7e: 86 ec ldi r24, 0xC6 ; 198
a80: 90 e0 ldi r25, 0x00 ; 0
a82: 90 93 8c 02 sts 0x028C, r25
a86: 80 93 8b 02 sts 0x028B, r24
_rxen = rxen;
a8a: 84 e0 ldi r24, 0x04 ; 4
a8c: 80 93 8d 02 sts 0x028D, r24
_txen = txen;
a90: 83 e0 ldi r24, 0x03 ; 3
a92: 80 93 8e 02 sts 0x028E, r24
_rxcie = rxcie;
a96: 87 e0 ldi r24, 0x07 ; 7
a98: 80 93 8f 02 sts 0x028F, r24
_udrie = udrie;
a9c: 85 e0 ldi r24, 0x05 ; 5
a9e: 80 93 90 02 sts 0x0290, r24
_u2x = u2x;
aa2: 81 e0 ldi r24, 0x01 ; 1
aa4: 80 93 91 02 sts 0x0291, r24
// Preinstantiate Objects //////////////////////////////////////////////////////
#if defined(UBRRH) && defined(UBRRL)
HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X);
#elif defined(UBRR0H) && defined(UBRR0L)
HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UCSR0C, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0);
aa8: 08 95 ret
00000aaa <main>:
#include <Arduino.h>
int main(void)
aaa: cf 93 push r28
aac: df 93 push r29
{
init();
aae: 0e 94 0f 02 call 0x41e ; 0x41e <init>
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
ab2: 0e 94 b9 01 call 0x372 ; 0x372 <setup>
for (;;) {
loop();
if (serialEventRun) serialEventRun();
ab6: c0 e8 ldi r28, 0x80 ; 128
ab8: d3 e0 ldi r29, 0x03 ; 3
#endif
setup();
for (;;) {
loop();
aba: 0e 94 e7 00 call 0x1ce ; 0x1ce <loop>
if (serialEventRun) serialEventRun();
abe: 20 97 sbiw r28, 0x00 ; 0
ac0: e1 f3 breq .-8 ; 0xaba <main+0x10>
ac2: 0e 94 80 03 call 0x700 ; 0x700 <_Z14serialEventRunv>
ac6: f9 cf rjmp .-14 ; 0xaba <main+0x10>
00000ac8 <_ZN5Print5writeEPKhj>:
#include "Print.h"
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
ac8: cf 92 push r12
aca: df 92 push r13
acc: ef 92 push r14
ace: ff 92 push r15
ad0: 0f 93 push r16
ad2: 1f 93 push r17
ad4: cf 93 push r28
ad6: df 93 push r29
ad8: 7c 01 movw r14, r24
ada: 6b 01 movw r12, r22
adc: 8a 01 movw r16, r20
ade: c0 e0 ldi r28, 0x00 ; 0
ae0: d0 e0 ldi r29, 0x00 ; 0
ae2: 0f c0 rjmp .+30 ; 0xb02 <_ZN5Print5writeEPKhj+0x3a>
{
size_t n = 0;
while (size--) {
n += write(*buffer++);
ae4: d6 01 movw r26, r12
ae6: 6d 91 ld r22, X+
ae8: 6d 01 movw r12, r26
aea: d7 01 movw r26, r14
aec: ed 91 ld r30, X+
aee: fc 91 ld r31, X
af0: 01 90 ld r0, Z+
af2: f0 81 ld r31, Z
af4: e0 2d mov r30, r0
af6: c7 01 movw r24, r14
af8: 09 95 icall
afa: c8 0f add r28, r24
afc: d9 1f adc r29, r25
afe: 01 50 subi r16, 0x01 ; 1
b00: 10 40 sbci r17, 0x00 ; 0
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
b02: 01 15 cp r16, r1
b04: 11 05 cpc r17, r1
b06: 71 f7 brne .-36 ; 0xae4 <_ZN5Print5writeEPKhj+0x1c>
n += write(*buffer++);
}
return n;
}
b08: ce 01 movw r24, r28
b0a: df 91 pop r29
b0c: cf 91 pop r28
b0e: 1f 91 pop r17
b10: 0f 91 pop r16
b12: ff 90 pop r15
b14: ef 90 pop r14
b16: df 90 pop r13
b18: cf 90 pop r12
b1a: 08 95 ret
00000b1c <yield>:
* Its defined as a weak symbol and it can be redefined to implement a
* real cooperative scheduler.
*/
static void __empty() {
// Empty
}
b1c: 08 95 ret
00000b1e <__udivmodsi4>:
b1e: a1 e2 ldi r26, 0x21 ; 33
b20: 1a 2e mov r1, r26
b22: aa 1b sub r26, r26
b24: bb 1b sub r27, r27
b26: fd 01 movw r30, r26
b28: 0d c0 rjmp .+26 ; 0xb44 <__udivmodsi4_ep>
00000b2a <__udivmodsi4_loop>:
b2a: aa 1f adc r26, r26
b2c: bb 1f adc r27, r27
b2e: ee 1f adc r30, r30
b30: ff 1f adc r31, r31
b32: a2 17 cp r26, r18
b34: b3 07 cpc r27, r19
b36: e4 07 cpc r30, r20
b38: f5 07 cpc r31, r21
b3a: 20 f0 brcs .+8 ; 0xb44 <__udivmodsi4_ep>
b3c: a2 1b sub r26, r18
b3e: b3 0b sbc r27, r19
b40: e4 0b sbc r30, r20
b42: f5 0b sbc r31, r21
00000b44 <__udivmodsi4_ep>:
b44: 66 1f adc r22, r22
b46: 77 1f adc r23, r23
b48: 88 1f adc r24, r24
b4a: 99 1f adc r25, r25
b4c: 1a 94 dec r1
b4e: 69 f7 brne .-38 ; 0xb2a <__udivmodsi4_loop>
b50: 60 95 com r22
b52: 70 95 com r23
b54: 80 95 com r24
b56: 90 95 com r25
b58: 9b 01 movw r18, r22
b5a: ac 01 movw r20, r24
b5c: bd 01 movw r22, r26
b5e: cf 01 movw r24, r30
b60: 08 95 ret
00000b62 <__tablejump2__>:
b62: ee 0f add r30, r30
b64: ff 1f adc r31, r31
00000b66 <__tablejump__>:
b66: 05 90 lpm r0, Z+
b68: f4 91 lpm r31, Z+
b6a: e0 2d mov r30, r0
b6c: 09 94 ijmp
00000b6e <_exit>:
b6e: f8 94 cli
00000b70 <__stop_program>:
b70: ff cf rjmp .-2 ; 0xb70 <__stop_program>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment