📄 systemasm.lst
字号:
1 # 1 "SystemAsm.s"
2 # 1 "<built-in>"
1 // SystemAsm.s
0
0
2
3 #include "m128asm.h"
1 //***************************************************************************
2 //* A P P L I C A T I O N N O T E F O R T H E A V R F A M I L Y
3 //*
4 //* Number : AVR000
4
5 .global GetFlashByte
6 .global GetExtFlashByte
7 .global ProgrFlash
8
9 .extern address
10 .extern buff
11 .extern length
12
13
14 .func GetFlashByte
15 GetFlashByte:
16:SystemAsm.s **** push ZL
17:SystemAsm.s **** push ZH
18:SystemAsm.s **** ldi ZL, 0
19:SystemAsm.s **** out RAMPZ, ZL
20:SystemAsm.s **** mov ZL, r24
21:SystemAsm.s **** mov ZH, r25
22:SystemAsm.s **** elpm r24, Z
23:SystemAsm.s **** clr r25
24:SystemAsm.s **** pop ZH
25:SystemAsm.s **** pop ZL
26:SystemAsm.s **** ret
27 .endfunc
28
29 .func GetExtFlashByte
30 GetExtFlashByte:
31:SystemAsm.s **** push ZL
32:SystemAsm.s **** push ZH
33:SystemAsm.s **** ldi ZL, 1
34:SystemAsm.s **** out RAMPZ, ZL
35:SystemAsm.s **** mov ZL, r24
36:SystemAsm.s **** mov ZH, r25
37:SystemAsm.s **** elpm r24, Z
38:SystemAsm.s **** clr r25
39:SystemAsm.s **** pop ZH
40:SystemAsm.s **** pop ZL
41:SystemAsm.s **** ret
42 .endfunc
43
44 .func ProgrFlash
45 ProgrFlash:
46:SystemAsm.s **** push r0
47:SystemAsm.s **** push r1
48:SystemAsm.s **** push r16
49:SystemAsm.s **** push r17
50:SystemAsm.s **** push r24
51:SystemAsm.s **** push r25
52:SystemAsm.s **** push YL
53:SystemAsm.s **** push YH
54:SystemAsm.s **** push ZL
55:SystemAsm.s **** push ZH
56:SystemAsm.s **** clr r17
57:SystemAsm.s **** lds ZL, address
58:SystemAsm.s **** lds ZH, address+1
59:SystemAsm.s **** ldi YL, lo8(buff)
60:SystemAsm.s **** ldi YH, hi8(buff)
61:SystemAsm.s **** lds r24, length
62:SystemAsm.s **** lds r25, length+1
63 length_loop:
64:SystemAsm.s **** cpi r17, 0x00
65:SystemAsm.s **** brne no_page_erase
66 wait_spm1:
67:SystemAsm.s **** lds r16, SPMCSR
68:SystemAsm.s **** andi r16, 1
69:SystemAsm.s **** cpi r16, 1
70:SystemAsm.s **** breq wait_spm1
71:SystemAsm.s **** ldi r16, 0x03
72:SystemAsm.s **** sts SPMCSR, r16
73:SystemAsm.s **** spm
74 wait_spm2:
75:SystemAsm.s **** lds r16, SPMCSR
76:SystemAsm.s **** andi r16, 1
77:SystemAsm.s **** cpi r16, 1
78:SystemAsm.s **** breq wait_spm2
79:SystemAsm.s **** ldi r16, 0x11
80:SystemAsm.s **** sts SPMCSR, r16
81:SystemAsm.s **** spm
82 no_page_erase:
83:SystemAsm.s **** ld r0, Y+
84:SystemAsm.s **** ld r1, Y+
85 wait_spm3:
86:SystemAsm.s **** lds r16, SPMCSR
87:SystemAsm.s **** andi r16, 1
88:SystemAsm.s **** cpi r16, 1
89:SystemAsm.s **** breq wait_spm3
90:SystemAsm.s **** ldi r16, 0x01
91:SystemAsm.s **** sts SPMCSR, r16
92:SystemAsm.s **** spm
93:SystemAsm.s **** inc r17
94:SystemAsm.s **** cpi r17, 128
95:SystemAsm.s **** brlo same_page
96 write_page:
97:SystemAsm.s **** clr r17
98 wait_spm4:
99:SystemAsm.s **** lds r16, SPMCSR
100:SystemAsm.s **** andi r16, 1
101:SystemAsm.s **** cpi r16, 1
102:SystemAsm.s **** breq wait_spm4
103:SystemAsm.s **** ldi r16, 0x05
104:SystemAsm.s **** sts SPMCSR, r16
105:SystemAsm.s **** spm
106 wait_spm5:
107:SystemAsm.s **** lds r16, SPMCSR
108:SystemAsm.s **** andi r16, 1
109:SystemAsm.s **** cpi r16, 1
110:SystemAsm.s **** breq wait_spm5
111:SystemAsm.s **** ldi r16, 0x11
112:SystemAsm.s **** sts SPMCSR, r16
113:SystemAsm.s **** spm
114 same_page:
115:SystemAsm.s **** adiw ZL, 2
116:SystemAsm.s **** sbiw r24, 2
117:SystemAsm.s **** breq final_write
118:SystemAsm.s **** rjmp length_loop
119 final_write:
120:SystemAsm.s **** cpi r17, 0
121:SystemAsm.s **** breq block_done
122:SystemAsm.s **** adiw r24,2
123:SystemAsm.s **** rjmp write_page
124 block_done:
125:SystemAsm.s **** pop ZH
126:SystemAsm.s **** pop ZL
127:SystemAsm.s **** pop YH
128:SystemAsm.s **** pop YL
129:SystemAsm.s **** pop r25
130:SystemAsm.s **** pop r24
131:SystemAsm.s **** pop r17
132:SystemAsm.s **** pop r16
133:SystemAsm.s **** pop r1
134:SystemAsm.s **** pop r0
135 .endfunc
DEFINED SYMBOLS
*ABS*:00000000 SystemAsm.s
*ABS*:00000000 m128asm.h
*ABS*:00000000 SystemAsm.s
*ABS*:00000000 <command line>
*ABS*:00000000 <built-in>
*ABS*:00000000 SystemAsm.s
SystemAsm.s:15 .text:00000000 GetFlashByte
SystemAsm.s:30 .text:00000016 GetExtFlashByte
SystemAsm.s:45 .text:0000002c ProgrFlash
SystemAsm.s:63 .text:00000056 length_loop
SystemAsm.s:82 .text:0000007e no_page_erase
SystemAsm.s:66 .text:0000005a wait_spm1
SystemAsm.s:74 .text:0000006c wait_spm2
SystemAsm.s:85 .text:00000082 wait_spm3
SystemAsm.s:114 .text:000000c0 same_page
SystemAsm.s:96 .text:0000009a write_page
SystemAsm.s:98 .text:0000009c wait_spm4
SystemAsm.s:106 .text:000000ae wait_spm5
SystemAsm.s:119 .text:000000c8 final_write
SystemAsm.s:124 .text:000000d0 block_done
UNDEFINED SYMBOLS
address
buff
length
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -