Looking at object code is too deep for me...
:
Learning atmel studio and a new assembly language and maybe c+ is a lot of work to answer a curiosity.
It's not THAT bad. You CAN disassemble the binary from the Arduino IDE, you just have to learn where stuff is. And you don't need to "learn" the assembly language to be able to tell the difference between shifting and division...
Sigh. Here:
char c;
int i;
long u;
c = PORTB;
i = (c + (PORTB << 8)) + micros();
u = (i + (PORTB << 16)) + millis();
PORTD = c / 8;
PORTD = i / 8;
PORTD = u / 8;
PORTD = c / 10;
PORTD = i / 10;
PORTD = u / 10;
Produces:
PORTD = c / 8;
230: 8c 2f mov r24, r28
232: c7 ff sbrs r28, 7
234: 02 c0 rjmp .+4 ; 0x23a <main+0x116>
236: 87 e0 ldi r24, 0x07 ; 7
238: 8c 0f add r24, r28
23a: 85 95 asr r24 ;;; ***** SHIFTS *****
23c: 85 95 asr r24
23e: 85 95 asr r24
240: 8b b9 out 0x0b, r24 ; 11
PORTD = i / 8;
242: c8 01 movw r24, r16
244: 17 fd sbrc r17, 7
246: 07 96 adiw r24, 0x07 ; 7
248: 23 e0 ldi r18, 0x03 ; 3
24a: 95 95 asr r25 ;;; ***** SHIFTS in a loop *****
24c: 87 95 ror r24
24e: 2a 95 dec r18
250: e1 f7 brne .-8 ; 0x24a <main+0x126>
252: 8b b9 out 0x0b, r24 ; 11
PORTD = u / 8;
254: c7 01 movw r24, r14
256: b6 01 movw r22, r12
258: 28 e0 ldi r18, 0x08 ; 8
25a: 30 e0 ldi r19, 0x00 ; 0
25c: 40 e0 ldi r20, 0x00 ; 0
25e: 50 e0 ldi r21, 0x00 ; 0
260: 0e 94 71 01 call 0x2e2 ; 0x2e2 <__divmodsi4> ;;;; ****** Divide *****
264: 2b b9 out 0x0b, r18 ; 11
PORTD = c / 10;
266: 8c 2f mov r24, r28
268: 6a e0 ldi r22, 0x0A ; 10
26a: 0e 94 4f 01 call 0x29e ; 0x29e <__divmodqi4> ;;;; ****** Divide *****
26e: 8b b9 out 0x0b, r24 ; 11
PORTD = i / 10;
270: c8 01 movw r24, r16
272: 6a e0 ldi r22, 0x0A ; 10
274: 70 e0 ldi r23, 0x00 ; 0
276: 0e 94 5d 01 call 0x2ba ; 0x2ba <__divmodhi4> ;;;; ****** Divide *****
27a: 6b b9 out 0x0b, r22 ; 11
PORTD = u / 10;
27c: c7 01 movw r24, r14
27e: b6 01 movw r22, r12
280: 2a e0 ldi r18, 0x0A ; 10
282: 30 e0 ldi r19, 0x00 ; 0
284: 40 e0 ldi r20, 0x00 ; 0
286: 50 e0 ldi r21, 0x00 ; 0
288: 0e 94 71 01 call 0x2e2 ; 0x2e2 <__divmodsi4> ;;;; ****** Divide *****
28c: 2b b9 out 0x0b, r18 ; 11
Interestingly (?) divide-by-8 of an unsigned quantity results in shifts for all variable sizes...
The divide operator is verrryyyy sloooooowwwww
Note that this is a CPU-dependent statement. Divide is pretty fast on a Due with it's ARM CM3 chip (but NOT on an Arduino Zero, where the CM0+ cpu lacks a divide instruction.)
Also note that right-shifting a signed integer is "implementation defined" in C. It might not be equivalent to division on some cpus.