Skip to content

Instantly share code, notes, and snippets.

@ciniml
Created November 8, 2016 18:01
Show Gist options
  • Save ciniml/60ee3e0fdfde4356d547e1e4b7a3a21b to your computer and use it in GitHub Desktop.
Save ciniml/60ee3e0fdfde4356d547e1e4b7a3a21b to your computer and use it in GitHub Desktop.
#include <avr/io.h>
#include <stdint.h>
int main(void)
{
/* Replace with your application code */
while (1)
{
const volatile uint8_t a = 10;
const volatile uint8_t b = 20;
volatile uint16_t result = a * b;
}
}
@ciniml
Copy link
Author

ciniml commented Nov 8, 2016

Output for tiny817:
0000004c

:
#include <avr/io.h>
#include <stdint.h>

int main(void)
{
4c: cf 93 push r28
4e: df 93 push r29
50: 00 d0 rcall .+0 ; 0x52 <main+0x6>
52: 00 d0 rcall .+0 ; 0x54 <main+0x8>
54: cd b7 in r28, 0x3d ; 61
56: de b7 in r29, 0x3e ; 62
/* Replace with your application code /
while (1)
{
const volatile uint8_t a = 10;
58: 3a e0 ldi r19, 0x0A ; 10
const volatile uint8_t b = 20;
5a: 24 e1 ldi r18, 0x14 ; 20
int main(void)
{
/
Replace with your application code */
while (1)
{
const volatile uint8_t a = 10;
5c: 3c 83 std Y+4, r19 ; 0x04
const volatile uint8_t b = 20;
5e: 2b 83 std Y+3, r18 ; 0x03
volatile uint16_t result = a * b;
60: 8c 81 ldd r24, Y+4 ; 0x04
62: 9b 81 ldd r25, Y+3 ; 0x03
64: 89 9f mul r24, r25
66: c0 01 movw r24, r0
68: 11 24 eor r1, r1
6a: 89 83 std Y+1, r24 ; 0x01
6c: 9a 83 std Y+2, r25 ; 0x02
}
6e: f6 cf rjmp .-20 ; 0x5c <main+0x10>

00000070 <_exit>:
70: f8 94 cli

00000072 <__stop_program>:
72: ff cf rjmp .-2 ; 0x72 <__stop_program>

@ciniml
Copy link
Author

ciniml commented Nov 8, 2016

Output for mega328:
000000cc

:
#include <avr/io.h>
#include <stdint.h>

int main(void)
{
cc: cf 93 push r28
ce: df 93 push r29
d0: 00 d0 rcall .+0 ; 0xd2 <main+0x6>
d2: 00 d0 rcall .+0 ; 0xd4 <main+0x8>
d4: cd b7 in r28, 0x3d ; 61
d6: de b7 in r29, 0x3e ; 62
/* Replace with your application code /
while (1)
{
const volatile uint8_t a = 10;
d8: 3a e0 ldi r19, 0x0A ; 10
const volatile uint8_t b = 20;
da: 24 e1 ldi r18, 0x14 ; 20
int main(void)
{
/
Replace with your application code */
while (1)
{
const volatile uint8_t a = 10;
dc: 3c 83 std Y+4, r19 ; 0x04
const volatile uint8_t b = 20;
de: 2b 83 std Y+3, r18 ; 0x03
volatile uint16_t result = a * b;
e0: 8c 81 ldd r24, Y+4 ; 0x04
e2: 9b 81 ldd r25, Y+3 ; 0x03
e4: 89 9f mul r24, r25
e6: c0 01 movw r24, r0
e8: 11 24 eor r1, r1
ea: 9a 83 std Y+2, r25 ; 0x02
ec: 89 83 std Y+1, r24 ; 0x01
}
ee: f6 cf rjmp .-20 ; 0xdc <main+0x10>

000000f0 <_exit>:
f0: f8 94 cli

000000f2 <__stop_program>:
f2: ff cf rjmp .-2 ; 0xf2 <__stop_program>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment