1 .file "led_flash.c" 2 .arch atmega8 3 __SREG__ = 0x3f 4 __SP_H__ = 0x3e 5 __SP_L__ = 0x3d 6 __tmp_reg__ = 0 7 __zero_reg__ = 1 8 .global __do_copy_data 9 .global __do_clear_bss 11 .text 12 .Ltext0: 53 .global delay_ms 55 delay_ms: 1:led_flash.c **** #include 2:led_flash.c **** #define F_CPU 1000000UL // 1 MHz 3:led_flash.c **** #include 4:led_flash.c **** 5:led_flash.c **** // convert from loop cycles to msecs 6:led_flash.c **** #define _delay_ms(x) _delay_loop_2((x)*(F_CPU/4000)) 7:led_flash.c **** 8:led_flash.c **** /* 9:led_flash.c **** void delay_ms(unsigned int t) 10:led_flash.c **** 11:led_flash.c **** _delay_loop_2() can only take a 16-bit argument. This routine 12:led_flash.c **** repeatedly calls _delay_loop_2() in order to get the desired busy 13:led_flash.c **** wait length. Note that there is some overhead in the loop that is 14:led_flash.c **** not counted in the delay (so the delay is actually just a little longer) 15:led_flash.c **** 16:led_flash.c **** This code is also specific to the 1 MHz clock 17:led_flash.c **** 18:led_flash.c **** */ 19:led_flash.c **** 20:led_flash.c **** void delay_ms(unsigned int t) { 57 .LM1: 58 /* prologue: frame size=0 */ 59 /* prologue end (size=0) */ 60 0000 AC01 movw r20,r24 21:led_flash.c **** d delay_ms(unsigned int t) { 62 .LM2: 63 0002 852F mov r24,r21 64 0004 9927 clr r25 22:led_flash.c **** d delay_ms(unsigned int t) { 23:led_flash.c **** unsigned int nloops = (unsigned short) (t >> 8); 24:led_flash.c **** unsigned int i; 66 .LM3: 67 0006 0097 sbiw r24,0 68 0008 41F0 breq .L10 69 000a 9C01 movw r18,r24 70 .L6: 71 .LBB2: 73 .Ltext1: 1:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** /* Copyright (c) 2002, Marek Michalkiewicz 2:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** All rights reserved. 3:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 4:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** Redistribution and use in source and binary forms, with or without 5:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** modification, are permitted provided that the following conditions are met: 6:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 7:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** * Redistributions of source code must retain the above copyright 8:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** notice, this list of conditions and the following disclaimer. 9:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** * Redistributions in binary form must reproduce the above copyright 10:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** notice, this list of conditions and the following disclaimer in 11:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** the documentation and/or other materials provided with the 12:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** distribution. 13:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 14:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** POSSIBILITY OF SUCH DAMAGE. */ 25:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 26:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** /* $Id: delay.h,v 1.2.2.2 2004/02/13 21:43:37 joerg_wunsch Exp $ */ 27:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 28:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** /* 29:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** avr/delay.h - loops for small accurate delays 30:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** */ 31:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 32:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** #ifndef _AVR_DELAY_H_ 33:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** #define _AVR_DELAY_H_ 1 34:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 35:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** #include 36:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 37:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** /* 8-bit count, 3 cycles/loop */ 38:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** static __inline__ void 39:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** _delay_loop_1(uint8_t __count) 40:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** { 41:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** asm volatile ( 42:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** "1: dec %0" "\n\t" 43:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** "brne 1b" 44:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** : "=r" (__count) 45:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** : "0" (__count) 46:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** ); 47:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** } 48:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** 49:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** /* 16-bit count, 4 cycles/loop */ 50:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** static __inline__ void 51:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** _delay_loop_2(uint16_t __count) 52:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** { 75 .LM4: 76 000c 80E0 ldi r24,lo8(-1536) 77 000e 9AEF ldi r25,hi8(-1536) 78 .LBB3: 53:C:/WinAVR/bin/../lib/gcc/avr/3.4.1/../../../../avr/include/avr/delay.h **** asm volatile ( 80 .LM5: 81 /* #APP */ 82 0010 0197 1: sbiw r24,1 83 0012 F1F7 brne 1b 84 /* #NOAPP */ 85 .LBE3: 86 .LBE2: 88 .Ltext2: 90 .LM6: 91 0014 2150 subi r18,lo8(-(-1)) 92 0016 3040 sbci r19,hi8(-(-1)) 93 0018 C9F7 brne .L6 94 .L10: 25:led_flash.c **** t >> 8); 26:led_flash.c **** unsigned int i; 27:led_flash.c **** 96 .LM7: 97 001a 9A01 movw r18,r20 98 001c 3070 andi r19,hi8(255) 28:led_flash.c **** >> 8); 100 .LM8: 101 001e 2115 cp r18,__zero_reg__ 102 0020 3105 cpc r19,__zero_reg__ 103 0022 71F0 breq .L1 104 .LBB4: 106 .Ltext3: 108 .LM9: 109 0024 C901 movw r24,r18 110 0026 AA27 clr r26 111 0028 BB27 clr r27 112 002a BC01 movw r22,r24 113 002c CD01 movw r24,r26 114 002e 2AEF ldi r18,lo8(250) 115 0030 30E0 ldi r19,hi8(250) 116 0032 40E0 ldi r20,hlo8(250) 117 0034 50E0 ldi r21,hhi8(250) 118 0036 00D0 rcall __mulsi3 119 0038 DC01 movw r26,r24 120 003a CB01 movw r24,r22 121 .LBB5: 123 .LM10: 124 /* #APP */ 125 003c 0197 1: sbiw r24,1 126 003e F1F7 brne 1b 127 /* #NOAPP */ 128 .L1: 129 0040 0895 ret 130 .LBE5: 131 .LBE4: 132 /* epilogue: frame size=0 */ 133 /* epilogue: noreturn */ 134 /* epilogue end (size=0) */ 135 /* function delay_ms size 40 (40) */ 146 .global main 148 main: 150 .Ltext4: 29:led_flash.c **** (unsigned short) (t >> 8); 30:led_flash.c **** unsigned int i; 31:led_flash.c **** 32:led_flash.c **** for(i = 0; i < nloops; ++i) { 33:led_flash.c **** _delay_ms(256); 34:led_flash.c **** }; 35:led_flash.c **** i = t & 0xFF; 152 .LM11: 153 /* prologue: frame size=0 */ 154 0042 C0E0 ldi r28,lo8(__stack - 0) 155 0044 D0E0 ldi r29,hi8(__stack - 0) 156 0046 DEBF out __SP_H__,r29 157 0048 CDBF out __SP_L__,r28 158 /* prologue end (size=4) */ 36:led_flash.c **** 37:led_flash.c **** }; 38:led_flash.c **** i = t & 0xFF; 160 .LM12: 161 004a 8FEF ldi r24,lo8(-1) 162 004c 87BB out 55-0x20,r24 163 .L12: 39:led_flash.c **** 40:led_flash.c **** }; 41:led_flash.c **** i = t & 0xFF; 165 .LM13: 166 004e 88B3 in r24,56-0x20 167 0050 91E0 ldi r25,lo8(1) 168 0052 8927 eor r24,r25 169 0054 88BB out 56-0x20,r24 42:led_flash.c **** 171 .LM14: 172 0056 84EF ldi r24,lo8(500) 173 0058 91E0 ldi r25,hi8(500) 174 005a D2DF rcall delay_ms 43:led_flash.c **** ) { 176 .LM15: 177 005c 88B3 in r24,56-0x20 178 005e 12E0 ldi r17,lo8(2) 179 0060 8127 eor r24,r17 180 0062 88BB out 56-0x20,r24 44:led_flash.c **** = 0; i < nloops; ++i) { 182 .LM16: 183 0064 8AEF ldi r24,lo8(250) 184 0066 90E0 ldi r25,hi8(250) 185 0068 CBDF rcall delay_ms 45:led_flash.c **** = 0; i < nloops; ++i) { 187 .LM17: 188 006a 88B3 in r24,56-0x20 189 006c 8127 eor r24,r17 190 006e 88BB out 56-0x20,r24 46:led_flash.c **** = 0; i < nloops; ++i) { 192 .LM18: 193 0070 8AEF ldi r24,lo8(250) 194 0072 90E0 ldi r25,hi8(250) 195 0074 C5DF rcall delay_ms 196 0076 EBCF rjmp .L12 197 /* epilogue: frame size=0 */ 198 /* epilogue: noreturn */ 199 /* epilogue end (size=0) */ 200 /* function main size 27 (23) */ 202 .text 204 Letext: 205 /* File "led_flash.c": code 67 = 0x0043 ( 63), prologues 4, epilogues 0 */ DEFINED SYMBOLS *ABS*:00000000 led_flash.c *ABS*:0000003f __SREG__ *ABS*:0000003e __SP_H__ *ABS*:0000003d __SP_L__ *ABS*:00000000 __tmp_reg__ *ABS*:00000001 __zero_reg__ C:\DOCUME~1\FAGG~1.ROV\LOCALS~1\Temp/ccCYaaaa.s:55 .text:00000000 delay_ms C:\DOCUME~1\FAGG~1.ROV\LOCALS~1\Temp/ccCYaaaa.s:148 .text:00000042 main C:\DOCUME~1\FAGG~1.ROV\LOCALS~1\Temp/ccCYaaaa.s:204 .text:00000078 Letext UNDEFINED SYMBOLS __do_copy_data __do_clear_bss __mulsi3 __stack