Disassembliamo?


oggi mi sono divertito disassemblare lo sketch blink compilato per atmega328p.
questo è il programma in linguaggio macchina che viene spedito al microcontrollore:

code: [select]

   0: jmp 0x061
   4: jmp 0x073
   8: jmp 0x073
   c: jmp 0x073
  10: jmp 0x073
  14: jmp 0x073
  18: jmp 0x073
  1c: jmp 0x073
  20: jmp 0x073
  24: jmp 0x073
  28: jmp 0x073
  2c: jmp 0x073
  30: jmp 0x073
  34: jmp 0x073
  38: jmp 0x073
  3c: jmp 0x073
  40: jmp 0x08f
  44: jmp 0x073
  48: jmp 0x073
  4c: jmp 0x073
  50: jmp 0x073
  54: jmp 0x073
  58: jmp 0x073
  5c: jmp 0x073
  60: jmp 0x073
  64: jmp 0x073
  68: nop
  6a: nop
  6c: .dw 0x024
  6e: .dw 0x027
  70: .dw 0x02a
  72: nop
  74: nop
  76: .dw 0x025
  78: .dw 0x028
  7a: .dw 0x02b
  7c: nop
  7e: nop
  80: .dw 0x023
  82: .dw 0x026
  84: .dw 0x029
  86: cpc r0, r4
  88: cpc r0, r4
  8a: cpc r0, r4
  8c: cpc r0, r4
  8e: muls r16, r18
  90: muls r16, r18
  92: muls r16, r18
  94: mulsu r16, r19
  96: mulsu r16, r19
  98: mulsu r16, r19
  9a: muls r16, r17
  9c: sbc r0, r4
  9e: and r1, r0
  a0: ld r4, z
  a2: muls r16, r17
  a4: sbc r0, r4
  a6: and r1, r0
  a8: muls r16, r17
  aa: sbc r0, r4
  ac: and r1, r0
  ae: nop
  b0: cpc r16, r16
  b2: muls r16, r16
  b4: .dw 0x001
  b6: mulsu r16, r16
  b8: cpc r0, r20
  ba: nop
  bc: nop
  be: nop
  c0: nop
  c2: clr r1
  c4: out $3f, r1
  c6: ser r28
  c8: ldi r29, 0x08
  ca: out $3e, r29
  cc: out $3d, r28
  ce: ldi r17, 0x01
  d0: ldi r26, 0x00
  d2: ldi r27, 0x01
  d4: rjmp .+2 ; 0xd8
  d6: st x+, r1
  d8: cpi r26, 0x0f
  da: cpc r27, r17
  dc: brne .-8 ; 0xd6
  de: call 0x212
  e2: jmp 0x219
  e6: jmp 0x000
  ea: ldi r24, 0x0d
  ec: ldi r22, 0x01
  ee: call 0x1b4
  f2: ret
  f4: ldi r24, 0x0d
  f6: ldi r22, 0x01
  f8: call 0x1d8
  fc: ldi r22, 0xe8
  fe: ldi r23, 0x03
