📄 自恢复程序.s
字号:
.module _自恢复程序.c
.area text(rom, con, rel)
.dbfile 自恢复程序.c
.dbfunc e delay _delay fV
; a -> R16,R17
; b -> R18,R19
.even
_delay::
.dbline -1
.dbline 42
; #include "iom8v.h"
; #include "macros.h"
; #include "stdio.h"
; #define FUSE_H 0xD9
; #define FUSE_L 0xE1
; #define ERASE_CHIP 0x80
; #define WRITE_FUSE 0x40
; #define READ_FUSE 0x04
;
; #define LED_ON PORTD|=BIT(PD0);
; #define LED_OFF PORTD&=~BIT(PD0);
; #define OE 2
; #define OE_H PORTD|=BIT(PD2);
; #define OE_L PORTD&=~BIT(PD2);
; #define WR 3
; #define WR_H PORTD|=BIT(PD3);
; #define WR_L PORTD&=~BIT(PD3);
; #define BS1 4
; #define BS1_H PORTD|=BIT(PD4);
; #define BS1_L PORTD&=~BIT(PD4);
; #define XA0 5
; #define XA0_H PORTD|=BIT(PD5);
; #define XA0_L PORTD&=~BIT(PD5);
; #define XA1 6
; #define XA1_H PORTD|=BIT(PD6);
; #define XA1_L PORTD&=~BIT(PD6);
; #define PAGEL 7
; #define PAGEL_H PORTD|=BIT(PD7);
; #define PAGEL_L PORTD&=~BIT(PD7);
;
; #define BS2 2
; #define BS2_H PORTC|=BIT(PC2);
; #define BS2_L PORTC&=~BIT(PC2);
; #define XTAL1 3
; #define XTAL1_H PORTC|=BIT(PC3);
; #define XTAL1_L PORTC&=~BIT(PC3);
; #define RDY 4
; #define RESET 5
; #define RESET_H PORTC|=BIT(PC5);
; #define RESET_L PORTC&=~BIT(PC5);
; void delay()
; {
.dbline 44
; unsigned int a,b;
; for(a=0;a<250;a++)
clr R16
clr R17
rjmp L5
L2:
.dbline 45
; for(b=0;b<350;b++)
clr R18
clr R19
rjmp L9
L6:
.dbline 46
L7:
.dbline 45
subi R18,255 ; offset = 1
sbci R19,255
L9:
.dbline 45
cpi R18,94
ldi R30,1
cpc R19,R30
brlo L6
L3:
.dbline 44
subi R16,255 ; offset = 1
sbci R17,255
L5:
.dbline 44
cpi R16,250
ldi R30,0
cpc R17,R30
brlo L2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r a 16 i
.dbsym r b 18 i
.dbend
.dbfunc e wait _wait fV
; a -> R16
; b -> R18
.even
_wait::
.dbline -1
.dbline 49
; ;
; }
; void wait()
; {
.dbline 51
; unsigned char a,b;
; for(a=0;a<10;a++)
clr R16
rjmp L14
L11:
.dbline 52
; for(b=0;b<10;b++)
clr R18
rjmp L18
L15:
.dbline 53
L16:
.dbline 52
inc R18
L18:
.dbline 52
cpi R18,10
brlo L15
L12:
.dbline 51
inc R16
L14:
.dbline 51
cpi R16,10
brlo L11
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbsym r a 16 c
.dbsym r b 18 c
.dbend
.dbfunc e set_data _set_data fV
; data -> R20
.even
_set_data::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 56
; ;
; }
; void set_data(char data)
; {
.dbline 58
;
; XA1_L;
cbi 0x12,6
.dbline 58
.dbline 59
; XA0_H;
sbi 0x12,5
.dbline 59
.dbline 60
; PORTB=data;
out 0x18,R20
.dbline 61
; XTAL1_H;
sbi 0x15,3
.dbline 61
.dbline 62
; wait();
rcall _wait
.dbline 63
; XTAL1_L;
cbi 0x15,3
.dbline 63
.dbline 64
; wait();
rcall _wait
.dbline -2
L19:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r data 20 c
.dbend
.dbfunc e write_puls _write_puls fV
.even
_write_puls::
.dbline -1
.dbline 67
; }
; void write_puls()
; {
.dbline 68
; WR_L;
cbi 0x12,3
.dbline 68
.dbline 69
; wait();
rcall _wait
.dbline 70
; WR_H;
sbi 0x12,3
.dbline 70
L21:
.dbline 72
L22:
.dbline 71
; while((PINC&0x10)==0)
sbis 0x13,4
rjmp L21
.dbline 73
; ;
; PORTB=0;
clr R2
out 0x18,R2
.dbline -2
L20:
.dbline 0 ; func end
ret
.dbend
.dbfunc e set_command _set_command fV
; com -> R20
.even
_set_command::
rcall push_gset1
mov R20,R16
.dbline -1
.dbline 76
; }
; void set_command(char com)
; {
.dbline 78
;
; WR_H;
sbi 0x12,3
.dbline 78
.dbline 79
; OE_H;
sbi 0x12,2
.dbline 79
.dbline 80
; XA1_H;
sbi 0x12,6
.dbline 80
.dbline 81
; XA0_L;
cbi 0x12,5
.dbline 81
.dbline 82
; BS1_L;
cbi 0x12,4
.dbline 82
.dbline 83
; BS2_L;
cbi 0x15,2
.dbline 83
.dbline 84
; PORTB=com;
out 0x18,R20
.dbline 85
; XTAL1_H;
sbi 0x15,3
.dbline 85
.dbline 86
; wait();
rcall _wait
.dbline 87
; XTAL1_L;
cbi 0x15,3
.dbline 87
.dbline 88
; wait();
rcall _wait
.dbline -2
L24:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r com 20 c
.dbend
.dbfunc e read_data _read_data fc
; data -> R20
.even
_read_data::
rcall push_gset1
.dbline -1
.dbline 91
; }
; char read_data()
; {
.dbline 93
; char data;
; DDRB=0x00;
clr R2
out 0x17,R2
.dbline 94
; OE_L;
cbi 0x12,2
.dbline 94
.dbline 95
; wait();
rcall _wait
.dbline 96
; data=PINB;
in R20,0x16
.dbline 97
; OE_H;
sbi 0x12,2
.dbline 97
.dbline 98
; return data;
mov R16,R20
.dbline -2
L25:
rcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r data 20 c
.dbend
.dbfunc e main _main fV
; p -> R10
; k -> R10
; i -> R22
; j -> R20
.even
_main::
.dbline -1
.dbline 101
; }
; void main()
; {
.dbline 102
; char i=0,j=0,k=0;
clr R22
.dbline 102
clr R20
.dbline 102
clr R10
.dbline 103
; char p=0;
.dbline 105
;
; DDRD=0x01;
ldi R24,1
out 0x11,R24
.dbline 106
; DDRC=0xef;
ldi R24,239
out 0x14,R24
.dbline 107
; delay();
rcall _delay
.dbline 108
; delay();
rcall _delay
.dbline 109
; delay();
rcall _delay
.dbline 110
; LED_ON;
sbi 0x12,0
.dbline 110
.dbline 111
; delay();
rcall _delay
.dbline 112
; LED_OFF;
cbi 0x12,0
.dbline 112
.dbline 113
; RESET_L;
cbi 0x15,5
.dbline 113
.dbline 114
; for (i=0; i < 10; i++)
rjmp L30
L27:
.dbline 115
.dbline 116
sbi 0x15,3
.dbline 116
.dbline 117
rcall _wait
.dbline 118
cbi 0x15,3
.dbline 118
.dbline 119
L28:
.dbline 114
inc R22
L30:
.dbline 114
cpi R22,10
brlo L27
.dbline 120
; {
; XTAL1_H;
; wait();
; XTAL1_L;
; }
; DDRC=0xef;
ldi R24,239
out 0x14,R24
.dbline 121
; DDRB=0xff;
ldi R24,255
out 0x17,R24
.dbline 122
; DDRD=0xff;
out 0x11,R24
.dbline 123
; OE_L;
cbi 0x12,2
.dbline 123
.dbline 124
; WR_L;
cbi 0x12,3
.dbline 124
.dbline 125
; BS1_L;
cbi 0x12,4
.dbline 125
.dbline 126
; XA0_L;
cbi 0x12,5
.dbline 126
.dbline 127
; XA1_L;
cbi 0x12,6
.dbline 127
.dbline 128
; PAGEL_L;
cbi 0x12,7
.dbline 128
.dbline 129
; BS2_L;
cbi 0x15,2
.dbline 129
.dbline 130
; XTAL1_L;
cbi 0x15,3
.dbline 130
.dbline 131
; delay();
rcall _delay
.dbline 132
; XTAL1_H;
sbi 0x15,3
.dbline 132
.dbline 133
; wait();
rcall _wait
.dbline 134
; XTAL1_L;
cbi 0x15,3
.dbline 134
.dbline 135
; RESET_H;
sbi 0x15,5
.dbline 135
.dbline 136
; delay();
rcall _delay
.dbline 137
; set_command(ERASE_CHIP);
ldi R16,128
rcall _set_command
.dbline 138
; write_puls();
rcall _write_puls
.dbline 139
; set_command(ERASE_CHIP);
ldi R16,128
rcall _set_command
.dbline 140
; write_puls();
rcall _write_puls
.dbline 141
; wait();
rcall _wait
.dbline 142
; wait();
rcall _wait
.dbline 143
; for (j = 0; j < 8; j++)
clr R20
rjmp L34
L31:
.dbline 144
.dbline 145
ldi R16,64
rcall _set_command
.dbline 146
ldi R16,225
rcall _set_data
.dbline 148
cbi 0x12,4
.dbline 148
.dbline 149
cbi 0x15,2
.dbline 149
.dbline 150
rcall _write_puls
.dbline 151
rcall _wait
.dbline 152
rcall _wait
.dbline 153
L32:
.dbline 143
inc R20
L34:
.dbline 143
cpi R20,8
brlo L31
.dbline 154
; {
; set_command(WRITE_FUSE);
; set_data(FUSE_L);
;
; BS1_L;
; BS2_L;
; write_puls();
; wait();
; wait();
; }
; for (j = 0; j < 8; j++)
clr R20
rjmp L38
L35:
.dbline 155
.dbline 157
ldi R16,64
rcall _set_command
.dbline 158
ldi R16,217
rcall _set_data
.dbline 160
sbi 0x12,4
.dbline 160
.dbline 161
cbi 0x15,2
.dbline 161
.dbline 162
rcall _write_puls
.dbline 164
rcall _wait
.dbline 165
rcall _wait
.dbline 166
L36:
.dbline 154
inc R20
L38:
.dbline 154
cpi R20,8
brlo L35
.dbline 169
; {
;
; set_command(WRITE_FUSE);
; set_data(FUSE_H);
;
; BS1_H;
; BS2_L;
; write_puls();
;
; wait();
; wait();
; }
;
;
; LED_ON;
sbi 0x12,0
.dbline 169
.dbline -2
L26:
.dbline 0 ; func end
ret
.dbsym r p 10 c
.dbsym r k 10 c
.dbsym r i 22 c
.dbsym r j 20 c
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -