📄 m128_my.s
字号:
.module m128_my.c
.area data(ram, con, rel)
_v::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbsym e v _v I
_time::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbsym e time _time i
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 11
; //ICC-AVR application builder : 2007-2-21 下午 09:30:23
; // Target : M128
; // Crystal: 8.0000Mhz
;
; #include <iom128v.h>
; #include <macros.h>
; int v=0;
; unsigned int time=0;
;
; void port_init(void)
; {
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e adc_init _adc_init fV
.even
_adc_init::
.dbline -1
.dbline 18
;
; }
;
; //ADC initialize
; // Conversion time: 3uS
; void adc_init(void)
; {
.dbline 19
; ADCSRA = 0x00; //disable adc
clr R2
out 0x6,R2
.dbline 20
; ADMUX = 0x00; //select adc input 0
out 0x7,R2
.dbline 21
; ACSR = 0x80;
ldi R24,128
out 0x8,R24
.dbline 22
; ADCSRA = 0xE9;
ldi R24,233
out 0x6,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 84
jmp _adc_isr
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e adc_isr _adc_isr fV
.even
_adc_isr::
st -y,R2
st -y,R3
st -y,R4
st -y,R5
in R2,0x3f
st -y,R2
.dbline -1
.dbline 27
; }
;
; #pragma interrupt_handler adc_isr:22
; void adc_isr(void)
; {
.dbline 29
; //conversion complete, read value (int) using...
; v=ADCL; //Read 8 low bits first (important)
in R2,0x4
clr R3
sts _v+1,R3
sts _v,R2
.dbline 30
; v|=(int)ADCH << 8; //read 2 high bits and shift into top byte
in R2,0x5
clr R3
mov R3,R2
clr R2
lds R4,_v
lds R5,_v+1
or R4,R2
or R5,R3
sts _v+1,R5
sts _v,R4
.dbline -2
L3:
ld R2,y+
out 0x3f,R2
ld R5,y+
ld R4,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 37
;
;
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 39
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 40
; XDIV = 0x00; //xtal divider
clr R2
out 0x3c,R2
.dbline 41
; XMCRA = 0x00; //external memory
sts 109,R2
.dbline 42
; port_init();
xcall _port_init
.dbline 43
; adc_init();
xcall _adc_init
.dbline 44
; timer0_init();
xcall _timer0_init
.dbline 46
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 47
; EICRA = 0x0A; //extended ext ints
ldi R24,10
sts 106,R24
.dbline 48
; EICRB = 0x00; //extended ext ints
out 0x3a,R2
.dbline 49
; EIMSK = 0x03;
ldi R24,3
out 0x39,R24
.dbline 50
; TIMSK = 0x01; //timer interrupt sources
ldi R24,1
out 0x37,R24
.dbline 51
; ETIMSK = 0x00; //extended timer interrupt sources
sts 125,R2
.dbline 52
; SEI(); //re-enable interrupts
sei
.dbline -2
L4:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 63
; //all peripherals are now initialized
; }
;
;
;
; //TIMER0 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value: 1.000mSec (0.0%)
; void timer0_init(void)
; {
.dbline 64
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 65
; ASSR = 0x00; //set async mode
out 0x30,R2
.dbline 66
; TCNT0 = 0x83; //set count
ldi R24,131
out 0x32,R24
.dbline 67
; OCR0 = 0x7D;
ldi R24,125
out 0x31,R24
.dbline 68
; TCCR0 = 0x04; //start timer
ldi R24,4
out 0x33,R24
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 64
jmp _timer0_ovf_isr
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
.even
_timer0_ovf_isr::
st -y,R24
st -y,R25
in R24,0x3f
st -y,R24
.dbline -1
.dbline 73
; }
;
; #pragma interrupt_handler timer0_ovf_isr:17
; void timer0_ovf_isr(void)
; {
.dbline 74
; TCNT0 = 0x83; //reload counter value
ldi R24,131
out 0x32,R24
.dbline 75
; time++;
lds R24,_time
lds R25,_time+1
adiw R24,1
sts _time+1,R25
sts _time,R24
.dbline -2
L6:
ld R24,y+
out 0x3f,R24
ld R25,y+
ld R24,y+
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 4
jmp _int0_isr
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e int0_isr _int0_isr fV
.even
_int0_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 79
; }
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
.dbline 81
; //external interupt on INT0
; EIMSK = 0x00;
clr R2
out 0x39,R2
.dbline 82
; PORTB=0xfe;
ldi R24,254
out 0x18,R24
.dbline -2
L7:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 8
jmp _int1_isr
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e int1_isr _int1_isr fV
.even
_int1_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 87
; }
;
; #pragma interrupt_handler int1_isr:3
; void int1_isr(void)
; {
.dbline 89
; //external interupt on INT1
; EIMSK = 0x00;
clr R2
out 0x39,R2
.dbline 90
; PORTB=0xfd;
ldi R24,253
out 0x18,R24
.dbline -2
L8:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e asc_tran1 _asc_tran1 fV
; asc_p -> y+4
; y -> R20
; x -> R22
.even
_asc_tran1::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 97
; }
;
;
; /* 传送ASCII字母到LCD */
; /* x:0x00~0x0f y:0~64 */
; void asc_tran1(unsigned char x,unsigned char y,unsigned char *asc_p)
; {
.dbline 98
; x+=4;
subi R22,252 ; addi 4
.dbline 100
; //while((*asc_p)!=0)
; {
.dbline 101
; ocmj_write(0xf1);
ldi R16,241
ldi R17,0
xcall _ocmj_write
.dbline 102
; ocmj_write(x);
mov R16,R22
clr R17
xcall _ocmj_write
.dbline 103
; ocmj_write(y);
mov R16,R20
clr R17
xcall _ocmj_write
.dbline 104
; ocmj_write(*asc_p);
ldd R30,y+4
ldd R31,y+5
ldd R16,z+0
clr R17
xcall _ocmj_write
.dbline 105
; asc_p++;
ldd R24,y+4
ldd R25,y+5
adiw R24,1
std y+5,R25
std y+4,R24
.dbline 106
; if (x<0x13)
cpi R22,19
brsh L10
.dbline 107
; x++;
inc R22
xjmp L11
L10:
.dbline 109
; else
; {
.dbline 110
; x=0x04;
ldi R22,4
.dbline 111
; y+=8;
subi R20,248 ; addi 8
.dbline 112
; }
L11:
.dbline 113
; }
.dbline -2
L9:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l asc_p 4 pc
.dbsym r y 20 c
.dbsym r x 22 c
.dbend
.area lit(rom, con, rel)
L13:
.byte 48,49
.byte 50,51
.byte 52,53
.byte 54,55
.byte 56,57
.byte 45,43
.area text(rom, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
.dbfunc e main _main fI
; j -> R20
; code -> y+2
; a -> R22,R23
; i -> R10,R11
; x -> R12,R13
.even
_main::
sbiw R28,14
.dbline -1
.dbline 119
; }
;
;
;
; main()
; {
.dbline 120
; int x=0,a=0,i=0;
clr R12
clr R13
.dbline 120
clr R22
clr R23
.dbline 120
clr R10
clr R11
.dbline 121
; char j=0;
clr R20
.dbline 122
; char code[]={'0','1','2','3','4','5','6','7','8','9','-','+',};
ldi R24,<L13
ldi R25,>L13
movw R30,R28
adiw R30,2
ldi R16,12
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
xcall asgncblk
.dbline 123
; DDRD=0x00;
clr R2
out 0x11,R2
.dbline 124
; PORTD=0x03;
ldi R24,3
out 0x12,R24
.dbline 127
;
; //while(1);
; init_devices();
xcall _init_devices
.dbline 129
;
; ocmj_init();//初始化
xcall _ocmj_init
.dbline 130
; ocmj_write(0xf4);//清屏
ldi R16,244
ldi R17,0
xcall _ocmj_write
.dbline 131
; hz_tran(3,0,"数模转换");//传送内部汉字
ldi R24,<L14
ldi R25,>L14
std y+1,R25
std y+0,R24
clr R18
clr R19
ldi R16,3
ldi R17,0
xcall _hz_tran
.dbline 135
;
;
;
; DDRB=0x03;
ldi R24,3
out 0x17,R24
.dbline 136
; PORTB=0xfc;
ldi R24,252
out 0x18,R24
xjmp L16
L15:
.dbline 139
; //while(1);
; while(1)
; { for(j=0;j<128;j++)
.dbline 139
clr R20
xjmp L21
L18:
.dbline 140
; { x=v;
.dbline 140
lds R12,_v
lds R13,_v+1
.dbline 141
; pset(j,x/17);
ldi R18,17
ldi R19,0
movw R16,R12
xcall div16s
movw R18,R16
mov R16,R20
clr R17
xcall _pset
.dbline 142
; for(i=0;i<7;i++)
clr R10
clr R11
L22:
.dbline 143
; {
.dbline 144
; if (x<0)
movw R24,R12
cpi R24,0
ldi R30,0
cpc R25,R30
brge L26
.dbline 145
; {x=-x;asc_tran1(9-7,50,& code[10]);}
.dbline 145
com R24
com R25
subi R24,0xFF
sbci R25,0xFF
movw R12,R24
.dbline 145
movw R24,R28
adiw R24,12
std y+1,R25
std y+0,R24
ldi R18,50
ldi R16,2
xcall _asc_tran1
.dbline 145
L26:
.dbline 146
ldi R18,10
ldi R19,0
movw R16,R12
xcall mod16s
movw R22,R16
.dbline 147
movw R24,R28
adiw R24,2
movw R2,R22
add R2,R24
adc R3,R25
std y+1,R3
std y+0,R2
ldi R18,50
ldi R16,10
sub R16,R10
sbc R17,R11
xcall _asc_tran1
.dbline 148
ldi R18,10
ldi R19,0
movw R16,R12
xcall div16s
movw R12,R16
.dbline 149
L23:
.dbline 142
movw R24,R10
adiw R24,1
movw R10,R24
.dbline 142
cpi R24,7
ldi R30,0
cpc R25,R30
brlt L22
.dbline 150
; a=x%10;
; asc_tran1(10-i,50,& code[a]);
; x=x/10;
; } //for
; delay_ms(1);
ldi R16,1
ldi R17,0
xcall _delay_ms
.dbline 151
; if (time>100)
ldi R24,100
ldi R25,0
lds R2,_time
lds R3,_time+1
cp R24,R2
cpc R25,R3
brsh L29
.dbline 152
; { EIMSK = 0x03;
.dbline 152
ldi R24,3
out 0x39,R24
.dbline 153
; PORTB=0xfc;
ldi R24,252
out 0x18,R24
.dbline 154
; }
L29:
.dbline 157
L19:
.dbline 139
inc R20
L21:
.dbline 139
cpi R20,128
brsh X1
xjmp L18
X1:
.dbline 158
ldi R16,244
ldi R17,0
xcall _ocmj_write
.dbline 159
L16:
.dbline 138
xjmp L15
X0:
.dbline -2
L12:
adiw R28,14
.dbline 0 ; func end
ret
.dbsym r j 20 c
.dbsym l code 2 A[12:12]c
.dbsym r a 22 I
.dbsym r i 10 I
.dbsym r x 12 I
.dbend
.area data(ram, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
L14:
.blkb 9
.area idata
.byte 202,253,196,163,215,170,187,187,0
.area data(ram, con, rel)
.dbfile D:\PROTEU~1.7\PROTEU~1.7\JOHU\a___EWTS82\m128_my.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -