;*******************************************************************************
org 0000
ljmp start
org 0003h ;功能选择键中断子程序
ljmp int00
org 0013h
ljmp start
;*******************************************************************************
org 0060h ;定义起始地址
start: mov sp,#60h ;sp指针
mov func_s,#0 ;功能设置为bjt
mov tmod,#20h ;方式2,自动装入8位定时器.
mov th1,#0fah ;4800bps 11.0592mhz=0fah
mov tl1,#0 ;4800bps
clr ie.3 ;中断et1,clr
setb tcon.6 ;开定时器1
mov scon,#01110000b ;8位uart/可接收
setb ie.0 ;ex0 on
setb ie.2 ;ex1 on
setb ie.7 ;允许中断
;*******************************************************************************
da_rx: mov 0ah,#0
w_disp: jb ri,c_ri
mov r5,#005h
dl_3: mov r3,#010h ;delay time
dl_1: mov r4,#010h
dl_2: jb ri,c_ri
djnz r4,dl_2
djnz r3,dl_1
djnz r5,dl_3
call disp
mov f_tmp,#0
jmp w_disp
c_ri: clr ri
mov a,0ah
cjne a,#0,wram
mov a,sbuf
cjne a,#24h,chu2
mov 09h,#80h
mov 0ah,#0fh
ljmp wram
chu2: cjne a,#47h,chu3
mov 09h,#80h
mov 0ah,#0fh
ljmp wram
chu3: cjne a,#50h,chu4
mov 09h,#80h
mov 0ah,#0fh
ljmp wram
chu4: mov 0ah,#0
ljmp w_disp
wram: mov 08h,sbuf
mov a,08h
cjne a,#2ah,wram1
inc 09h
mov r0,09h
mov @r0,08h
mov_ff: inc 09h
mov r0,09h
mov @r0,#0ffh
mov a,09h
cjne a,#0,mov_ff
mov r0,09h
mov @r0,08h
;------------------------------------------------------------------------------
call dspram ;数据处理
mov 0ah,#0
ljmp w_disp
;------------------------------------------------------------------------------
wram1: mov r0,09h
mov @r0,08h
inc 09h
mov a,09h
cjne a,#0ffh,w_disp
mov 0ah,#0
ljmp w_disp
;*******************************************************************************
;###############################################################################
int00: clr ie.7
mov r3,#200
int08: setb func
nop
jb func,int07
djnz r3,int08
inc func_s
mov a,func_s
cjne a,#4,int_l
mov func_s,#0
int_l: setb func
mov f_tmp,#1
jnb func,int_l
int07: setb ie.7
reti
;*******************************************************************************
;******************************************************************************
j_rmc: jmp d_rmc
;##############################################################################
dspram: mov r0,#83h ;$gpgga
cjne @r0,#47h,j_rmc
inc r0
cjne @r0,#47h,j_rmc
inc r0
cjne @r0,#41h,j_rmc
;==============================================================================
mov r0,#80h ;经度表 gpgga
mov r1,#2 ;第2个","
r_jd: cjne @r0,#2ch,j_hi ;","
djnz r1,j_hi
jmp r_j_d
j_hi: inc r0
jmp r_jd
r_j_d: mov r1,#lat_1
j_l: inc r0
cjne @r0,#2eh,r_j_l ; "."
jmp j_r_ok
r_j_l: inc r1
mov a,@r0
mov @r1,a
jmp j_l
j_r_ok: inc r0
inc r1
mov a,@r0
mov @r1,a
inc r0
inc r1
mov a,@r0
mov @r1,a
inc r0
inc r0
inc r0
inc r0
inc r1
mov a,@r0 ;n
mov @r1,a
;==============================================================================
mov r0,#80h ;纬度
mov r1,#4 ;第4个","
r_wd: cjne @r0,#2ch,w_hi ;","
djnz r1,w_hi
jmp r_w_d
w_hi: inc r0
jmp r_wd
r_w_d: mov r1,#lon_1-1
w_l: inc r0
cjne @r0,#2eh,r_w_l ; "."
jmp w_r_ok
r_w_l: inc r1
mov a,@r0
mov @r1,a
jmp w_l
w_r_ok: inc r0
inc r1
mov a,@r0
mov @r1,a
inc r0
inc r1
mov a,@r0
mov @r1,a
inc r0
inc r0
inc r0
inc r0
inc r1
mov a,@r0 ;e
mov @r1,a
;==============================================================================
; ;星数 gpgga
;==============================================================================
mov hi_1,#0 ;高度
mov hi_2,#0
mov hi_3,#0
mov hi_4,#0
mov r0,#80h
mov r1,#10 ;第10个","
r_high: cjne @r0,#2ch,r_hi ;","
djnz r1,r_hi
jmp r_hi_d
r_hi: inc r0
jmp r_high
r_hi_d: dec r0
cjne @r0,#2eh,r_hi_d ;"."
mov r1,#hi_4+1
hi_l: dec r0
cjne @r0,#2ch,r_hi_l
jmp hi_r_ok
r_hi_l: dec r1
mov a,@r0
mov @r1,a
jmp hi_l
hi_r_ok:
;==============================================================================
mov x_1,#0 ;星数
mov x_2,#0
mov r0,#80h
mov r1,#8 ;第8个","
r_star: cjne @r0,#2ch,x_hi ;","
djnz r1,x_hi
jmp x_hi_d
x_hi: inc r0
jmp r_star
x_hi_d: mov r1,#x_2+1
hi_x: dec r0
cjne @r0,#2ch,x_hi_l
jmp x_r_ok
x_hi_l: dec r1
mov a,@r0
mov @r1,a
jmp hi_x
x_r_ok: ret
;******************************************************************************
;******************************************************************************
j_gsa: jmp d_gsa
;******************************************************************************
d_rmc: mov r0,#83h ;$gprmc
cjne @r0,#52h,j_gsa
inc r0
cjne @r0,#4dh,j_gsa
inc r0
cjne @r0,#43h,j_gsa
;==============================================================================
mov sd_1,#0 ;速度
mov sd_2,#0
mov sd_3,#0
mov sd_4,#0
mov r0,#80h
mov r1,#8 ;第8个","
r_sd: cjne @r0,#2ch,r_si ;","
djnz r1,r_si
jmp r_sd_d
r_si: inc r0
jmp r_sd
r_sd_d: dec r0
cjne @r0,#2ch,sd_nz
jmp sd_r_ok ;","
sd_nz: mov a,@r0
clr c
subb a,#30h
mov sd_4,a
dec r0
mov r1,#sd_3+1
sd_l: dec r0
cjne @r0,#2ch,r_sd_l
jmp sd_r_ok
r_sd_l: dec r1
mov a,@r0
clr c
subb a,#30h
mov @r1,a
jmp sd_l
sd_r_ok:
;==============================================================================
mov fx_1,#0 ;方向
mov fx_2,#0
mov fx_3,#0
mov fx_4,#0
mov r0,#80h
mov r1,#9 ;第8个","
r_fx: cjne @r0,#2ch,r_fi ;","
djnz r1,r_fi
jmp r_fx_d
r_fi: inc r0
jmp r_fx
r_fx_d: dec r0
cjne @r0,#2ch,fx_nz
jmp fx_r_ok ;","
fx_nz: mov fx_4,@r0
dec r0
mov r1,#fx_3+1
fx_l: dec r0
cjne @r0,#2ch,r_fx_l
jmp fx_r_ok
r_fx_l: dec r1
mov a,@r0
mov @r1,a
jmp fx_l
fx_r_ok:ret
;******************************************************************************
;******************************************************************************
j_zda: jmp d_zda
;******************************************************************************
d_gsa: mov r0,#83h ;$gpgsa
cjne @r0,#47h,j_zda
inc r0
cjne @r0,#53h,j_zda
inc r0
cjne @r0,#41h,j_zda
;=============================================================================
mov r0,#80h
mov r1,#2 ;第2个","
r_3d: cjne @r0,#2ch,d_hi ;","
djnz r1,d_hi
inc r0
jmp d_hi_d
d_hi: inc r0
jmp r_3d
d_hi_d: mov d3d,@r0 ;定位状态 gprmc
d_r_ok: ret
;*******************************************************************************
j_ret: ret
;*******************************************************************************
d_zda: mov r0,#83h ;$gpzda
cjne @r0,#5ah,j_ret
inc r0
cjne @r0,#44h,j_ret
inc r0
cjne @r0,#41h,j_ret
mov h_1,#0 ;时间
mov h_2,#0
mov m_1,#0
mov m_2,#0
mov s_1,#0
mov s_2,#0
mov r0,#80h
mov r1,#1 ;第1个","
r_time: cjne @r0,#2ch,t_hi ;","
djnz r1,t_hi
jmp r_t_d
t_hi: inc r0
jmp r_time
;==============================================================================
r_t_d: mov r1,#h_1-1
t_l: inc r0
cjne @r0,#2eh,r_t_l
jmp t_r_ok
r_t_l: inc r1
mov a,@r0
mov @r1,a
cjne r0,#0ffh,t_l
ret
t_r_ok:
;=============================================================================
mov r0,#80h
mov r1,#2 ;第9个","
r_year: cjne @r0,#2ch,y_hi ;","
djnz r1,y_hi
inc r0
jmp y_hi_d
y_hi: inc r0
jmp r_year
y_hi_d: mov r_1,@r0 ;年月日 gprmc
inc r0
mov r_2,@r0 ;年月日 gprmc
inc r0 ;","
inc r0
mov y_1,@r0 ;年月日 gprmc
inc r0
mov y_2,@r0 ;年月日 gprmc
inc r0
inc r0
inc r0
inc r0
mov n_1,@r0 ;年月日 gprmc
inc r0
mov n_2,@r0 ;年月日 gprmc
inc r0
;=============================================================================
ret
;******************************************************************************