100: ldi r24, 0x00
102: ldi r25, 0x00
104: call 0x125
108: ldi r24, 0x0d
10a: ldi r22, 0x00
10c: call 0x1d8
110: ldi r22, 0xe8
112: ldi r23, 0x03
114: ldi r24, 0x00
116: ldi r25, 0x00
118: call 0x125
11c: ret
11e: push r1
120: push r0
122: in r0, 0x3f
124: push r0
126: clr r1
128: push r18
12a: push r19
12c: push r24
12e: push r25
130: push r26
132: push r27
134: lds r24, 0x104
138: lds r25, 0x105
13c: lds r26, 0x106
140: lds r27, 0x107
144: lds r19, 0x10e
148: adiw r24, 0x01
14a: adc r26, r1
14c: adc r27, r1
14e: mov r18, r19
150: subi r18, 0xfd
152: cpi r18, 0x7d
154: brcs .+8 ; 0x15e
156: subi r18, 0x7d
158: adiw r24, 0x01
15a: adc r26, r1
15c: adc r27, r1
15e: sts 0x10e, r18
162: sts 0x104, r24
166: sts 0x105, r25
16a: sts 0x106, r26
16e: sts 0x107, r27
172: lds r24, 0x100
176: lds r25, 0x101
17a: lds r26, 0x102
17e: lds r27, 0x103
182: adiw r24, 0x01
184: adc r26, r1
186: adc r27, r1
188: sts 0x100, r24
18c: sts 0x101, r25
190: sts 0x102, r26
194: sts 0x103, r27
198: lds r24, 0x10c
19c: lds r25, 0x10d
1a0: adiw r24, 0x01
1a2: sts 0x10d, r25
1a6: sts 0x10c, r24
1aa: lds r24, 0x10c
1ae: lds r25, 0x10d
1b2: ldi r18, 0x03
1b4: cpi r24, 0xd1
1b6: cpc r25, r18
1b8: brcs .+46 ; 0x1e8
1ba: lds r24, 0x108
1be: lds r25, 0x109
1c2: lds r26, 0x10a
1c6: lds r27, 0x10b
1ca: adiw r24, 0x01
1cc: adc r26, r1
1ce: adc r27, r1
1d0: sts 0x108, r24
1d4: sts 0x109, r25
1d8: sts 0x10a, r26
1dc: sts 0x10b, r27
1e0: sts 0x10d, r1
1e4: sts 0x10c, r1
1e8: pop r27
1ea: pop r26
1ec: pop r25
1ee: pop r24
1f0: pop r19
1f2: pop r18
1f4: pop r0
1f6: out $3f, r0
1f8: pop r0
1fa: pop r1
1fc: reti
1fe: in r25, 0x3f
200: cli
202: lds r18, 0x100
206: lds r19, 0x101
20a: lds r20, 0x102
20e: lds r21, 0x103
212: in r24, 0x26
214: sbis $15, 0
216: rjmp .+12 ; 0x224
218: cpi r24, 0xff
21a: breq .+8 ; 0x224
21c: subi r18, 0xff
21e: sbci r19, 0xff
220: sbci r20, 0xff
222: sbci r21, 0xff
224: out $3f, r25
226: mov r21, r20
228: mov r20, r19
22a: mov r19, r18
22c: clr r18
22e: add r18, r24
230: adc r19, r1
232: adc r20, r1
234: adc r21, r1
236: ldi r24, 0x02
238: lsl r18
23a: rol r19
23c: rol r20
23e: rol r21
240: dec r24
242: brne .-12 ; 0x238
244: movw r22, r18
246: movw r24, r20
248: ret
24a: push r14
24c: push r15
24e: push r16
250: push r17
252: push r28
254: push r29
256: movw r14, r22
258: movw r16, r24
25a: call 0x0ff
25e: movw r28, r22
260: rjmp .+30 ; 0x280
262: call 0x0ff
266: sub r22, r28
268: sbc r23, r29
26a: ldi r24, 0x03
26c: cpi r22, 0xe8
26e: cpc r23, r24
270: brcs .+14 ; 0x280
272: sec
274: sbc r14, r1
276: sbc r15, r1
278: sbc r16, r1
27a: sbc r17, r1
27c: subi r28, 0x18
27e: sbci r29, 0xfc
280: cp r14, r1
282: cpc r15, r1
284: cpc r16, r1
286: cpc r17, r1
288: brne .-40 ; 0x262
28a: pop r29
28c: pop r28
28e: pop r17
290: pop r16
292: pop r15
294: pop r14
296: ret
298: sei
29a: in r24, 0x24
29c: ori r24, 0x02
29e: out $24, r24
2a0: in r24, 0x24
2a2: ori r24, 0x01
2a4: out $24, r24
2a6: in r24, 0x25
2a8: ori r24, 0x02
2aa: out $25, r24
2ac: in r24, 0x25
2ae: ori r24, 0x01
2b0: out $25, r24
2b2: ldi r30, 0x6e
2b4: ldi r31, 0x00
2b6: ld r24, z
2b8: ori r24, 0x01
2ba: st z, r24
2bc: ldi r30, 0x81
2be: ldi r31, 0x00
2c0: st z, r1
2c2: ld r24, z
2c4: ori r24, 0x02
2c6: st z, r24
2c8: ld r24, z
2ca: ori r24, 0x01
2cc: st z, r24
2ce: ldi r30, 0x80
2d0: ldi r31, 0x00
2d2: ld r24, z
2d4: ori r24, 0x01
2d6: st z, r24
2d8: ldi r30, 0xb1
2da: ldi r31, 0x00
2dc: ld r24, z
2de: ori r24, 0x04
2e0: st z, r24
2e2: ldi r30, 0xb0
2e4: ldi r31, 0x00
2e6: ld r24, z
2e8: ori r24, 0x01
2ea: st z, r24
2ec: ldi r30, 0x7a
2ee: ldi r31, 0x00
2f0: ld r24, z
2f2: ori r24, 0x04
2f4: st z, r24
2f6: ld r24, z
2f8: ori r24, 0x02
2fa: st z, r24
2fc: ld r24, z
2fe: ori r24, 0x01
300: st z, r24
302: ld r24, z
304: ori r24, 0x80
306: st z, r24
308: sts 0x0c1, r1
30c: ret
30e: cpi r24, 0x03
310: breq .+28 ; 0x32e
312: cpi r24, 0x04
314: brcc .+10 ; 0x320
316: cpi r24, 0x01
318: breq .+40 ; 0x342
31a: cpi r24, 0x02
31c: brne .+72 ; 0x366
31e: rjmp .+40 ; 0x348
320: cpi r24, 0x06
322: breq .+44 ; 0x350
324: cpi r24, 0x07
326: breq .+52 ; 0x35c
328: cpi r24, 0x04
32a: brne .+58 ; 0x366
32c: rjmp .+8 ; 0x336
32e: lds r24, 0x080
332: andi r24, 0x7f
334: rjmp .+6 ; 0x33c
336: lds r24, 0x080
33a: andi r24, 0xdf
33c: sts 0x080, r24
340: ret
342: in r24, 0x24
344: andi r24, 0x7f
346: rjmp .+4 ; 0x34c
348: in r24, 0x24
34a: andi r24, 0xdf
34c: out $24, r24
34e: ret
350: lds r24, 0x0b0
354: andi r24, 0x7f
356: sts 0x0b0, r24
35a: ret
35c: lds r24, 0x0b0
360: andi r24, 0xdf
362: sts 0x0b0, r24
366: ret
368: ldi r25, 0x00
36a: movw r30, r24
36c: subi r30, 0x66
36e: sbci r31, 0xff
370: lpm r18, z
372: movw r30, r24
374: subi r30, 0x7a
376: sbci r31, 0xff
378: lpm r30, z
37a: tst r30
37c: breq .+48 ; 0x3ae
37e: ldi r31, 0x00
380: lsl r30
382: rol r31
384: subi r30, 0x98
386: sbci r31, 0xff
388: lpm r24, z+
38a: lpm r25, z
38c: movw r26, r24
38e: tst r22
390: brne .+16 ; 0x3a2
392: in r25, 0x3f
394: cli
396: ld r24, x
398: com r18
39a: and r24, r18
39c: st x, r24
39e: out $3f, r25
3a0: ret
3a2: in r25, 0x3f
3a4: cli
3a6: ld r24, x
3a8: or r24, r18
3aa: st x, r24
3ac: out $3f, r25
3ae: ret
3b0: push r16
3b2: push r17
3b4: push r29
3b6: push r28
3b8: push r0
3ba: in r28, 0x3d
3bc: in r29, 0x3e
3be: mov r18, r24
3c0: ldi r19, 0x00
3c2: movw r30, r18
3c4: subi r30, 0x52
3c6: sbci r31, 0xff
3c8: lpm r24, z
3ca: movw r30, r18
3cc: subi r30, 0x66
3ce: sbci r31, 0xff
3d0: lpm r17, z
3d2: subi r18, 0x7a
3d4: sbci r19, 0xff
3d6: movw r30, r18
3d8: lpm r16, z
3da: tst r16
3dc: breq .+58 ; 0x418
3de: tst r24
3e0: breq .+8 ; 0x3ea
3e2: std y+1, r22
3e4: call 0x187
3e8: ldd r22, y+1
3ea: mov r30, r16
3ec: ldi r31, 0x00
3ee: lsl r30
3f0: rol r31
3f2: subi r30, 0x8e
3f4: sbci r31, 0xff
3f6: lpm r24, z+
3f8: lpm r25, z
3fa: movw r26, r24
3fc: tst r22
3fe: brne .+12 ; 0x40c
400: in r25, 0x3f
402: cli
404: ld r24, x
406: com r17
408: and r24, r17
40a: rjmp .+8 ; 0x414
40c: in r25, 0x3f
40e: cli
410: ld r24, x
412: or r24, r17
414: st x, r24
416: out $3f, r25
418: pop r0
41a: pop r28
41c: pop r29
41e: pop r17
420: pop r16
422: ret
424: call 0x14c
428: call 0x075
42c: call 0x07a
430: rjmp .-6 ; 0x42c
432: cli
434: rjmp .-2 ; 0x434


buffo, vero? uno sketch di neanche 10 righe in c diventa lunghettino in linguaggio macchina  :smiley-sweat:

come l'hai decompilato? hai semplicemente aperto l'hex?


Arduino Forum > International > Italiano > Generale (Moderator: leo72) > Disassembliamo?


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial