📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile E:\Program\gps\main.c
.dbfunc e main _main fV
; i -> R20,R21
.even
_main::
.dbline -1
.dbline 47
; /*
; ###############################################################################
; Include Part
; ###############################################################################
; */
; #include <iom32v.h> // mega16 register definition file
; #include <lcd.h> // LCD driver file
; #include "def.h" // Type definition file
; #include <macros.h>
; #include <serial.h> //serial port driver file
;
;
; /*
; ##############################################################
; define part
; ##############################################################
; */
; // char rcv_buf[1024];
; char time[10];
; char status;
; char latitude[9];
; char NSind;
; char longtitude[10];
; char EWind;
; char date[6];
;
;
; /*
; ###############################################################################
; Function Prototype Definition Part
; ###############################################################################
; */
; void port_init(void);
; void init_devices(void);
; void GpsDataParse(void);
; void Parse (void);
; //void convert (void);
;
;
;
; /*
; ###############################################################################
; Function Implementation Part
; ###############################################################################
; */
; void main (void)
; {
.dbline 48
; int i=0;
clr R20
clr R21
.dbline 50
; //initial the MCU
; init_devices();
xcall _init_devices
xjmp L3
L2:
.dbline 52
.dbline 54
xcall _GpsDataParse
.dbline 55
xcall _display
.dbline 56
L3:
.dbline 51
xjmp L2
X0:
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbend
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 62
; while (1)
; {
; // for (i=0;i<3000;i++);
; GpsDataParse(); //get data
; display(); //display
; }
;
; }
;
;
; void port_init(void)
; {
.dbline 63
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 64
; DDRA = 0xFC;
ldi R24,252
out 0x1a,R24
.dbline 65
; PORTB = 0x00;
out 0x18,R2
.dbline 66
; DDRB = 0x00;
out 0x17,R2
.dbline 67
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 68
; DDRC = 0x83;
ldi R24,131
out 0x14,R24
.dbline 69
; PORTD = 0x00;
out 0x12,R2
.dbline 70
; DDRD = 0x9C;
ldi R24,156
out 0x11,R24
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 75
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 77
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 78
; port_init();
xcall _port_init
.dbline 79
; uart0_init();
xcall _uart0_init
.dbline 81
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 82
; GICR = 0x00;
out 0x3b,R2
.dbline 83
; TIMSK = 0x00; //timer interrupt sources
out 0x39,R2
.dbline 85
; //all peripherals are now initialized
; SEI();
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e GpsDataParse _GpsDataParse fV
; head -> y+0
; temp -> R20
.even
_GpsDataParse::
xcall push_gset1
sbiw R28,3
.dbline -1
.dbline 88
; }
; void GpsDataParse(void)
; {
.dbline 93
; char head[3];
; char temp;
;
; //CLI();
; temp=Read_buf();
xcall _Read_buf
mov R20,R16
xjmp L9
L8:
.dbline 95
xcall _Read_buf
mov R20,R16
L9:
.dbline 94
cpi R20,36
brne L8
.dbline 97
xcall _Read_buf
.dbline 98
xcall _Read_buf
mov R20,R16
.dbline 101
xcall _Read_buf
std y+0,R16
.dbline 102
xcall _Read_buf
std y+1,R16
.dbline 103
xcall _Read_buf
std y+2,R16
.dbline 104
ldd R24,y+0
cpi R24,82
brne L13
ldd R24,y+1
cpi R24,77
brne L13
cpi R16,67
brne L13
.dbline 105
.dbline 106
xcall _Parse
.dbline 107
L13:
.dbline -2
L7:
adiw R28,3
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym l head 0 A[3:3]c
.dbsym r temp 20 c
.dbend
.dbfunc e Parse _Parse fV
; i -> R20,R21
; temp -> R22
.even
_Parse::
xcall push_gset2
.dbline -1
.dbline 117
; while (temp != '$')
; temp=Read_buf();
;
; temp=Read_buf();//first and second character are "GPXXX"
; temp=Read_buf();
;
; //get the header
; head[0]=Read_buf();
; head[1]=Read_buf();
; head[2]=Read_buf();
; if(head[0]=='R' && head[1]=='M' && head[2]=='C')
; {
; Parse ();
; return ;
; }
; }
;
; /**********************************************************************
; * get information from GPRMC
; *Description: need array to place time,date, latitude,longtitude
; size of the array
; ************************************************************************/
; void Parse (void)
; {
.dbline 119
; char temp;
; int i=0;
clr R20
clr R21
.dbline 122
;
; //read time
; temp=Read_buf();// jump over ','
xcall _Read_buf
.dbline 123
; temp=Read_buf();
xcall _Read_buf
mov R22,R16
xjmp L19
L18:
.dbline 125
.dbline 126
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
ldi R24,<_time
ldi R25,>_time
movw R30,R2
add R30,R24
adc R31,R25
std z+0,R22
.dbline 127
xcall _Read_buf
mov R22,R16
.dbline 128
L19:
.dbline 124
; while(i<10)
cpi R20,10
ldi R30,0
cpc R21,R30
brlt L18
.dbline 132
; {
; time[i++]=temp;
; temp=Read_buf();
; }
;
; // convert ();
; //read status
; status=Read_buf();
xcall _Read_buf
sts _status,R16
.dbline 133
; if (status=='V')
cpi R16,86
brne L21
.dbline 134
; return;
xjmp L17
L21:
.dbline 137
;
; //read latitude
; temp=Read_buf();//read the ','
xcall _Read_buf
mov R22,R16
.dbline 138
; i=0;
clr R20
clr R21
xjmp L24
L23:
.dbline 140
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
push R2
push R3
xcall _Read_buf
pop R3
pop R2
ldi R24,<_latitude
ldi R25,>_latitude
movw R30,R2
add R30,R24
adc R31,R25
std z+0,R16
L24:
.dbline 139
; while(i<9)
cpi R20,9
ldi R30,0
cpc R21,R30
brlt L23
.dbline 143
; latitude[i++]=Read_buf();
;
; //read NSindicator
; temp=Read_buf();//read the ','
xcall _Read_buf
.dbline 144
; NSind=Read_buf();
xcall _Read_buf
sts _NSind,R16
.dbline 145
; temp=Read_buf();//read the ','
xcall _Read_buf
mov R22,R16
.dbline 148
;
; //read longtitude
; i=0;
clr R20
clr R21
xjmp L27
L26:
.dbline 150
movw R2,R20
subi R20,255 ; offset = 1
sbci R21,255
push R2
push R3
xcall _Read_buf
pop R3
pop R2
ldi R24,<_longtitude
ldi R25,>_longtitude
movw R30,R2
add R30,R24
adc R31,R25
std z+0,R16
L27:
.dbline 149
; while(i<10)
cpi R20,10
ldi R30,0
cpc R21,R30
brlt L26
.dbline 153
; longtitude[i++]=Read_buf();
;
; //read EWindicator
; temp=Read_buf();//read the ','
xcall _Read_buf
mov R22,R16
.dbline 154
; EWind=Read_buf();
xcall _Read_buf
sts _EWind,R16
.dbline 155
; i=0;
clr R20
clr R21
xjmp L30
L29:
.dbline 157
; while (i<3)
; {
.dbline 158
; temp=Read_buf();//read the ','
xcall _Read_buf
mov R22,R16
xjmp L33
L32:
.dbline 160
xcall _Read_buf
mov R22,R16
L33:
.dbline 159
cpi R22,44
brne L32
.dbline 161
subi R20,255 ; offset = 1
sbci R21,255
.dbline 162
L30:
.dbline 156
cpi R20,3
ldi R30,0
cpc R21,R30
brlt L29
.dbline 163
; while (temp!=',')
; temp=Read_buf();
; i++;
; }
; for (i=0;i<6;i++)
clr R20
clr R21
L35:
.dbline 164
.dbline 165
xcall _Read_buf
ldi R24,<_date
ldi R25,>_date
movw R30,R20
add R30,R24
adc R31,R25
std z+0,R16
.dbline 166
L36:
.dbline 163
subi R20,255 ; offset = 1
sbci R21,255
.dbline 163
cpi R20,6
ldi R30,0
cpc R21,R30
brlt L35
.dbline -2
L17:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbsym r temp 22 c
.dbend
.area bss(ram, con, rel)
.dbfile E:\Program\gps\main.c
_date::
.blkb 6
.dbsym e date _date A[6:6]c
_EWind::
.blkb 1
.dbsym e EWind _EWind c
_longtitude::
.blkb 10
.dbsym e longtitude _longtitude A[10:10]c
_NSind::
.blkb 1
.dbsym e NSind _NSind c
_latitude::
.blkb 9
.dbsym e latitude _latitude A[9:9]c
_status::
.blkb 1
.dbsym e status _status c
_time::
.blkb 10
.dbsym e time _time A[10:10]c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -