The diff output of test.wo.s (test.c without pin_write()) vs test.s (test.c with pin_write()):
--- test.wo.s 2019-02-02 09:41:05.975979913 +0300
+++ test.s 2019-02-02 09:41:30.247979382 +0300
@@ -5,6 +5,16 @@
__tmp_reg__ = 0
__zero_reg__ = 1
.text
+.global pin_write
+ .type pin_write, @function
+pin_write:
+/* prologue: function */
+/* frame size = 0 */
+/* stack size = 0 */
+.L__stack_usage = 0
+/* epilogue start */
+ ret
+ .size pin_write, .-pin_write
.section .text.startup,"ax",@progbits
.global main
.type main, @function
@@ -14,7 +24,7 @@
/* stack size = 0 */
.L__stack_usage = 0
sbi 0xa,2
-.L2:
+.L3:
sbi 0xb,2
ldi r18,lo8(639999)
ldi r24,hi8(639999)
@@ -35,6 +45,6 @@
brne 1b
rjmp .
nop
- rjmp .L2
+ rjmp .L3
.size main, .-main
.ident "GCC: (GNU) 7.3.0"
I use -Os option to generate smaller code and smaller diff(with -Os the problem stay the same).
test.wo.s:
.file "test.c"
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__SREG__ = 0x3f
__tmp_reg__ = 0
__zero_reg__ = 1
.text
.section .text.startup,"ax",@progbits
.global main
.type main, @function
main:
/* prologue: function */
/* frame size = 0 */
/* stack size = 0 */
.L__stack_usage = 0
sbi 0xa,2
.L2:
sbi 0xb,2
ldi r18,lo8(639999)
ldi r24,hi8(639999)
ldi r25,hlo8(639999)
1: subi r18,1
sbci r24,0
sbci r25,0
brne 1b
rjmp .
nop
cbi 0xb,2
ldi r18,lo8(639999)
ldi r24,hi8(639999)
ldi r25,hlo8(639999)
1: subi r18,1
sbci r24,0
sbci r25,0
brne 1b
rjmp .
nop
rjmp .L2
.size main, .-main
.ident "GCC: (GNU) 7.3.0"