Last active
December 29, 2015 16:22
-
-
Save cho45/397f834791bae67166e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
avr-objdump -d main.elf | |
main.elf: file format elf32-avr | |
Disassembly of section .text: | |
00000000 <__vectors>: | |
0: 34 c0 rjmp .+104 ; 0x6a <__ctors_end> | |
2: 00 00 nop | |
4: 4c c0 rjmp .+152 ; 0x9e <__bad_interrupt> | |
6: 00 00 nop | |
8: 4a c0 rjmp .+148 ; 0x9e <__bad_interrupt> | |
a: 00 00 nop | |
c: 48 c0 rjmp .+144 ; 0x9e <__bad_interrupt> | |
e: 00 00 nop | |
10: 46 c0 rjmp .+140 ; 0x9e <__bad_interrupt> | |
12: 00 00 nop | |
14: 44 c0 rjmp .+136 ; 0x9e <__bad_interrupt> | |
16: 00 00 nop | |
18: 42 c0 rjmp .+132 ; 0x9e <__bad_interrupt> | |
1a: 00 00 nop | |
1c: 40 c0 rjmp .+128 ; 0x9e <__bad_interrupt> | |
1e: 00 00 nop | |
20: 3e c0 rjmp .+124 ; 0x9e <__bad_interrupt> | |
22: 00 00 nop | |
24: 3c c0 rjmp .+120 ; 0x9e <__bad_interrupt> | |
26: 00 00 nop | |
28: 3a c0 rjmp .+116 ; 0x9e <__bad_interrupt> | |
2a: 00 00 nop | |
2c: 38 c0 rjmp .+112 ; 0x9e <__bad_interrupt> | |
2e: 00 00 nop | |
30: 36 c0 rjmp .+108 ; 0x9e <__bad_interrupt> | |
32: 00 00 nop | |
34: 34 c0 rjmp .+104 ; 0x9e <__bad_interrupt> | |
36: 00 00 nop | |
38: 32 c0 rjmp .+100 ; 0x9e <__bad_interrupt> | |
3a: 00 00 nop | |
3c: 30 c0 rjmp .+96 ; 0x9e <__bad_interrupt> | |
3e: 00 00 nop | |
40: 2e c0 rjmp .+92 ; 0x9e <__bad_interrupt> | |
42: 00 00 nop | |
44: 2c c0 rjmp .+88 ; 0x9e <__bad_interrupt> | |
46: 00 00 nop | |
48: 2a c0 rjmp .+84 ; 0x9e <__bad_interrupt> | |
4a: 00 00 nop | |
4c: 28 c0 rjmp .+80 ; 0x9e <__bad_interrupt> | |
4e: 00 00 nop | |
50: 26 c0 rjmp .+76 ; 0x9e <__bad_interrupt> | |
52: 00 00 nop | |
54: 24 c0 rjmp .+72 ; 0x9e <__bad_interrupt> | |
56: 00 00 nop | |
58: 22 c0 rjmp .+68 ; 0x9e <__bad_interrupt> | |
5a: 00 00 nop | |
5c: 20 c0 rjmp .+64 ; 0x9e <__bad_interrupt> | |
5e: 00 00 nop | |
60: 1e c0 rjmp .+60 ; 0x9e <__bad_interrupt> | |
62: 00 00 nop | |
64: 1c c0 rjmp .+56 ; 0x9e <__bad_interrupt> | |
... | |
00000068 <__ctors_start>: | |
68: 5b 00 .word 0x005b ; ???? | |
0000006a <__ctors_end>: | |
6a: 11 24 eor r1, r1 | |
6c: 1f be out 0x3f, r1 ; 63 | |
6e: cf ef ldi r28, 0xFF ; 255 | |
70: d8 e0 ldi r29, 0x08 ; 8 | |
72: de bf out 0x3e, r29 ; 62 | |
74: cd bf out 0x3d, r28 ; 61 | |
00000076 <__do_clear_bss>: | |
76: 21 e0 ldi r18, 0x01 ; 1 | |
78: a0 e0 ldi r26, 0x00 ; 0 | |
7a: b1 e0 ldi r27, 0x01 ; 1 | |
7c: 01 c0 rjmp .+2 ; 0x80 <.do_clear_bss_start> | |
0000007e <.do_clear_bss_loop>: | |
7e: 1d 92 st X+, r1 | |
00000080 <.do_clear_bss_start>: | |
80: a1 30 cpi r26, 0x01 ; 1 | |
82: b2 07 cpc r27, r18 | |
84: e1 f7 brne .-8 ; 0x7e <.do_clear_bss_loop> | |
00000086 <__do_global_ctors>: | |
86: 10 e0 ldi r17, 0x00 ; 0 | |
88: c5 e3 ldi r28, 0x35 ; 53 | |
8a: d0 e0 ldi r29, 0x00 ; 0 | |
8c: 03 c0 rjmp .+6 ; 0x94 <__do_global_ctors+0xe> | |
8e: 21 97 sbiw r28, 0x01 ; 1 | |
90: fe 01 movw r30, r28 | |
92: 14 d0 rcall .+40 ; 0xbc <__tablejump2__> | |
94: c4 33 cpi r28, 0x34 ; 52 | |
96: d1 07 cpc r29, r17 | |
98: d1 f7 brne .-12 ; 0x8e <__do_global_ctors+0x8> | |
9a: 02 d0 rcall .+4 ; 0xa0 <main> | |
9c: 15 c0 rjmp .+42 ; 0xc8 <_exit> | |
0000009e <__bad_interrupt>: | |
9e: b0 cf rjmp .-160 ; 0x0 <__vectors> | |
000000a0 <main>: | |
a0: 00 00 nop | |
a2: 00 00 nop | |
a4: 00 00 nop | |
a6: 80 91 00 01 lds r24, 0x0100 | |
aa: 8c 71 andi r24, 0x1C ; 28 | |
ac: 81 6e ori r24, 0xE1 ; 225 | |
ae: 80 93 00 01 sts 0x0100, r24 | |
b2: 00 00 nop | |
b4: ff cf rjmp .-2 ; 0xb4 <main+0x14> | |
000000b6 <_GLOBAL__sub_I_main>: | |
b6: 10 92 00 01 sts 0x0100, r1 | |
ba: 08 95 ret | |
000000bc <__tablejump2__>: | |
bc: ee 0f add r30, r30 | |
be: ff 1f adc r31, r31 | |
c0: 05 90 lpm r0, Z+ | |
c2: f4 91 lpm r31, Z | |
c4: e0 2d mov r30, r0 | |
c6: 09 94 ijmp | |
000000c8 <_exit>: | |
c8: f8 94 cli | |
000000ca <__stop_program>: | |
ca: ff cf rjmp .-2 ; 0xca <__stop_program> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AVR Memory Usage | |
---------------- | |
Device: atmega328p | |
Program: 204 bytes (0.6% Full) | |
(.text + .data + .bootloader) | |
Data: 1 bytes (0.0% Full) | |
(.data + .bss + .noinit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#!make disasm | |
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
template <class T, uint8_t s, uint8_t e = s> | |
struct bits { | |
T ref; | |
static constexpr T mask = (T)(~( (T)(~0) << (e - s + 1))) << s; | |
void operator=(const T val) { ref = (ref & ~mask) | ((val & (mask >> s)) << s); } | |
operator T() const { return (ref & mask) >> s; } | |
}; | |
template <uint8_t s, uint8_t e = s> | |
using bits8 = bits<uint8_t, s, e>; | |
union { | |
uint8_t data = 0; | |
bits8<0, 1> FAULT_QUEUE ; | |
bits8<2> CT_PIN_POLARITY ; | |
bits8<3> INT_PIN_POLARITY ; | |
bits8<4> INT_CT_MODE ; | |
bits8<5, 6> OPERATION_MODE ; | |
bits8<7> RESOLUTION ; | |
} config; | |
int main(void) { | |
asm volatile ("nop"); | |
config.OPERATION_MODE = 0b11; | |
asm volatile ("nop"); | |
config.RESOLUTION = 1; | |
asm volatile ("nop"); | |
config.FAULT_QUEUE = 1; | |
asm volatile ("nop"); | |
for (;;) { | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment