📄 main.s
字号:
.module main.c
.area lit(rom, con, rel)
_seg7_data::
.byte 63,6
.byte 91,'O
.byte 'f,'m
.byte 125,7
.byte 127,'o
.byte 'w,124
.byte 57,94
.byte 'y,'q
.byte 0
.dbfile E:\avr\2.2.3\main.c
.dbsym e seg7_data _seg7_data A[17:17]kc
.area text(rom, con, rel)
.dbfile E:\avr\2.2.3\main.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 13
; // ICC-AVR application builder : 2007-5-28 22:03:35
; // Target : M16
; // Crystal: 7.3728Mhz
; // 连接:接好电源和晶振的跳线
; // 7断数码管的ABCD接VCC,a~dp接PA0~PA7
; #include <iom16v.h>
; #include <macros.h>
;
; const unsigned char seg7_data[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};//0~F and "shut"
; volatile unsigned char i; //在中断中会变化的变量,加volatile限定词定义
;
; void port_init(void)
; {
.dbline 14
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 15
; DDRA = 0xFF;
ldi R24,255
out 0x1a,R24
.dbline 16
; PORTB = 0x00;
out 0x18,R2
.dbline 17
; DDRB = 0x00;
out 0x17,R2
.dbline 18
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 19
; DDRC = 0x00;
out 0x14,R2
.dbline 20
; PORTD = 0x00;
out 0x12,R2
.dbline 21
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 29
; }
;
; //TIMER1 initialize - prescale:256
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1Sec
; // actual value: 1.000Sec (0.0%)
; void timer1_init(void)
; {
.dbline 30
; TCCR1B = 0x00; //stop
clr R2
out 0x2e,R2
.dbline 31
; TCNT1H = 0x8F; //setup
ldi R24,143
out 0x2d,R24
.dbline 32
; TCNT1L = 0x81;
ldi R24,129
out 0x2c,R24
.dbline 33
; OCR1AH = 0x70;
ldi R24,112
out 0x2b,R24
.dbline 34
; OCR1AL = 0x7F;
ldi R24,127
out 0x2a,R24
.dbline 35
; OCR1BH = 0x70;
ldi R24,112
out 0x29,R24
.dbline 36
; OCR1BL = 0x7F;
ldi R24,127
out 0x28,R24
.dbline 37
; ICR1H = 0x70;
ldi R24,112
out 0x27,R24
.dbline 38
; ICR1L = 0x7F;
ldi R24,127
out 0x26,R24
.dbline 39
; TCCR1A = 0x00;
out 0x2f,R2
.dbline 40
; TCCR1B = 0x04; //start Timer
ldi R24,4
out 0x2e,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 32
jmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile E:\avr\2.2.3\main.c
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R2
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
.dbline -1
.dbline 45
.dbline 47
ldi R24,143
out 0x2d,R24
.dbline 48
ldi R24,129
out 0x2c,R24
.dbline 49
lds R24,_i
subi R24,255 ; addi 1
sts _i,R24
.dbline 50
lds R24,_i
cpi R24,10
brne L4
.dbline 50
clr R2
sts _i,R2
L4:
.dbline -2
L3:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 55
; }
;
; #pragma interrupt_handler timer1_ovf_isr:iv_TIMER1_OVF
; void timer1_ovf_isr(void)
; {
; //TIMER1 has overflowed
; TCNT1H = 0x8F; //reload counter high value
; TCNT1L = 0x81; //reload counter low value
; i++; //在文件开始的定义,volatile unsigned char i;
; if(i==10) i=0;
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 57
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 58
; port_init();
xcall _port_init
.dbline 59
; timer1_init();
xcall _timer1_init
.dbline 61
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 62
; GICR = 0x00;
out 0x3b,R2
.dbline 63
; TIMSK = 0x04; //timer interrupt sources ,这里允许了timer1溢出中断。
ldi R24,4
out 0x39,R24
.dbline 64
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 69
; //all peripherals are now initialized
; }
;
; void main(void)
; {
.dbline 70
; init_devices(); //初始化,包含了定时器的初始化
xcall _init_devices
xjmp L9
L8:
.dbline 72
.dbline 73
ldi R24,<_seg7_data
ldi R25,>_seg7_data
lds R30,_i
clr R31
add R30,R24
adc R31,R25
lpm R30,Z
out 0x1b,R30
.dbline 74
L9:
.dbline 71
xjmp L8
X0:
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbend
.area bss(ram, con, rel)
.dbfile E:\avr\2.2.3\main.c
_i::
.blkb 1
.dbsym e i _i c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -