.module num_led.c
.area lit(rom, con, rel)
_seg_table::
.byte 192,249
.byte 164,176
.byte 153,146
.byte 130,248
.byte 128,144
.byte 136,131
.byte 198,161
.byte 134,142
.dbfile C:\work\mega128\num_led\num_led.c
.dbsym e seg_table _seg_table A[16:16]c
.area data(ram, con, rel)
.dbfile C:\work\mega128\num_led\num_led.c
_led_buff::
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile C:\work\mega128\num_led\num_led.c
.blkb 2
.area idata
.byte 0,0
.area data(ram, con, rel)
.dbfile C:\work\mega128\num_led\num_led.c
.dbsym e led_buff _led_buff A[4:4]c
.area text(rom, con, rel)
.dbfile C:\work\mega128\num_led\num_led.c
.dbfunc e delay_1ms _delay_1ms fV
; i -> R16,R17
.even
_delay_1ms::
.dbline -1
.dbline 8
; #include
; #include
; #define xtal 4
; const unsigned char seg_table[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,
; 0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
; unsigned char led_buff[4]={0,0,0,0};
; void delay_1ms(void)
; {
.dbline 10
; unsigned int i;
; for(i=1;i ldi R16,1
ldi R17,0
xjmp L5
L2:
.dbline 11
L3:
.dbline 10
subi R16,255 ; offset = 1
sbci R17,255
L5:
.dbline 10
cpi R16,58
ldi R30,2
cpc R17,R30
brlo L2
.dbline -2
.dbline 12
; ;
; }
L1:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e led_display _led_display fV
; i -> R20
.even
_led_display::
xcall push_gset1
.dbline -1
.dbline 23
; /*void delay_ms(unsigned int n)
; {
; unsigned int i=0;
; while(i ; {
; delay_1ms();
; i++;
; }
; }*/
; void led_display(void)
; {
.dbline 25
; unsigned char i;
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline 26
; PORTA=0xff;
out 0x1b,R24
.dbline 27
; DDRC|=0xf0;
in R24,0x14
ori R24,240
out 0x14,R24
.dbline 28
; PORTC|=0xf0;
in R24,0x15
ori R24,240
out 0x15,R24
.dbline 29
; for(i=0;i clr R20
xjmp L10
L7:
.dbline 30
.dbline 31
ldi R24, ldi R25,>_led_buff
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
out 0x1b,R2
.dbline 32
mov R17,R20
subi R17,252 ; addi 4
ldi R16,1
xcall lsl8
mov R2,R16
com R2
in R3,0x15
and R3,R2
out 0x15,R3
.dbline 33
xcall _delay_1ms
.dbline 34
in R24,0x15
ori R24,240
out 0x15,R24
.dbline 35
L8:
.dbline 29
inc R20
L10:
.dbline 29
cpi R20,4
brlo L7
.dbline -2
.dbline 36
; {
; PORTA=led_buff[i];
; PORTC&=~(1 ; delay_1ms();
; PORTC|=0xf0;
; }
; }
L6:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e led_fill _led_fill fV
; i -> R20
; index -> R16
.even
_led_fill::
xcall push_gset1
.dbline -1
.dbline 38
; void led_fill(unsigned char index)
; {
.dbline 40
; unsigned char i;
; for(i=0;i clr R20
xjmp L15
L12:
.dbline 41
.dbline 42
mov R2,R20
clr R3
mov R30,R16
clr R31
add R30,R2
adc R31,R3
ldi R24, ldi R25,>_seg_table
add R30,R24
adc R31,R25
lpm R30,Z
ldi R24, ldi R25,>_led_buff
mov R26,R20
clr R27
add R26,R24
adc R27,R25
st x,R30
.dbline 43
L13:
.dbline 40
inc R20
L15:
.dbline 40
cpi R20,4
brlo L12
.dbline -2
.dbline 44
; {
; led_buff[i]=seg_table[index+i];
; }
; }
L11:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r index 16 c
.dbend
.dbfunc e main _main fV
; j -> R20
; i -> R22
.even
_main::
.dbline -1
.dbline 46
; void main(void)
; {
xjmp L18
L17:
.dbline 49
; unsigned char i,j;
; while(1)
; {
.dbline 50
; for(j=0;j clr R20
xjmp L23
L20:
.dbline 51
; {
.dbline 52
; led_fill(4*j);
ldi R24,4
mul R24,R20
mov R16,R0
xcall _led_fill
.dbline 53
; for(i=0;i clr R22
xjmp L27
L24:
.dbline 54
xcall _led_display
L25:
.dbline 53
inc R22
L27:
.dbline 53
cpi R22,200
brlo L24
.dbline 55
L21:
.dbline 50
inc R20
L23:
.dbline 50
cpi R20,4
brlo L20
.dbline 56
L18:
.dbline 48
xjmp L17
X0:
.dbline -2
.dbline 57
; led_display();
; }
; }
; }
L16:
.dbline 0 ; func end
ret
.dbsym r j 20 c
.dbsym r i 22 c
.dbend