📄 second.s
字号:
.module second.c
.area lit(rom, con, rel)
_seg_table::
.byte 48,49
.byte 50,51
.byte 52,53
.byte 54,55
.byte 56,57
.dbfile D:\mega16学习板资料\例程\m16\1602/1602.h
.dbsym e seg_table _seg_table A[10:10]kc
.area text(rom, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602/1602.h
.dbfunc e lcd_init _lcd_init fV
.even
_lcd_init::
.dbline -1
.dbline 37
; //ICC-AVR application builder : 2006-12-22 20:34:51
; // Target : M8
; // Crystal: 6.0000Mhz
; //1602占用了PB口作为数据口,PA6,PA5,PA4分别是RS,WR,E
; //按纽采用循环检测方式工作,不采用中断方式.
;
;
; #include <iom16v.h>
; #include <macros.h>
; #include "1602.h"
; unsigned char led_buff[]="qian ru shi LM! ";
; unsigned char str1[]="www.ourembed.com";
;
;
; void timer1_init(void);
; void init_devices(void);
; unsigned char KeyPress(void);
; void delay_ms(unsigned int time);
; void StartCount(void);
; void StopCount(void);
; void Clear(void);
; unsigned int hour=0,minute=0,second=0,ms=0;
; unsigned char c_next=0,choose=0;
;
; void port_init(void)
; {
; PORTB = 0xFF;
; DDRB = 0xFF;
; PORTC = 0xFF; //m103 output only
; DDRC = 0xFF;
; PORTD = 0xFF;
; DDRD = 0xFF;
; }
;
; //TIMER1 initialisation - prescale:8
; // WGM: 0) Normal, TOP=0xFFFF
; // desired value: 1mSec
.dbline 38
; // actual value: 1.000mSec (0.0%)
ldi R16,100
ldi R17,0
xcall _delay_nms
.dbline 39
; void timer1_init(void)
clr R18
ldi R16,56
xcall _lcd_write_command
.dbline 40
; {
ldi R16,20
ldi R17,0
xcall _delay_nms
.dbline 41
; TCCR1B = 0x00; //stop
clr R18
ldi R16,56
xcall _lcd_write_command
.dbline 42
; TCNT1H = 0x63; //setup
ldi R16,20
ldi R17,0
xcall _delay_nms
.dbline 43
; TCNT1L = 0xc0;
clr R18
ldi R16,56
xcall _lcd_write_command
.dbline 44
; OCR1AH = 0x17;
ldi R16,20
ldi R17,0
xcall _delay_nms
.dbline 46
; OCR1AL = 0x70;
; OCR1BH = 0x17;
ldi R18,1
ldi R16,56
xcall _lcd_write_command
.dbline 47
; OCR1BL = 0x70;
ldi R18,1
ldi R16,8
xcall _lcd_write_command
.dbline 48
; ICR1H = 0x17;
ldi R18,1
ldi R16,1
xcall _lcd_write_command
.dbline 49
; ICR1L = 0x70;
ldi R18,1
ldi R16,6
xcall _lcd_write_command
.dbline 50
; TCCR1A = 0x00;
ldi R18,1
ldi R16,12
.dbline -2
.dbline 51
; TCCR1B = 0x00; //start Timer
L1:
.dbline 0 ; func end
xjmp _lcd_write_command
.dbend
.dbfunc e delay_1ms _delay_1ms fV
; i -> R16,R17
.even
_delay_1ms::
.dbline -1
.dbline 56
; }
;
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
.dbline 58
clr R16
clr R17
xjmp L6
L3:
.dbline 58
L4:
.dbline 58
subi R16,255 ; offset = 1
sbci R17,255
L6:
.dbline 58
; //TIMER1 has overflowed
; TCNT1H = 0x63; //reload counter high value
cpi R16,64
ldi R30,6
cpc R17,R30
brlo L3
.dbline -2
.dbline 59
; TCNT1L = 0xc0; //reload counter low value
L2:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e delay_nms _delay_nms fV
; i -> R20,R21
; n -> R22,R23
.even
_delay_nms::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 63
; }
;
; //call this routine to initialise all peripherals
; void init_devices(void)
.dbline 65
clr R20
clr R21
xjmp L11
L8:
.dbline 65
xcall _delay_1ms
L9:
.dbline 65
subi R20,255 ; offset = 1
sbci R21,255
L11:
.dbline 65
; {
; //stop errant interrupts until set up
cp R20,R22
cpc R21,R23
brlo L8
.dbline -2
.dbline 66
; CLI(); //disable all interrupts
L7:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 22 i
.dbend
.dbfunc e lcd_write_command _lcd_write_command fV
; wait_en -> R22
; command -> R20
.even
_lcd_write_command::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 70
; port_init();
; timer1_init();
;
; MCUCR = 0x0A;
.dbline 71
; GICR = 0x00;
tst R22
breq L13
.dbline 71
xcall _wait_enable
L13:
.dbline 72
; TIMSK = 0x04; //timer interrupt sources
cbi 0x1b,6
.dbline 73
; SEI(); //re-enable interrupts
cbi 0x1b,5
.dbline 74
; //all peripherals are now initialised
cbi 0x1b,4
.dbline 75
; }
nop
.dbline 76
;
sbi 0x1b,4
.dbline 77
; //
out 0x18,R20
.dbline 78
; void main(void)
cbi 0x1b,4
.dbline -2
.dbline 79
; {
L12:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r wait_en 22 c
.dbsym r command 20 c
.dbend
.dbfunc e display_a_char _display_a_char fV
; position_tem -> R22
; char_data -> R20
; position -> R10
.even
_display_a_char::
xcall push_gset3
mov R20,R18
mov R10,R16
.dbline -1
.dbline 84
; init_devices();
; lcd_init();
; //insert your functional code here...
; display_a_string(0,led_buff);
; display_a_string(1,str1);
.dbline 86
;
;
mov R24,R10
cpi R24,16
brlo L16
.dbline 87
; }
mov R22,R24
subi R22,80 ; addi 176
xjmp L17
L16:
.dbline 89
;
; //延时
mov R22,R10
subi R22,128 ; addi 128
L17:
.dbline 90
; void delay_ms(unsigned int time)
ldi R18,1
mov R16,R22
xcall _lcd_write_command
.dbline 91
; { unsigned int i,j;
mov R16,R20
xcall _lcd_write_data
.dbline -2
.dbline 92
;
L15:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r position_tem 22 c
.dbsym r char_data 20 c
.dbsym r position 10 c
.dbend
.dbfunc e display_a_string _display_a_string fV
; col_tem -> R20
; i -> R22
; ptr -> R10,R11
; col -> R20
.even
_display_a_string::
xcall push_gset3
movw R10,R18
mov R20,R16
.dbline -1
.dbline 97
; for(j=0;j<time;j++)
; { for(i=0;i<1000;i++)
; time=time;
; }
; }
.dbline 99
;
; //键盘
mov R24,R20
andi R24,#0x0F
swap R24
mov R20,R24
.dbline 100
;
clr R22
xjmp L22
L19:
.dbline 101
mov R30,R22
clr R31
add R30,R10
adc R31,R11
ldd R18,z+0
mov R2,R20
subi R20,255 ; addi 1
mov R16,R2
xcall _display_a_char
L20:
.dbline 100
inc R22
L22:
.dbline 100
cpi R22,16
brlo L19
.dbline -2
.dbline 102
;
;
L18:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r col_tem 20 c
.dbsym r i 22 c
.dbsym r ptr 10 pc
.dbsym r col 20 c
.dbend
.dbfunc e lcd_write_data _lcd_write_data fV
; char_data -> R20
.even
_lcd_write_data::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 106
;
;
;
;
.dbline 107
;
xcall _wait_enable
.dbline 108
;
sbi 0x1b,6
.dbline 109
;
cbi 0x1b,5
.dbline 110
;
cbi 0x1b,4
.dbline 111
;
nop
.dbline 112
;
sbi 0x1b,4
.dbline 113
;
out 0x18,R20
.dbline 114
;
cbi 0x1b,4
.dbline -2
.dbline 115
;
L23:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r char_data 20 c
.dbend
.dbfunc e wait_enable _wait_enable fV
.even
_wait_enable::
.dbline -1
.dbline 120
;
;
;
;
;
.dbline 121
;
cbi 0x17,7
.dbline 122
;
cbi 0x1b,6
.dbline 123
;
sbi 0x1b,5
.dbline 124
;
nop
.dbline 125
;
sbi 0x1b,4
L25:
.dbline 126
L26:
.dbline 126
;
sbic 0x16,7
rjmp L25
.dbline 127
;
cbi 0x1b,4
.dbline 128
;
sbi 0x17,7
.dbline -2
.dbline 129
;
L24:
.dbline 0 ; func end
ret
.dbend
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602/1602.h
_led_buff::
.blkb 17
.area idata
.byte 'q,'i,'a,'n,32,'r,'u,32,'s,'h,'i,32,'L,'M,33,32
.byte 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602/1602.h
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e led_buff _led_buff A[17:17]c
_str1::
.blkb 17
.area idata
.byte 'w,'w,'w,46,'o,'u,'r,'e,'m,'b,'e,'d,46,'c,'o,'m
.byte 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e str1 _str1 A[17:17]c
_hour::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e hour _hour i
_minute::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e minute _minute i
_second::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e second _second i
_ms::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e ms _ms i
_c_next::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e c_next _c_next c
_choose::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbsym e choose _choose c
.area text(rom, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 26
.dbline 27
ldi R24,255
out 0x18,R24
.dbline 28
out 0x17,R24
.dbline 29
out 0x15,R24
.dbline 30
out 0x14,R24
.dbline 31
out 0x12,R24
.dbline 32
out 0x11,R24
.dbline -2
.dbline 33
L28:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 40
.dbline 41
clr R2
out 0x2e,R2
.dbline 42
ldi R24,99
out 0x2d,R24
.dbline 43
ldi R24,192
out 0x2c,R24
.dbline 44
ldi R24,23
out 0x2b,R24
.dbline 45
ldi R24,112
out 0x2a,R24
.dbline 46
ldi R24,23
out 0x29,R24
.dbline 47
ldi R24,112
out 0x28,R24
.dbline 48
ldi R24,23
out 0x27,R24
.dbline 49
ldi R24,112
out 0x26,R24
.dbline 50
out 0x2f,R2
.dbline 51
out 0x2e,R2
.dbline -2
.dbline 52
L29:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 32
jmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile D:\mega16学习板资料\例程\m16\1602\second.c
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R24
in R24,0x3f
st -y,R24
.dbline -1
.dbline 56
.dbline 58
ldi R24,99
out 0x2d,R24
.dbline 59
ldi R24,192
out 0x2c,R24
.dbline -2
.dbline 60
L30:
ld R24,y+
out 0x3f,R24
ld R24,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 64
.dbline 66
cli
.dbline 67
xcall _port_init
.dbline 68
xcall _timer1_init
.dbline 70
ldi R24,10
out 0x35,R24
.dbline 71
clr R2
out 0x3b,R2
.dbline 72
ldi R24,4
out 0x39,R24
.dbline 73
sei
.dbline -2
.dbline 75
L31:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 79
.dbline 80
xcall _init_devices
.dbline 81
xcall _lcd_init
.dbline 83
ldi R18,<_led_buff
ldi R19,>_led_buff
clr R16
xcall _display_a_string
.dbline 84
ldi R18,<_str1
ldi R19,>_str1
ldi R16,1
.dbline -2
.dbline 87
L32:
.dbline 0 ; func end
xjmp _display_a_string
.dbend
.dbfunc e delay_ms _delay_ms fV
; j -> R20,R21
; i -> R22,R23
; time -> R16,R17
.even
_delay_ms::
xcall push_gset2
.dbline -1
.dbline 91
.dbline 93
clr R20
clr R21
xjmp L37
L34:
.dbline 94
.dbline 94
clr R22
clr R23
xjmp L41
L38:
.dbline 95
L39:
.dbline 94
subi R22,255 ; offset = 1
sbci R23,255
L41:
.dbline 94
cpi R22,232
ldi R30,3
cpc R23,R30
brlo L38
.dbline 96
L35:
.dbline 93
subi R20,255 ; offset = 1
sbci R21,255
L37:
.dbline 93
cp R20,R16
cpc R21,R17
brlo L34
.dbline -2
.dbline 97
L33:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r j 20 i
.dbsym r i 22 i
.dbsym r time 16 i
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -