📄 main.s
字号:
.module main.c
.area lit(rom, con, rel)
_FontLookup:
.byte 62,'Q
.byte 'I,'E
.byte 62
.byte 0,'B
.byte 127,64
.byte 0
.byte 'B,'a
.byte 'Q,'I
.byte 'F
.byte 33,'A
.byte 'E,'K
.byte 49
.byte 24,20
.byte 18,127
.byte 16
.byte 39,'E
.byte 'E,'E
.byte 57
.byte 60,'J
.byte 'I,'I
.byte 48
.byte 1,'q
.byte 9,5
.byte 3
.byte 54,'I
.byte 'I,'I
.byte 54
.byte 6,'I
.byte 'I,41
.byte 30
.byte 0,96
.byte 96,0
.byte 0
.byte 127,8
.byte 20,34
.byte 'A
.byte 0,54
.byte 54,0
.byte 0
.byte 0,'V
.byte 54,0
.byte 0
.byte 8,20
.byte 34,'A
.byte 0
.byte 20,20
.byte 20,20
.byte 20
.byte 0,'A
.byte 34,20
.byte 8
.byte 2,1
.byte 'Q,9
.byte 6
.byte 50,'I
.byte 'Y,'Q
.byte 62
.byte 126,17
.byte 17,17
.byte 126
.byte 127,'I
.byte 'I,'I
.byte 54
.byte 62,'A
.byte 'A,'A
.byte 34
.byte 127,'A
.byte 'A,34
.byte 28
.byte 127,'I
.byte 'I,'I
.byte 'A
.byte 127,9
.byte 9,9
.byte 1
.byte 62,'A
.byte 'I,'I
.byte 'z
.byte 127,8
.byte 8,8
.byte 127
.byte 0,'A
.byte 127,'A
.byte 0
.byte 32,64
.byte 'A,63
.byte 1
.byte 127,8
.byte 20,34
.byte 'A
.byte 127,64
.byte 64,64
.byte 64
.byte 127,2
.byte 12,2
.byte 127
.byte 127,4
.byte 8,16
.byte 127
.byte 62,'A
.byte 'A,'A
.byte 62
.byte 127,9
.byte 9,9
.byte 6
.byte 62,'A
.byte 'Q,33
.byte 94
.byte 127,9
.byte 25,41
.byte 'F
.byte 'F,'I
.byte 'I,'I
.byte 49
.byte 1,1
.byte 127,1
.byte 1
.byte 63,64
.byte 64,64
.byte 63
.byte 31,32
.byte 64,32
.byte 31
.byte 63,64
.byte 56,64
.byte 63
.byte 'c,20
.byte 8,20
.byte 'c
.byte 7,8
.byte 'p,8
.byte 7
.byte 'a,'Q
.byte 'I,'E
.byte 'C
.byte 0,127
.byte 'A,'A
.byte 0
.byte 'U,42
.byte 'U,42
.byte 'U
.byte 0,'A
.byte 'A,127
.byte 0
.byte 4,2
.byte 1,2
.byte 4
.byte 64,64
.byte 64,64
.byte 64
.byte 0,1
.byte 2,4
.byte 0
.byte 32,'T
.byte 'T,'T
.byte 'x
.byte 127,'H
.byte 'D,'D
.byte 56
.byte 56,'D
.byte 'D,'D
.byte 32
.byte 56,'D
.byte 'D,'H
.byte 127
.byte 56,'T
.byte 'T,'T
.byte 24
.byte 8,126
.byte 9,1
.byte 2
.byte 12,'R
.byte 'R,'R
.byte 62
.byte 127,8
.byte 4,4
.byte 'x
.byte 0,'D
.byte 125,64
.byte 0
.byte 32,64
.byte 'D,61
.byte 0
.byte 127,16
.byte 40,'D
.byte 0
.byte 0,'A
.byte 127,64
.byte 0
.byte 124,4
.byte 24,4
.byte 'x
.byte 124,8
.byte 4,4
.byte 'x
.byte 56,'D
.byte 'D,'D
.byte 56
.byte 124,20
.byte 20,20
.byte 8
.byte 8,20
.byte 20,24
.byte 124
.byte 124,8
.byte 4,4
.byte 8
.byte 'H,'T
.byte 'T,'T
.byte 32
.byte 4,63
.byte 'D,64
.byte 32
.byte 60,64
.byte 64,32
.byte 124
.byte 28,32
.byte 64,32
.byte 28
.byte 60,64
.byte 48,64
.byte 60
.byte 'D,40
.byte 16,40
.byte 'D
.byte 12,'P
.byte 'P,'P
.byte 60
.byte 'D,'d
.byte 'T,'L
.byte 'D
.dbfile E:\avr\RCtest/font.h
.dbsym s FontLookup _FontLookup A[385:77:5]kc
.area data(ram, con, rel)
.dbfile E:\avr\RCtest/font.h
_timer_count::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\avr\RCtest/font.h
.dbfile E:\avr\RCtest\main.c
.dbsym e timer_count _timer_count i
.area text(rom, con, rel)
.dbfile E:\avr\RCtest\main.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 33
; //ICC-AVR application builder : 2007-5-24 20:31:27
; // Target : M16
; // Crystal: 8.0000Mhz
;
; #include <iom16v.h>
; #include <macros.h>
; #include "font.h"
;
;
; #define LCD_DC_PIN 0x04 // PB2
; #define LCD_CE_PIN 0x02 // PB1
; #define SPI_MOSI_PIN 0x20 // PB5
; #define LCD_RST_PIN 0x01 // PB0
; #define SPI_CLK_PIN 0x80 // PB7
;
; #define X_Length 45
; #define X_Init 10
; #define Y_Init 2
;
; /*--------------------------------------------------------------------------------------------------
; Public function prototypes
; --------------------------------------------------------------------------------------------------*/
; void LcdInit ( void );
; void LcdClear ( void );
;
; static void LcdSend ( unsigned char, unsigned char);
; static void Delay ( void );
; void LcdGotoXY ( unsigned char, unsigned char );
;
; unsigned int timer_count=0;
;
; void port_init(void)
; {
.dbline 34
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 35
; DDRA = 0x00;
out 0x1a,R2
.dbline 36
; PORTB = 0x00;
out 0x18,R2
.dbline 37
; DDRB = 0x00;
out 0x17,R2
.dbline 38
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 39
; DDRC = 0x00;
out 0x14,R2
.dbline 40
; PORTD = 0x00;
out 0x12,R2
.dbline 41
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 49
; }
;
; //TIMER0 initialize - prescale:1
; // WGM: Normal
; // desired value: 32uSec
; // actual value: 32.000uSec (0.0%)
; void timer0_init(void)
; {
.dbline 50
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 51
; TCNT0 = 0x00; //set count
out 0x32,R2
.dbline 52
; OCR0 = 0xFE; //set compare
ldi R24,254
out 0x3c,R24
.dbline 53
; TCCR0 = 0x01; //start timer
ldi R24,1
out 0x33,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 76
jmp _timer0_comp_isr
.area text(rom, con, rel)
.dbfile E:\avr\RCtest\main.c
.dbfunc e timer0_comp_isr _timer0_comp_isr fV
.even
_timer0_comp_isr::
st -y,R2
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
.dbline -1
.dbline 58
; }
;
; #pragma interrupt_handler timer0_comp_isr:20
; void timer0_comp_isr(void)
; {
.dbline 60
; //compare occured TCNT0=OCR0
; TCNT0 = 0x00;
clr R2
out 0x32,R2
.dbline 61
; timer_count++;
lds R24,_timer_count
lds R25,_timer_count+1
adiw R24,1
sts _timer_count+1,R25
sts _timer_count,R24
.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 65
; }
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 67
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 68
; port_init();
xcall _port_init
.dbline 69
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 70
; GICR = 0x00;
out 0x3b,R2
.dbline 71
; TIMSK = 0x02; //timer interrupt sources
ldi R24,2
out 0x39,R24
.dbline 72
; SEI(); //re-enable interrupts
sei
.dbline -2
L4:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay _delay fV
; i -> R16,R17
; j -> R18
.even
_delay::
.dbline -1
.dbline 77
; //all peripherals are now initialized
; }
;
; void delay(void) //延时
; {
.dbline 78
; unsigned int i=0;
clr R16
clr R17
.dbline 79
; unsigned char j=0;
clr R18
.dbline 80
; for(i=1;i!=0;i++)
ldi R16,1
xjmp L9
L6:
.dbline 81
; {
.dbline 82
; for(j=1;j!=0;j++)
ldi R18,1
xjmp L13
L10:
.dbline 83
L11:
.dbline 82
inc R18
L13:
.dbline 82
tst R18
brne L10
.dbline 84
L7:
.dbline 80
subi R16,255 ; offset = 1
sbci R17,255
L9:
.dbline 80
cpi R16,0
cpc R16,R17
brne L6
X0:
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbsym r j 18 c
.dbend
.dbfunc e Delay100us _Delay100us fV
; i -> R20
; x -> R16
.even
_Delay100us::
xcall push_gset1
.dbline -1
.dbline 88
; ;
; }
; }
;
; void Delay100us(unsigned char x)
; {
.dbline 90
; unsigned char i; //4clock
; for(i=147;x!=0;x--)
ldi R20,147
xjmp L18
L19:
.dbline 91
L20:
.dbline 91
mov R24,R20
subi R24,1
mov R20,R24
tst R24
brne L19
L16:
.dbline 90
dec R16
L18:
.dbline 90
tst R16
brne L20
.dbline -2
L14:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r x 16 c
.dbend
.dbfunc e Delay1ms _Delay1ms fV
; n -> R20,R21
.even
_Delay1ms::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 94
; while(--i); //5 * i clock
; }
; void Delay1ms( unsigned int n)
; {
.dbline 95
xjmp L26
L23:
.dbline 95
.dbline 96
ldi R16,10
xcall _Delay100us
.dbline 97
L24:
.dbline 95
subi R20,1
sbci R21,0
L26:
.dbline 95
; for (;n!=0;n--){
cpi R20,0
cpc R20,R21
brne L23
X1:
.dbline -2
L22:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r n 20 i
.dbend
.dbfunc e Delay1s _Delay1s fV
; m -> R20,R21
.even
_Delay1s::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 100
; Delay100us(10);
; }
; }
; void Delay1s( unsigned int m) // m <= 6 ,when m==7, it is 1.
; {
.dbline 101
; m=m*40;
ldi R16,40
ldi R17,0
movw R18,R20
xcall empy16s
movw R20,R16
.dbline 102
xjmp L31
L28:
.dbline 102
.dbline 103
ldi R16,250
xcall _Delay100us
.dbline 104
L29:
.dbline 102
subi R20,1
sbci R21,0
L31:
.dbline 102
; for (;m!=0;m--){
cpi R20,0
cpc R20,R21
brne L28
X2:
.dbline -2
L27:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r m 20 i
.dbend
.area lit(rom, con, rel)
_X_TAB::
.byte 126,10
.byte 10,10
.byte 0,126
.byte 64,64
.byte 126,0
.byte 126,'B
.byte 'B,'B
.byte 0,126
.byte 24,36
.byte 'B,0
.byte 0,0
.byte 'B,126
.byte 2,0
.byte 124,18
.byte 18,124
.byte 0,126
.byte 10,10
.byte 14,0
.byte 124,18
.byte 18,124
.byte 0,126
.byte 8,16
.byte 126
.dbsym e X_TAB _X_TAB A[45:45]kc
.area text(rom, con, rel)
.dbfile E:\avr\RCtest\main.c
.dbfunc e LcdInit _LcdInit fV
.even
_LcdInit::
.dbline -1
.dbline 135
; Delay100us(250);
; }
; }
;
;
; /*--------------------------------------------------------------------------------------------------
; Global Variables
; 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,10个
; --------------------------------------------------------------------------------------------------*/
; //字模 "FUCK JAPAN"
; unsigned char const X_TAB[] =
; {0x7E,0x0A,0x0A,0x0A,0x00,0x7E,0x40,0x40,0x7E,0x00,0x7E,0x42,0x42,0x42,0x00,0x7E,0x18,0x24,0x42,0x00,0x00,0x00,0x42,0x7E,0x02,0x00,0x7C,0x12,0x12,0x7C,
; 0x00,0x7E,0x0A,0x0A,0x0E,0x00,0x7C,0x12,0x12,0x7C,0x00,0x7E,0x08,0x10,0x7E};
;
;
;
;
;
;
;
; ////////////////////////////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////////////////////////////
;
; /*--------------------------------------------------------------------------------------------------
; Name : LcdInit
; Description : Performs MCU SPI & LCD controller initialization.
; Argument(s) : None.
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; void LcdInit( void )
; {
.dbline 138
; //unsigned char Clear;
; // Pull-up on reset pin,上电复位端口,此时为高,不复位;
; PORTB |= LCD_RST_PIN;
sbi 0x18,0
.dbline 141
;
; // Set output bits on port B,设置输出口;
; DDRB |= LCD_RST_PIN | LCD_DC_PIN | LCD_CE_PIN | SPI_MOSI_PIN | SPI_CLK_PIN;
in R24,0x17
ori R24,167
out 0x17,R24
.dbline 143
;
; Delay();
xcall _Delay
.dbline 146
;
; // Toggle display reset pin.
; PORTB &= ~LCD_RST_PIN; //上电复位;
cbi 0x18,0
.dbline 147
; Delay();
xcall _Delay
.dbline 148
; PORTB |= LCD_RST_PIN; //复位完;
sbi 0x18,0
.dbline 151
;
; // SPI初始化;Enable SPI port: No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4
; SPCR = BIT(SPE)|BIT(MSTR); //使能SPI,主机模式;
ldi R24,80
out 0xd,R24
.dbline 156
; //SPSR = 0x00; //似乎不用这几句也能正常运行;
; //Clear= SPSR;
; //Clear= SPDR;
; // Disable LCD controller
; PORTB |= LCD_CE_PIN;
sbi 0x18,1
.dbline 158
;
; LcdSend( 0x21, 0 ); // LCD Extended Commands.
clr R18
ldi R16,33
xcall _LcdSend
.dbline 159
; LcdSend( 0xC8, 0 ); // Set LCD Vop (Contrast).
clr R18
ldi R16,200
xcall _LcdSend
.dbline 160
; LcdSend( 0x06, 0 ); // Set Temp coefficent.
clr R18
ldi R16,6
xcall _LcdSend
.dbline 161
; LcdSend( 0x13, 0 ); // LCD bias mode 1:48.
clr R18
ldi R16,19
xcall _LcdSend
.dbline 162
; LcdSend( 0x20, 0 ); // LCD Standard Commands, Horizontal addressing mode.
clr R18
ldi R16,32
xcall _LcdSend
.dbline 163
; LcdSend( 0x0C, 0 ); // LCD in normal mode.
clr R18
ldi R16,12
xcall _LcdSend
.dbline 165
;
; LcdClear();
xcall _LcdClear
.dbline -2
L32:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LcdClear _LcdClear fV
; i -> R20,R21
.even
_LcdClear::
xcall push_gset1
.dbline -1
.dbline 177
;
; }
;
;
; /*--------------------------------------------------------------------------------------------------
; Name : LcdClear
; Description : Clears the display.
; Argument(s) : None.
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; void LcdClear(void)
; {
.dbline 180
; unsigned int i;
;
; LcdSend(0x0c, 0);
clr R18
ldi R16,12
xcall _LcdSend
.dbline 181
; LcdSend(0x80, 0); //此时默认操作为清屏
clr R18
ldi R16,128
xcall _LcdSend
.dbline 183
;
; for (i=0; i<504; i++)
clr R20
clr R21
xjmp L37
L34:
.dbline 184
ldi R18,1
clr R16
xcall _LcdSend
L35:
.dbline 183
subi R20,255 ; offset = 1
sbci R21,255
L37:
.dbline 183
cpi R20,248
ldi R30,1
cpc R21,R30
brlo L34
.dbline -2
L33:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbend
.dbfunc e LcdGotoXY _LcdGotoXY fV
; Y -> R22
; X -> R20
.even
_LcdGotoXY::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 196
; LcdSend(0, 1);
; }
;
;
;
; /*--------------------------------------------------------------------------------------------------
; Name : LcdGotoXY 设置块坐标
; Description : Sets cursor location to xy location corresponding to basic font size.
; Argument(s) : x, y -> Coordinate for new cursor position. Range: 1,1 .. 14,6
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; void LcdGotoXY(unsigned char X, unsigned char Y)
; {
.dbline 197
; LcdSend(0x40 | Y, 0); // column
clr R18
mov R16,R22
ori R16,64
xcall _LcdSend
.dbline 198
; LcdSend(0x80 | X, 0); // row
clr R18
mov R16,R20
ori R16,128
xcall _LcdSend
.dbline -2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -