📄 main.lis
字号:
.module main.c
.area text(rom, con, rel)
0000 .dbfile D:\AVR_Demo\M8IAP\Source\main.c
0000 .dbfunc e Delay _Delay fV
0000 ; i -> R16,R17
.even
0000 _Delay::
0000 .dbline -1
0000 .dbline 43
0000 ; /*****************************************************************************
0000 ; *
0000 ; * Copyright (C) 1996-1998 Atmel Corporation
0000 ; *
0000 ; * File : main.c
0000 ; * Compiler : IAR 1.51B
0000 ; * Output size : 505 bytes (size optimized)
0000 ; * Created : 16-jun-99
0000 ; * Modified : 5-jan-2000
0000 ; * Last modified : 16-may-2001 by jll
0000 ; *
0000 ; * Support mail : avr@atmel.com
0000 ; *
0000 ; * Description : This Program allows an AVR with bootloader capabilities to
0000 ; * Read/write its own Flash/EEprom. To enter Programming mode
0000 ; * PD2 is checked, it this pin is pulled low, programming mode
0000 ; * is entered. If not, normal execution is done from $0000
0000 ; * "reset" vector in Application area.
0000 ; * The PD2 pin should be pulled HIGH by an external Pull-up
0000 ; * resistor.
0000 ; *
0000 ; * Other info : Code must be modified to use this specific code with devices
0000 ; * other than ATmega161. Following change should be made:
0000 ; * -Specify device in define list (e.g. _ATMEGA163)
0000 ; *
0000 ; * When using this code with (future) parts other than ATmega32,
0000 ; * ATmega161 and ATmega163, it will be necessary to change more
0000 ; * than the device name. The changes that should be made is:
0000 ; * -Device name
0000 ; * -Device signature and memory settings (defines.h)
0000 ; * -Device code
0000 ; * -Linker file
0000 ; *
0000 ; * In general the linker file should always be verifyed to match
0000 ; * the used part's boot address and size. Note that memory size
0000 ; * is specified in bytes in the linker file.
0000 ; ****************************************************************************/
0000 ; #include "defines.h"
0000 ; #include "serial.h"
0000 ; #include "assembly.h"
0000 ;
0000 ; void Delay(unsigned int i)
0000 ; {
0000 L2:
0000 .dbline 44
0000 L3:
0000 .dbline 44
0000 ; while(i--) ;
0000 1801 movw R2,R16
0002 0150 subi R16,1
0004 1040 sbci R17,0
0006 2220 tst R2
0008 D9F7 brne L2
000A 3320 tst R3
000C C9F7 brne L2
000E X0:
000E .dbline -2
000E .dbline 45
000E ; }
000E L1:
000E .dbline 0 ; func end
000E 0895 ret
0010 .dbsym r i 16 i
0010 .dbend
0010 .dbfunc e Display_IAP _Display_IAP fV
.even
0010 _Display_IAP::
0010 .dbline -1
0010 .dbline 48
0010 ;
0010 ; void Display_IAP(void)
0010 ; {
0010 .dbline 49
0010 ; PORTD = 0xEF;
0010 8FEE ldi R24,239
0012 82BB out 0x12,R24
0014 .dbline 50
0014 ; PORTB = 0xF9;
0014 89EF ldi R24,249
0016 88BB out 0x18,R24
0018 .dbline 51
0018 ; Delay(6000);
0018 00E7 ldi R16,6000
001A 17E1 ldi R17,23
001C F1DF rcall _Delay
001E .dbline 52
001E ; PORTD = 0xB7;
001E 87EB ldi R24,183
0020 82BB out 0x12,R24
0022 .dbline 53
0022 ; PORTB = 0x08;
0022 88E0 ldi R24,8
0024 88BB out 0x18,R24
0026 .dbline 54
0026 ; Delay(6000);
0026 00E7 ldi R16,6000
0028 17E1 ldi R17,23
002A EADF rcall _Delay
002C .dbline 55
002C ; PORTD = 0xBB;
002C 8BEB ldi R24,187
002E 82BB out 0x12,R24
0030 .dbline 56
0030 ; PORTB = 0xCC;
0030 8CEC ldi R24,204
0032 88BB out 0x18,R24
0034 .dbline -2
0034 .dbline 57
0034 ; }
0034 L5:
0034 .dbline 0 ; func end
0034 0895 ret
0036 .dbend
.area vector(rom, abs)
.org 18
0012 1BC0 rjmp _timer0_ovf_isr
.area text(rom, con, rel)
0036 .dbfile D:\AVR_Demo\M8IAP\Source\main.c
0036 .dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
.even
0036 _timer0_ovf_isr::
0036 00D0 rcall push_lset
0038 .dbline -1
0038 .dbline 61
0038 ;
0038 ; #pragma interrupt_handler timer0_ovf_isr:10
0038 ; void timer0_ovf_isr(void)
0038 ; {
0038 .dbline 62
0038 ; TCNT0 = 0x8D; //reload counter value
0038 8DE8 ldi R24,141
003A 82BF out 0x32,R24
003C .dbline 63
003C ; Display_IAP();
003C E9DF rcall _Display_IAP
003E .dbline -2
003E .dbline 64
003E ; }
003E L6:
003E 00D0 rcall pop_lset
0040 .dbline 0 ; func end
0040 1895 reti
0042 .dbend
0042 .dbfunc e main _main fV
0042 ; intval -> <dead>
0042 ; val -> R20
0042 ; address -> R22,R23
0042 ; data -> R14,R15
0042 ; page_size -> R10
0042 ; page_address -> R12,R13
.even
0042 _main::
0042 .dbline -1
0042 .dbline 66
0042 ; void main(void)
0042 ; {
0042 .dbline 69
0042 ; unsigned int intval,address,data,page_address;
0042 ; unsigned char val, page_size;
0042 ; Delay(10000);
0042 00E1 ldi R16,10000
0044 17E2 ldi R17,39
0046 DCDF rcall _Delay
0048 .dbline 70
0048 ; SerialInit();
0048 00D0 rcall _SerialInit
004A .dbline 71
004A ; Delay(50000);
004A 00E5 ldi R16,50000
004C 13EC ldi R17,195
004E D8DF rcall _Delay
0050 .dbline 72
0050 ; sendstr("富友勤IAP V1.0 ");
0050 00E0 ldi R16,<L8
0052 10E0 ldi R17,>L8
0054 00D0 rcall _sendstr
0056 .dbline 73
0056 ; PORTB = 0xFF;
0056 8FEF ldi R24,255
0058 88BB out 0x18,R24
005A .dbline 74
005A ; DDRB = 0xFF;
005A 87BB out 0x17,R24
005C .dbline 75
005C ; PORTC = 0x7F; //m103 output only
005C 8FE7 ldi R24,127
005E 85BB out 0x15,R24
0060 .dbline 76
0060 ; DDRC = 0x79;
0060 89E7 ldi R24,121
0062 84BB out 0x14,R24
0064 .dbline 77
0064 ; PORTD = 0xFF;
0064 8FEF ldi R24,255
0066 82BB out 0x12,R24
0068 .dbline 78
0068 ; DDRD = 0xFC;
0068 8CEF ldi R24,252
006A 81BB out 0x11,R24
006C .dbline 79
006C ; val=UDR;
006C 4CB1 in R20,0xc
006E .dbline 80
006E ; val=reccharcommand2();
006E 00D0 rcall _reccharcommand2
0070 402F mov R20,R16
0072 .dbline 81
0072 ; if(val=='I') //Chip erase
0072 0934 cpi R16,73
0074 09F4 brne L9
0076 .dbline 82
0076 ; goto Binger;
0076 03C0 rjmp L11
0078 L9:
0078 .dbline 87
0078 ;
0078 ; //UCSRB = 0x00; //disable while setting baud rate
0078 ; //UCSRA = 0x00;
0078 ;
0078 ; PROGPORT |= PROGCTRL; //enable pull-up on PROGCTRL line on PROGPORT
0078 929A sbi 0x12,2
007A .dbline 88
007A ; if (PROGMODE)
007A 8299 sbic 0x10,2
007C 78C0 rjmp L12
007E .dbline 89
007E ; {
007E L11:
007E .dbline 92
007E ; Binger:
007E ;
007E ; sendstr("富友勤 ATMEGA8 DEMO");
007E 00E0 ldi R16,<L14
0080 10E0 ldi R17,>L14
0082 00D0 rcall _sendstr
0084 .dbline 93
0084 ; sendstr("Start IAP");
0084 00E0 ldi R16,<L15
0086 10E0 ldi R17,>L15
0088 00D0 rcall _sendstr
008A .dbline 94
008A ; for(;;)
008A L16:
008A .dbline 95
008A ; {
008A .dbline 96
008A ; Display_IAP();
008A C2DF rcall _Display_IAP
008C .dbline 97
008C ; val=reccharcommand();
008C 00D0 rcall _reccharcommand
008E 402F mov R20,R16
0090 .dbline 98
0090 ; if(val=='W') //Chip erase
0090 0735 cpi R16,87
0092 09F0 breq X5
0094 53C0 rjmp L20
0096 X5:
0096 .dbline 99
0096 ; {
0096 .dbline 100
0096 ; sendstr("Start Write ");
0096 00E0 ldi R16,<L22
0098 10E0 ldi R17,>L22
009A 00D0 rcall _sendstr
009C .dbline 101
009C ; page_address=recchar();
009C 00D0 rcall _recchar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -