📄 bi2.s
字号:
;
; 0x2a,0x2a,0x4a,0x2a,0x2a,0x4a,0x2a,0x2c,0x28,0x29,
; 0x4a,0x4a,0x2b,0x2b,0x2b,0x2b,0x2b,0x2a,0x2a,0x2a,
; 0x2a,0x29,0x29,0x28,0x49,0x4c,0x2a,0x2a,0x4a,0x2a,
; 0x2a,0x4a,0x2a,0x2c,0x28,0x29,0x4a,0x4a,0x2b,0x2b,
; 0x2b,0x2b,0x2b,0x2a,0x2a,0x2a,0x2c,0x2c,0x2b,0x29,
; 0x48,0x48,
;
; 0x4a,0x2a,0x29,0x28,0x29,0x28,0x27,0x46,0x46,0x46,
; 0x46,0x4b,0x2b,0x2a,0x29,0x28,0x29,0x2b,0x4a,0x4a,
; 0x4a,0x4b,0x2b,0x2a,0x49,0x29,0x2b,0x4a,0x2a,0x28,
; 0x46,0x48,0x47,0x4a,0x29,0x28,0x27,0x28,0x46,0x46,
; 0x46,0x46,0x4a,0x2a,0x29,0x28,0x29,0x28,0x27,0x46,
; 0x46,0x46,0x46,0x4b,0x2b,0x2a,0x29,0x28,0x29,0x2b,
; 0x4a,0x4a,0x4a,0x4b,0x2b,0x2a,0x49,0x29,0x2b,0x4a,
; 0x2a,0x28,0x46,0x48,0x47,0x4a,0x29,0x28,0x27,0x28,
; 0x46,0x46,0x46,0x46,
;
; 0x43,0x43,0x45,0x49,0x49,0x49,0x48,0x48,0x45,0x44,
; 0x44,0x44,0x43,0x43,0x43,0x43,0x44,0x45,0x46,0x46,
; 0x46,0x45,0x45,0x45,0x43,0x43,0x45,0x49,0x49,0x49,
; 0x48,0x48,0x45,0x44,0x44,0x44,0x43,0x43,0x45,0x45,
; 0x46,0x47,0x48,0x48,0x48,0x48,0x48,0x48,0x49,0x49,
; 0x45,0x47,0x46,0x45,0x43,0x43,0x45,0x48,0x48,0x48,
; 0x46,0x46,0x48,0x49,0x49,0x48,0x47,0x47,0x47,0x45,
; 0x45,0x45,0x43,0x43,0x45,0x49,0x49,0x49,0x48,0x48,
; 0x45,0x44,0x44,0x44,0x43,0x43,0x45,0x45,0x46,0x47,
; 0x48,0x48,0x48,0x48,0x40,0x40,
;
; 0x45,0x48,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x49,0x4a,
; 0x49,0x48,0x48,0x48,0x48,0x48,0x45,0x48,0x4a,0x4a,
; 0x48,0x4a,0x4c,0x4c,0x4b,0x4a,0x49,0x49,0x49,0x49,
; 0x49,0x4c,0x4b,0x4a,0x4a,0x4a,0x49,0x48,0x48,0x49,
; 0x4a,0x4c,0x4b,0x4b,0x4b,0x4b,0x4b,0x46,0x46,0x45,
; 0x45,0x45,0x47,0x48,0x49,0x49,0x4a,0x49,0x48,0x48,
; 0x48,0x48,0x48,0x48,
;
; 0x00,0x00*/
; };
;
; /* 音阶表 */
; const unsigned int TONETABLE[15]={DO,RE,MI,FA,SO,LA,TI,DO_H,
; RE_H,MI_H,FA_H,SO_H,LA_H,TI_H,DO_HH};
; /* 音阶重装常数 */
; unsigned int toneconst;
;
; void delay_us(int time)
; {//微秒级延时程序
L58:
.dbline 337
; do
; {
.dbline 338
; time--;
subi R16,1
sbci R17,0
.dbline 339
; }
L59:
.dbline 340
; while (time>1);
ldi R24,1
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L58
.dbline -2
L57:
.dbline 0 ; func end
ret
.dbsym r time 16 I
.dbend
.dbfunc e delay_ms _delay_ms fV
; time -> R20,R21
.even
_delay_ms::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 344
; }
;
; void delay_ms(unsigned int time)
; {//毫秒级延时程序
xjmp L63
L62:
.dbline 346
.dbline 347
ldi R16,1000
ldi R17,3
xcall _delay_us
.dbline 348
subi R20,1
sbci R21,0
.dbline 349
L63:
.dbline 345
; while(time!=0)
cpi R20,0
cpc R20,R21
brne L62
X0:
.dbline -2
L61:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r time 20 i
.dbend
.area vector(rom, abs)
.org 32
jmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile E:\temp\avr\bi2\bi2.c
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R2
st -y,R3
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 354
; {
; delay_us(1000);
; time--;
; }
; }
;
; #pragma interrupt_handler timer1_ovf_isr:iv_TIMER1_OVF
; void timer1_ovf_isr(void)
; {
.dbline 355
; TCNT1=toneconst;
lds R2,_toneconst
lds R3,_toneconst+1
out 0x2d,R3
out 0x2c,R2
.dbline 356
; PORTC^=1;
ldi R24,1
in R2,0x15
eor R2,R24
out 0x15,R2
.dbline -2
L65:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e music _music fV
; sound_add -> R20,R21
; temp1 -> R22
; temp -> R10
.even
_music::
xcall push_gset3
sbiw R28,2
.dbline -1
.dbline 359
; }
; void music(void)
; {
.dbline 361
; unsigned char temp,temp1;
; unsigned int sound_add=0;
clr R20
clr R21
.dbline 362
; TCCR1A = 0x00;
clr R2
out 0x2f,R2
.dbline 363
; TCCR1B =(1<<CS11);//8分频
ldi R24,2
out 0x2e,R24
.dbline 364
; temp1 = sound[sound_add];
ldi R24,<_sound
ldi R25,>_sound
movw R30,R20
add R30,R24
adc R31,R25
lpm R22,Z
xjmp L68
L67:
.dbline 366
; while(temp1!=0)
; {disp_temp(0,0,1);
.dbline 366
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
clr R18
clr R19
clr R16
clr R17
xcall _disp_temp
.dbline 367
; temp=temp1;
mov R10,R22
.dbline 368
; temp&=0x0f;
mov R24,R10
andi R24,15
mov R10,R24
.dbline 370
;
; if(temp!=0)
tst R24
breq L70
.dbline 371
; {
.dbline 372
; TIMSK|=(1<<TOIE1);//根据SOUNDTABLE中数据的低四位选择音调频率
in R24,0x39
ori R24,4
out 0x39,R24
.dbline 373
; temp--;
dec R10
.dbline 374
; toneconst=TONETABLE[temp];
ldi R24,2
mul R24,R10
movw R30,R0
ldi R24,<_TONETABLE
ldi R25,>_TONETABLE
add R30,R24
adc R31,R25
lpm R0,Z+
lpm R1,Z
movw R30,R0
sts _toneconst+1,R31
sts _toneconst,R30
.dbline 375
; TCNT1=toneconst;
out 0x2d,R31
out 0x2c,R30
.dbline 376
; }
L70:
.dbline 377
mov R10,R22
.dbline 378
mov R24,R10
swap R24
andi R24,#0x0F
.dbline 379
andi R24,15
mov R10,R24
.dbline 380
ldi R24,129
mul R24,R10
movw R16,R0
xcall _delay_ms
.dbline 381
in R24,0x39
andi R24,251
out 0x39,R24
.dbline 382
subi R20,255 ; offset = 1
sbci R21,255
.dbline 383
ldi R24,<_sound
ldi R25,>_sound
movw R30,R20
add R30,R24
adc R31,R25
lpm R22,Z
.dbline 384
L68:
.dbline 365
tst R22
breq X1
xjmp L67
X1:
.dbline -2
L66:
adiw R28,2
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r sound_add 20 i
.dbsym r temp1 22 c
.dbsym r temp 10 c
.dbend
.dbfunc e timer2_init _timer2_init fV
.even
_timer2_init::
.dbline -1
.dbline 394
; temp=temp1;
; temp>>=4;
; temp&=0x0f;
; delay_ms(temp*129);//根据SOUNDTABLE中数据的高四位*5后,为音调持续时间
; TIMSK&=~(1<<TOIE1);
; sound_add++;
; temp1 = sound[sound_add];
; }
; // delay_ms(1000);
;
; }
; #define delaytime 300
;
; //TIMER2 initialisation - prescale:256
; // desired value: 1Sec
; // actual value: 1.000Sec (0.0%)
; void timer2_init(void)
; {
.dbline 395
; TCCR2 = 0x00; //stop
clr R2
out 0x25,R2
.dbline 396
; ASSR |= (1<<AS2); //set async mode
in R24,0x22
ori R24,8
out 0x22,R24
.dbline 397
; TCNT2 = 0x80; //setup
ldi R24,128
out 0x24,R24
.dbline 398
; TCCR2 |= (1<<CS22)|(1<<CS21); //start
in R24,0x25
ori R24,6
out 0x25,R24
.dbline -2
L72:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 16
jmp _timer2_ovf_isr
.area text(rom, con, rel)
.dbfile E:\temp\avr\bi2\bi2.c
.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
.even
_timer2_ovf_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 403
; }
;
; #pragma interrupt_handler timer2_ovf_isr:iv_TIMER2_OVF
; void timer2_ovf_isr(void)
; {
.dbline 404
; TCNT2 = 0x80; //reload counter value
ldi R24,128
out 0x24,R24
.dbline 405
; PORTB^=1;
ldi R24,1
in R2,0x18
eor R2,R24
out 0x18,R2
.dbline -2
L73:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area lit(rom, con, rel)
L75:
.byte 48,0
.byte 0,0,0,0
.area text(rom, con, rel)
.dbfile E:\temp\avr\bi2\bi2.c
.dbfunc e LCD_write_ch _LCD_write_ch fV
; k -> <dead>
; p -> y+0
; i -> R20
; s -> R22,R23
; z -> R10
; Y -> R14
; X -> R12
.even
_LCD_write_ch::
xcall push_gset5
mov R14,R18
mov R12,R16
sbiw R28,6
ldd R10,y+16
ldd R22,y+18
ldd R23,y+19
.dbline -1
.dbline 433
; }
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
; void LCD_write_ch(unsigned char X,unsigned char Y,unsigned char z,unsigned int s)
; {unsigned char k;
.dbline 434
; unsigned char p[6]="0";
ldi R24,<L75
ldi R25,>L75
movw R30,R28
ldi R16,6
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
xcall asgncblk
.dbline 435
; unsigned char i=0;
clr R20
.dbline 437
; //写地址
; LCD_set_xy( X, Y );
mov R18,R14
mov R16,R12
xcall _LCD_set_xy
.dbline 438
; for(i=0;i<z;i++)
xjmp L79
L76:
.dbline 439
.dbline 440
ldi R18,10
ldi R19,0
movw R16,R22
xcall mod16u
movw R24,R28
mov R30,R20
clr R31
add R30,R24
adc R31,R25
std z+0,R16
.dbline 441
ldi R18,10
ldi R19,0
movw R16,R22
xcall div16u
movw R22,R16
.dbline 443
L77:
.dbline 438
inc R20
L79:
.dbline 438
cp R20,R10
brlo L76
.dbline 444
; {
; p[i]=s%10;
; s=s/10;
;
; }
; i--;
dec R20
.dbline 455
; /*
; while(!(p[i]))
; {
; if(i==0)
; {LCD_write_char( 0, 0b00110000 );i--;}
; else
; {i--;LCD_write_char( 0, 0b10000000 );}
;
; }
; */
; for(;i<255;i--)
xjmp L83
L80:
.dbline 456
.dbline 457
movw R24,R28
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R18,z+0
clr R19
subi R18,208 ; offset = 48
sbci R19,255
clr R16
clr R17
xcall _LCD_write_char
.dbline 458
L81:
.dbline 455
dec R20
L83:
.dbline 455
cpi R20,255
brlo L80
.dbline -2
L74:
adiw R28,6
xcall pop_gset5
.dbline 0 ; func end
ret
.dbsym l k 1 c
.dbsym l p 0 A[6:6]c
.dbsym r i 20 c
.dbsym r s 22 i
.dbsym r z 10 c
.dbsym r Y 14 c
.dbsym r X 12 c
.dbend
.dbfunc e LCD_init _LCD_init fV
.even
_LCD_init::
.dbline -1
.dbline 465
; {
; LCD_write_char( 0, p[i]+0b00110000 );
; }}
;
;
;
;
;
; void LCD_init(void) //液晶初始化
; {
.dbline 466
; delay_nms(15);
ldi R16,15
ldi R17,0
xcall _delay_nms
.dbline 467
; LCD_write_char(0x28,0); //4位显示
clr R18
clr R19
ldi R16,40
ldi R17,0
xcall _LCD_write_char
.dbline 468
; LCD_write_char(0x0c,0); //显示开
clr R18
clr R19
ldi R16,12
ldi R17,0
xcall _LCD_write_char
.dbline 469
; LCD_write_char(0x01,0); //清屏
clr R18
clr R19
ldi R16,1
ldi R17,0
xcall _LCD_write_char
.dbline -2
L84:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_write_string _LCD_write_string fV
; s -> R20,R21
; Y -> R10
; X -> R22
.even
_LCD_write_string::
xcall push_gset3
mov R10,R18
mov R22,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 472
; }
; void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
; {
.dbline 473
; LCD_set_xy( X, Y ); //写地址
mov R18,R10
mov R16,R22
xcall _LCD_set_xy
xjmp L87
L86:
.dbline 476
.dbline 477
movw R30,R20
ldd R18,z+0
clr R19
clr R16
clr R17
xcall _LCD_write_char
.dbline 478
subi R20,255 ; offset = 1
sbci R21,255
.dbline 479
L87:
.dbline 475
;
; while (*s) // 写显示字符
movw R30,R20
ldd R2,z+0
tst R2
brne L86
.dbline -2
L85:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r s 20 pc
.dbsym r Y 10 c
.dbsym r X 22 c
.dbend
.dbfunc e LCD_set_xy _LCD_set_xy fV
; address -> R20
; y -> R20
; x -> R22
.even
_LCD_set_xy::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 482
; {
; LCD_write_char( 0, *s );
; s ++;
; }
; }
; void LCD_set_xy( unsigned char x, unsigned char y ) //写地址函数
; {
.dbline 484
; unsigned char address;
; if (y == 0) address = 0x80 + x;
tst R20
brne L90
.dbline 484
mov R20,R22
subi R20,128 ; addi 128
xjmp L91
L90:
.dbline 486
; else
; address = 0xc0 + x;
mov R20,R22
subi R20,64 ; addi 192
L91:
.dbline 487
; LCD_write_char( address, 0 );
clr R18
clr R19
mov R16,R20
clr R17
xcall _LCD_write_char
.dbline -2
L89:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r address 20 c
.dbsym r y 20 c
.dbsym r x 22 c
.dbend
.dbfunc e LCD_en_write _LCD_en_write fV
.even
_LCD_en_write::
.dbline -1
.dbline 490
; }
; void LCD_en_write(void) //液晶使能
; {
.dbline 491
; LCD_EN_PORT|=LCD_EN;
sbi 0x12,4
.dbline 492
; delay_nus(1);
ldi R16,1
ldi R17,0
xcall _delay_nus
.dbline 493
; LCD_EN_PORT&=~LCD_EN;
cbi 0x12,4
.dbline -2
L92:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_write_char _LCD_write_char fV
; data_temp -> R22,R23
; command_temp -> R20,R21
; data -> R12,R13
; command -> R10,R11
.even
_LCD_write_char::
xcall push_gset4
movw R12,R18
movw R10,R16
.dbline -1
.dbline 496
; }
; void LCD_write_char(unsigned command,unsigned data) // 写数据
; {
.dbline 498
; unsigned command_temp,data_temp;
; command_temp=command;
movw R20,R10
.dbline 499
; data_temp=data;
movw R22,R12
.dbline 500
; delay_nus(16);
ldi R16,16
ldi R17,0
xcall _delay_nus
.dbline 501
; if(command==0)
cpi R20,0
cpc R20,R21
brne L94
X2:
.dbline 502
; {
.dbline 503
; LCD_RS_PORT|=LCD_RS; //RS=1
sbi 0x12,6
.dbline 504
; LCD_DATA_PORT&=0XF0;
in R24,0x12
andi R24,240
out 0x12,R24
.dbline 505
; LCD_DATA_PORT|=(data_temp>>4)&0x0F; //写高四位
movw R24,R22
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
andi R24,15
andi R25,0
in R2,0x12
clr R3
or R2,R24
or R3,R25
out 0x12,R2
.dbline 506
; LCD_en_write();
xcall _LCD_en_write
.dbline 508
; //data_temp=data_temp<<4;
; LCD_DATA_PORT&=0XF0;
in R24,0x12
andi R24,240
out 0x12,R24
.dbline 509
; LCD_DATA_PORT|=data_temp&0x0F; //写低四位
movw R24,R22
andi R24,15
andi R25,0
in R2,0x12
clr R3
or R2,R24
or R3,R25
out 0x12,R2
.dbline 510
; LCD_en_write();
xcall _LCD_en_write
.dbline 511
; }
xjmp L95
L94:
.dbline 513
.dbline 514
cbi 0x12,6
.dbline 515
in R24,0x12
andi R24,240
out 0x12,R24
.dbline 516
movw R24,R20
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
andi R24,15
andi R25,0
in R2,0x12
clr R3
or R2,R24
or R3,R25
out 0x12,R2
.dbline 517
xcall _LCD_en_write
.dbline 519
in R24,0x12
andi R24,240
out 0x12,R24
.dbline 520
movw R24,R20
andi R24,15
andi R25,0
in R2,0x12
clr R3
or R2,R24
or R3,R25
out 0x12,R2
.dbline 521
xcall _LCD_en_write
.dbline 522
L95:
.dbline -2
L93:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r data_temp 22 i
.dbsym r command_temp 20 i
.dbsym r data 12 i
.dbsym r command 10 i
.dbend
.dbfunc e time_change _time_change fV
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -