下载文件详细资料
  文件名称: ht1380汇编样例程序
  公司名称: 上海图一实业有限公司
  下载次数: 2586
  文件详细说明:
 

ht1380汇编样例程序

#include ht48r30a-1.inc

;LCM.INC for DV_16100NRB
LCM_CLS         EQU  01H     ;display clear
CURSOR_HOME     EQU  02H     ;display/cursor home
CURSOR_SHIFT_R  EQU  14H     ;display/cursor shift right
CURSOR_SHIFT_L  EQU  10H     ;display/cursor shift left
display_SHIFT_l EQU  18H     ;display/cursor shift left
INCDD_CG_SHF_C  EQU  06H     ;entry mode set
TURN_ON_DISP    EQU  0EH     ;display on
JUST_TURN_ON    EQU  0CH     ;display on
TURN_OFF_DISP   EQU  08H     ;display on
LCD_ON_CSR_OFF  EQU  0CH     ;display off

;LCM PORT DEFINE
lcm_data        equ  pb
lcm_data_ctrl   equ  pbc

lcm_ctrl        equ  pa
lcm_ctrl_ctrl   equ  pac

ht1380_ctrl     equ  pac
ht1380_pin      equ  pa

key_ctrl_A      equ  pac
key_ctrl_C      equ  pcc
key_A           equ  pa
key_C           equ  pc

;lcm display commands and control signal name.
RS  EQU  0
RW  EQU  1
E   EQU  2

SCLK EQU  7
IO   EQU  6
RST  EQU  5

SEL  EQU  4
INCR EQU  0
C_SHF EQU  1

data .section 'data'       
      bell          dbit     ;if have alarm function
      inv_pa3_flag  dbit     ;use to produce "CPL" function
      cut_flag      dbit     ;judge to turn on/off "tmrc.4"
      hit_alm_time  dbit     ;judge if hit the set alarm time
      if_write      dbit     ;judge if any change of year/time/alarm
      mode_flag     dbit     ;wait_mode or change_mode
      sec_write     dbit     ;judge if change the time_mode
      year_chg_flag dbit     ;judge if the year_h have been set
      time_or_alm   dbit     ;judge if time_adjust or alm_adjust
      speed_key     dbit     ;judge if speed key has been ON
      disp_judge    db ?     ;use for display subrotine
      acc_temp      db ?     ;save data before interrupt
      status_temp   db ?     ;save data before interrupt
      cut_count1    db ?     ;use to as the count of speaker
      cut_count2    db ?     ;use to as the count of speaker
      year_time_alm db ?     ;mode of year/time/alarm
      count         db ?
      count1        db ?
      counter2      db ?    
      ram_point     db ?     ;save the data "MP0" to later reuse
      temp          db ?
      sec           db ?
      min           db ?
      hour          db ?
      date          db ?
      month         db ?
      day           db ?
      year          db ?
      year_h        db ?
      alm_sec       db ?
      alm_min       db ?
      alm_hour      db ?
      disp_word_num db ?     ;judge how many data word(16/8/1)
                             ;you want to display on LCM
      read_temp     db ?
      read_flg      dbit
code .section 'code'
      org    00h                  

      jmp    start
      org    04h
      jmp    ext_int
      org    08h
      jmp    bell_sub 
      org    0ch
      org    10h
ext_int:                         ;extern interrupt subroutin
      mov    acc_temp,a          ;store the ACC value for later
      mov    a,status            ;return interrupt using
      mov    status_temp,a       ;store the STATUS value for
                                 ;later return interrupt using
      snz    hit_alm_time        ;judge if the alarm are acting
      jmp    ext0
      clr    hit_alm_time
      clr    tmrc.4
   ext0:
      snz    mode_flag           ;judge if wait_mode(mode_flag=0)
      jmp    ext1                ;then set mode_flag=1
      clr    mode_flag           ;or if chang_mode(mode_flag=1)
      jmp    ext2                ;then set mode_flag=0
   ext1:
      set    mode_flag
   ext2:
      mov    a,07fh             
      mov    counter2,a         
      mov    disp_word_num,a     ;"disp_word_num" just use as counter
   ext3:                         ;no other meaings
      sdz    disp_word_num
      jmp    ext3
      sdz    counter2
      jmp    ext3
      clr    tmrc.4
      mov    a,status_temp       ;return the "ACC" and "STATUS" data
      mov    status,a
      mov    a,acc_temp
      reti

bell_sub:                        ;inner timer interrupt subroutin
      mov    acc_temp,a
      mov    a,status
      mov    status_temp,a   

      sz     inv_pa3_flag        ;use to "CPL" the port "pa.3"
      jmp    bell_sub1
      set    pa.3
      set    inv_pa3_flag
      jmp    bell_sub2
bell_sub1:
      clr    pa.3
      clr    inv_pa3_flag
bell_sub2:
      mov    a,status_temp   
      mov    status,a
      mov    a,acc_temp
      reti

start:
clr_ram:
 mov a, 20h
 mov mp0, a
 mov a, 96
 
clr_1: inc mp0
 clr r0
 sdz acc
 jmp clr_1
 
      clr    sec_write
      clr    inv_pa3_flag
      clr    bell
      clr    hit_alm_time
      clr    cut_flag
      clr    mode_flag
      clr    alm_sec
      clr    alm_min
      clr    alm_hour
      clr    year_chg_flag
      clr    speed_key
      mov    a,19h
      mov    year_h,a     

      mov    a,01fh              ;have a uncontinue sound of alarm
      mov    cut_count1,a        ;equ "be" sound
      mov    a,09h               ;every four times,have a longer time
      mov    cut_count2,a        ;to "take a rest"
                                 ;equ "be,be,be,be,--"
      mov    a,07h               ;allow external and tmr0 int
      mov    intc,a              ;
      mov    a,81h               ;sys/4 and internal clock count
      mov    tmrc,a              ;

      clr    lcm_data_ctrl       ;set output port type (pbc)
      clr    lcm_data   ;output zero
      mov    a,10h
      mov    pac,a   ;sure 1380 reset is high
      clr    pa
      set    pcc  ;key intput

      clr    read_temp
      set    read_flg

;[lcm_instruction reset start]
      call   delay               ;why need this,see data sheet...

;      mov    a,38h               ;initial set
;      mov    lcm_data,a
;      set    lcm_ctrl.E
;      clr    lcm_ctrl.E
;
;      call   delay
;
;      mov    a,38h
;      mov    lcm_data,a
;      set    lcm_ctrl.E
;      clr    lcm_ctrl.E
;
;     call   delay

      mov    a,38h
      mov    lcm_data,a
      set    lcm_ctrl.E
      clr    lcm_ctrl.E

      call   delay
      call   busy_chk

      mov    a,38h
      call   snd_cmd
      call   busy_chk

      mov    a,TURN_OFF_DISP     ;clr the display type
      call   snd_cmd
      call   busy_chk

      mov    a,JUST_TURN_ON      ;set the display type
      call   snd_cmd
      call   busy_chk

      mov    a,lcm_cls           ;clear the LCM screen
      call   snd_cmd
      call   busy_chk

      mov    a,INCDD_CG_SHF_C    ;set the entry mode
      call   snd_cmd
      call   busy_chk
;[lcm_instruction reset end]

;[ht1380_set start]
      clr    ht1380_pin.RST      ;WP(write protect) disable
      set    ht1380_pin.RST      ;
      mov    a,8eh               ;
      call   write_1380          ;
      mov    a,00h               ;"WP" bit is set "0"
      call   write_1380          ;
      clr    ht1380_pin.RST      ;

      set    ht1380_pin.RST      ;burst mode set
      mov    a,0beh              ;burst mode command
      call   write_1380

      mov    a,00h               ;seconds set ->00,and "CH" bit set "0"
      call   write_1380          ;it means "oscilator start to osc"
 ;     set    pa.3
      mov    a,00h               ;minutes set ->00           
      call   write_1380
      mov    a,00h               ;hour set ->00           
      call   write_1380
      mov    a,05h               ;date set ->29           
      call   write_1380
      mov    a,01h               ;month set ->12           
      call   write_1380
      mov    a,01h               ;day set ->01           
      call   write_1380
      mov    a,98h               ;year set ->97           
      call   write_1380
      clr    ht1380_pin.RST     
;      clr    pa.3

;[ht1380_set end]

;set clock figure,it's userself define *start*
      mov    a,048h              ;the code of LCM
      call   snd_cmd
      call   busy_chk
      mov    a,0d9h
      mov    tblp,a
fg_clk0:
      tabrdl temp
      mov    a,temp
      mov    count,a
      mov    a,24h
      xorm   a,count
      sz     count
      jmp    fg_clk1
      jmp    fg_clk_end
fg_clk1:
      mov    a,temp
      call   write_char
      call   busy_chk
      inc    tblp
      jmp    fg_clk0
fg_clk_end:
;set bell mask *end*

;set bell mask,it's userself define *start*
      mov    a,040h              ;the code of LCM
      call   snd_cmd
      call   busy_chk
      mov    a,0e2h
      mov    tblp,a
fg_bell0:
      tabrdl temp
      mov    a,temp
      mov    count,a
      mov    a,24h
      xorm   a,count
      sz     count
      jmp    fg_bell1
      jmp    wait_mode
fg_bell1:
      mov    a,temp
      call   write_char
      call   busy_chk
      inc    tblp
      jmp    fg_bell0
;set bell mask *end*

wait_mode:
      sz    mode_flag            ;wait_mode(mode_flag=0)
      jmp   chang_mode           ;or chang_mode(mode_flag=1)

      snz   read_flg
      jmp   read0
      set   ht1380_pin.RST       ;burst mode set
      mov   a,0bfh               ;burst mode command
      call  write_1380

      call  get_1380             ;read the data from "HT1380"
      mov   sec,a
      call  get_1380
      mov   min,a
      call  get_1380
      mov   hour,a
      call  get_1380
      mov   date,a
      call  get_1380
      mov   month,a
      call  get_1380
      mov   day,a
      call  get_1380
      mov   year,a
      call  get_1380
      clr   ht1380_pin.RST     

  read0:
      mov   a,160
      sub   a,read_temp  
      sz    acc
      jmp   read1
      set   read_flg
      clr   read_temp
      jmp   read2
  read1:
      inc   read_temp
      clr   read_flg

;year to year transfer *start*
  read2:
      sz    year                 ;judge if the year_h must
      jmp   go                   ;be change,the other say is
      mov   a,1                  ;if 1999-12-31 23:59:59
      sub   a,month              ;then when 00:00:00,the
      sz    acc                  ;year=00,and the
      jmp   go                   ;year_h must be change to
      mov   a,1                  ;year_h=20
      sub   a,date
      sz    acc
      jmp   go
      sz    hour
      jmp   go
      sz    min
      jmp   go
      sz    sec
      jmp   go
      sz    year_chg_flag        ;this is used to judge the year_h
      jmp   go                   ;if have been changed,if yes,then
      inc   year_h               ;the next time won't change the
      set   year_chg_flag        ;year_h again,so if year_chg_flag
      mov   a,year_h             ;=1,then next time won't chang again
      and   a,0fh                ;judge year_h if change to "?a",?=0,1,2
      xor   a,0ah                ;?=0,1,2,...if "yes"
      sz    acc                  ;then set year_h="#0",#=?+1
      jmp   go
      mov   a,0f0h
      andm  a,year_h
      mov   a,010h
      addm  a,year_h
;year to year transfer *end*

;transfer to lcm data type *start*
;alarm data start
   go:
      sz     sec                 ;when the time is not at 00:00:00
      clr    year_chg_flag       ;then we can clear this flag again
                                 ;it's use for that year_h if change
      mov    a,5dh               ;put the datas at "RAM",see the "RAM"
      mov    mp0,a

      mov    a,alm_hour
      call   trn_to_lcm

      mov    a,3ah
      mov    r0,a
      inc    mp0

      mov    a,alm_min
      call   trn_to_lcm

      mov    a,3ah
      mov    r0,a
      inc    mp0

      mov    a,alm_sec
      call   trn_to_lcm

      mov    a,24h
      mov    r0,a
      inc    mp0
;alarm data end

;time data start
      mov    a,66h               ;put the datas at "RAM"
      mov    mp0,a

      mov    a,hour
      call   trn_to_lcm

      mov    a,3ah
      mov    r0,a
      inc    mp0

      mov    a,min
      call   trn_to_lcm

      mov    a,3ah
      mov    r0,a
      inc    mp0

      mov    a,sec
      call   trn_to_lcm

      mov    a,24h
      mov    r0,a
      inc    mp0
;time data end

;year data start
      mov    a,70h
      mov    mp0,a
      mov    a,year_h
      call   trn_to_lcm

      mov    a,year
      call   trn_to_lcm

      mov    a,2dh
      mov    r0,a
      inc    mp0

      mov    a,month
      call   trn_to_lcm

      mov    a,2dh
      mov    r0,a
      inc    mp0
      mov    a,24h
      mov    r0,a
      inc    mp0

      mov    a,date
      call   trn_to_lcm

      mov    a,20h
      mov    r0,a
      inc    mp0

      mov    a,0
      mov    count,a
      mov    a,0ebh
      mov    tblp,a
get_day:
      inc    count
      mov    a,count
      sub    a,day
      sz     acc                 ;judge the day is Monday or
      jmp    get_day2            ;others
      mov    a,3
      mov    count,a
get_day1:
      tabrdl temp                ;if monday,then get "M","O",
      mov    a,temp              ;"N",so others
      mov    r0,a
      inc    mp0
      inc    tblp
      sdz    count
      jmp    get_day1
      jmp    get_day_end
get_day2:
      mov    a,3                 ;because every data has three words
      addm   a,tblp
      jmp    get_day
get_day_end:
      mov    a,24h
      mov    r0,a
;year data end
;transfer to lcm data type *end*
      mov    a,83h               ;move the cursor to "03H"
      call   snd_cmd
      call   busy_chk

      mov    a,5                 ;only want to show "5" words
      mov    count,a
      mov    a,66h               ;the "time" data adress
      mov    mp0,a
disp_time_w1:
      mov    a,1
      mov    disp_word_num,a     ;every time just run disp-sub
      call   display             ;-routine one time
      inc    mp0
      sdz    count
      jmp    disp_time_w1

      mov    a,0c0h              ;move the cursor to "second"
      call   snd_cmd             ;segment of LCM
      call   busy_chk
      mov    a,8                 ;display "8" words everytime
      mov    disp_word_num,a     ;from the "disp_proc",if meet
      call   display             ;"24h",then stop to return

      snz    bell                ;judge if set the alarm
      jmp    wait4
      mov    a,0c7h              ;move the cursor of "LCM"
      call   snd_cmd             ;to the last position "47H"
      call   busy_chk

      mov    a,00h               ;display the "alarm" figure
      call   write_char
      call   busy_chk

      mov    a,04h               ;set the time counter register
      mov    tmr,a
      
      mov    a,sec               ;judge if hit the "setting alarm"
      sub    a,alm_sec           ;time
      sz     acc
      jmp    wait1
      mov    a,min
      sub    a,alm_min
      sz     acc
      jmp    wait1
      mov    a,hour
      sub    a,alm_hour
      sz     acc
      jmp    wait1
      set    hit_alm_time        ;if hit the alarm time,set the
wait1:                           ;falg "hit_alm_time
      snz    hit_alm_time
      jmp    wait4
      sdz    cut_count1          ;use to make "be,--" sound
      jmp    wait4
      sdz    cut_count2          ;use to make be,be,be,be,"--"
      jmp    wait11              ;be,be,be,be,"--" sound
      jmp    wait2
wait11:
      sz     cut_flag            ;for make "be" sound,we can turn
      jmp    wait2               ;on timer interrupt in a while
      set    tmrc.4              ;    |   
      set    cut_flag            ;    |
      jmp    wait3               ;    |
wait2:                           ;    V
      clr    cut_flag            ;and "--" sound,turn it off
      clr    tmrc.4
      clr    pa.3
wait3:
      mov    a,01fh              ;the frequence of "be" sound
      mov    cut_count1,a
      sz     cut_count2
      jmp    wait4
      mov    a,09h               ;because be,-,be,-,be,-,be,-,"-"
      mov    cut_count2,a        ;so must be "9" times
wait4:
      jmp    wait_mode


chang_mode:
      set    mode_flag           ;change_mode(mode_flag=1)
      clr    year_time_alm       ;if this falg is "0",then
                                 ;year,if "1",then time
                                 ;if "2",then alarm
      mov    a,TURN_ON_DISP      ;set display type
      call   snd_cmd
      call   busy_chk

year_adj:
      clr    if_write            ;if no set,then any data won't
                                 ;be change
      mov    a,01h               ;for next time_adj mode
      mov    year_time_alm,a
      mov    a,LCM_CLS
      call   snd_cmd
      call   busy_chk
      mov    a,70h               ;the adress of "year",month,
      mov    mp0,a               ;date,and so one
      set    disp_word_num
      call   display
      mov    a,CURSOR_HOME
      call   snd_cmd
      call   busy_chk
      mov    a,70h
      mov    ram_point,a         ;because the "MP0" data will be change
      mov    mp0,a       
      jmp    key_scan1   

time_adj:
      clr    if_write
      mov    a,LCM_CLS
      call   snd_cmd
      call   busy_chk
      mov    a,83h               ;move the cursor to "03H" of LCM
      call   snd_cmd
      call   busy_chk
      mov    a,5
      mov    count,a
      mov    a,1
      sub    a,year_time_alm     ;year_time_alm=1 is "time_adj"
      sz     acc                 ;otherwise is "alm_adj"
      jmp    disp_time0
      mov    a,66h               ;display the RAM "time" data
      jmp    disp_time1
disp_time0:
      mov    a,5dh               ;display the RAM "alarm" data
disp_time1:
      mov    mp0,a
disp_time_c1:                    ;display the first five words
      mov    a,1                 ;of LCM
      mov    disp_word_num,a
      call   display
      inc    mp0
      sdz    count
      jmp    disp_time_c1
      mov    a,0c0h              ;move the cursor to "second"
      call   snd_cmd             ;segment of LCM
      call   busy_chk
      mov    a,8                 ;display the remainder three
      mov    disp_word_num,a     ;words of "LCM"
      call   display

      mov    a,1
      sub    a,year_time_alm
      sz     acc
      jmp    disp_time
;*********time_adj***********
      mov    a,02h
      mov    year_time_alm,a
      mov    a,84h               ;move cursor to "04H",the low byte
      call   snd_cmd             ;of hour
      call   busy_chk
      mov    a,67h               ;RAM data of time address
      mov    ram_point,a
      mov    mp0,a
      clr    time_or_alm
      jmp    key_scan1
;****************************
;********alm_adj*************
disp_time:
      clr    year_time_alm
      mov    a,0c7h              ;move the cursor to "47H" of LCM
      call   snd_cmd
      call   busy_chk
      mov    a,01h               ;the "clocl" figure
      sz     bell
      mov    a,00h               ;the "alarm" figure
      call   write_char
      call   busy_chk
      mov    a,CURSOR_SHIFT_L    ;move the cursor left to
      call   snd_cmd             ;stay original position
      call   busy_chk
      mov    a,65h               ;RAM data of alam address
      mov    ram_point,a
      mov    mp0,a
      set    time_or_alm
      jmp    key_scan1
;****************************

key_scan1:                       ;judge which key be pressed
      sz     mode_flag
      jmp    key_scan2
      jmp    leave_chang_mode

key_scan2:
      snz    key_C.INCR
      jmp    key_incr

      clr    speed_key     
      snz    key_C.C_SHF
      jmp    cursor_shf

      sz     key_A.SEL
      jmp    key_scan1

key_sel:
      call   delay               ;safe protec procedure 
      snz    key_A.SEL           ;
      jmp    key_sel
      mov    a,0                 ;if now in year_adj,then jmp time_adj
      sub    a,year_time_alm     ;if time_adj,then alarm_adj....
      sz     acc
      jmp    time_adj
      jmp    year_adj

key_incr:
      mov    a,8
      mov    temp,a
key_incr0:
      sz     speed_key           ;judge if speed_key turn on
      jmp    key_incr_speed     
      call   delay1
      snz    key_C.INCR
      jmp    key_incr2
key_incr1:
      mov    a,1                 ;if now in year_adj,then jmp time_adj
      sub    a,year_time_alm     ;if time_adj,then alarm_adj....
      sz     acc
      jmp    time_adjust
      jmp    year_adjust
key_incr2:
      call   delay1
      snz    key_C.INCR          ;stay for a while,if still press the
      jmp    key_incr3           ;inc_key,then turn the speed_key
      clr    speed_key     
      jmp    key_incr0
key_incr3:
      sdz    temp
      jmp    key_incr2
      set    speed_key     
      jmp    key_incr1
key_incr_speed:
      call   delay1
      set    speed_key     
      jmp    key_incr1

year_adjust:
      mov    a,ram_point        
      mov    mp0,a
      mov    a,r0
      mov    temp,a
;**********month*************
      mov    a,76h               ;the address the last
      sub    a,ram_point         ;byte of month at RAM
      sz     acc
      jmp    year_adjust2
      mov    a,85h               ;the address of hi_byte
      mov    count,a             ;of month,it's for later display using
                                 ;display using
      mov    a,12h
      sub    a,month
      sz     acc
      jmp    year_adjust1
      dec    mp0                 ;if now is "12",then must turn to "01"
      mov    a,30h               ;represent "0"
      mov    r0,a
      inc    mp0
      mov    a,31h               ;represent "1"
      mov    r0,a
      jmp    year_adjust12
year_adjust1:
      inc    temp
      mov    a,3ah
      sub    a,temp
      sz     acc
      jmp    year_adjust11
      dec    mp0                 ;if now is "09",then next be "0a"
      mov    a,31h               ;so must be change to "10"
      mov    r0,a
      inc    mp0
      mov    a,30h
      mov    r0,a
      jmp    year_adjust12
;****************************
;********date****************
year_adjust2:   
      mov    a,7ah
      sub    a,ram_point
      sz     acc
      jmp    year_adjust4
      mov    a,0c0h              ;the address hi_byte of date
      mov    count,a             ;using for later display
;*****judge intercalary******
      mov    a,02h
      sub    a,month
      sz     acc
      jmp    intercalary
      mov    a,27h               ;because we use "sz C",so must sub "1"
      jmp    year_adjust22       ;like "28" be "27" and "30" be "29"
intercalary:
      mov    a,04h
      sub    a,month
      sz     acc
      jmp    intercalary0
      jmp    intercalary3
intercalary0:
      mov    a,06h
      sub    a,month
      sz     acc
      jmp    intercalary1
      jmp    intercalary3
intercalary1:
      mov    a,09h
      sub    a,month
      sz     acc
      jmp    intercalary2
      jmp    intercalary3
intercalary2:
      mov    a,11h
      sub    a,month
      sz     acc
      jmp    year_adjust21
intercalary3:
      mov    a,29h               ;because we use "sz C"
      jmp    year_adjust22       ;so must pre_sub "1"
;****************************
year_adjust21:
      mov    a,30h               ;because we use "sz C"
year_adjust22:                   ;so must pre_sub "1"
      sub    a,date              ;
      sz     c                   ;
      jmp    year_adjust3
      dec    mp0                 ;if now is "31",then must turn to "01"
      mov    a,30h               ;represent "0"
      mov    r0,a
      inc    mp0
      mov    a,31h               ;represent "1"
      mov    r0,a
      jmp    year_adjust12
year_adjust3:
      inc    temp
      mov    a,0fh
      and    a,temp
      xor    a,0ah
      sz     acc
      jmp    year_adjust11
      mov    a,30h               ;if now is "09",then next be "0a"
      mov    r0,a                ;so must be change to "10"
      dec    mp0
      mov    a,r0
      add    a,1   
      mov    r0,a
      inc    mp0
      jmp    year_adjust12
;****************************
;*********day****************
year_adjust4:   
      mov    a,7eh
      sub    a,ram_point
      sz     acc
      jmp    year_adjust10
      inc    day
      mov    a,8
      sub    a,day
      sz     acc
      jmp    year_leave_chang_mode
      mov    a,1
      mov    day,a
year_leave_chang_mode:   
      mov    a,0
      mov    count,a
      mov    a,0ebh
      mov    tblp,a
year_adjust6:                    ;judge today is which day
      inc    count
      mov    a,count
      sub    a,day
      sz     acc
      jmp    year_adjust9
      mov    a,3
      mov    count,a
      mov    a,7ch
      mov    mp0,a
year_adjust7:                    ;get the day data;like day=1
      tabrdl temp                ;then get "M","O","N"
      mov    a,temp
      mov    r0,a
      inc    mp0
      inc    tblp
      sdz    count
      jmp    year_adjust7
      mov    a,0c3h              ;move the cursor position
      call   snd_cmd             ;to "43H"
      call   busy_chk
      mov    a,7ch
      mov    mp0,a
      mov    a,1
      mov    disp_word_num,a
      mov    a,3                 ;display the data three times
      mov    count,a             ;because "MON" have three words
year_adjust8:  
      call   display
      inc    mp0
      sdz    count
      jmp    year_adjust8
      mov    a,CURSOR_SHIFT_L    ;move the cursos to last position
      call   snd_cmd             ;of "MON"
      call   busy_chk
      jmp    key_scan1
year_adjust9:
      mov    a,3                 ;every day have three words
      addm   a,tblp              ;data in table
      jmp    year_adjust6
;****************************
;***just display one word****
year_adjust10:
      inc    temp
      mov    a,3ah               ;if the data is "09",then
      sub    a,temp              ;after increase,change to
      sz     acc                 ;"0a",so must set to "00"
      jmp    year_adjust11       ;for LCM,must put "30" to
      mov    a,30h               ;data display RAM of LCM
      mov    temp,a
year_adjust11:
      mov    a,temp
      mov    r0,a
      mov    a,1
      mov    disp_word_num,a
      call   display
      mov    a,CURSOR_SHIFT_L    ;return to original possition
      call   snd_cmd
      call   busy_chk
      set    if_write
      jmp    store_sub
;****************************
;******display two words*****
year_adjust12:
      mov    a,count
      call   snd_cmd
      call   busy_chk
      dec    mp0
      mov    a,1
      mov    disp_word_num,a
      call   display
      inc    mp0
      inc    count
      mov    a,count
      call   snd_cmd
      call   busy_chk
      mov    a,1
      mov    disp_word_num,a
      call   display
      mov    a,CURSOR_SHIFT_L
      call   snd_cmd
      call   busy_chk
      set    if_write
      jmp    store_sub
;****************************

time_adjust:
      mov    a,ram_point
      mov    mp0,a
      mov    a,r0
      mov    temp,a
;**********hour**************
      mov    a,67h               ;the address of low-byte
      sz     time_or_alm         ;of hour
;****************************
;*******alm_hour*************
      mov    a,5eh               ;the address of low-byte
;****************************    ;of alm_hour
      sub    a,ram_point
      sz     acc
      jmp    time_adjust2
      mov    a,83h
      mov    count,a
      mov    a,23h
      sz     time_or_alm
      jmp    time_hour0
      jmp    time_hour1
time_hour0:
      sub    a,alm_hour
      jmp    time_hour2
time_hour1:
      sub    a,hour
time_hour2:
      sz     acc
      jmp    time_adjust1
      dec    mp0
      mov    a,30h               ;if hour is "23",then next step
      mov    r0,a                ;should be change to "00"
      inc    mp0
      mov    a,30h
      mov    r0,a
      jmp    time_adjust9
time_adjust1:
      inc    temp
      mov    a,0fh
      and    a,temp
      xor    a,0ah
      sz     acc
      jmp    time_adjust8
      mov    a,30h
      mov    r0,a
      dec    mp0
      mov    a,r0
      add    a,1   
      mov    r0,a
      inc    mp0
      jmp    time_adjust9
;****************************
time_adjust2:
;**********min**************
      mov    a,6ah
      sz     time_or_alm
;***************************
;*******alm_min*************
      mov    a,61h
;***************************
      sub    a,ram_point
      sz     acc
      jmp    time_adjust3
      jmp    time_adjust41
time_adjust3:
;**********sec**************
      mov    a,6dh
      sz     time_or_alm
;***************************
;*******alm_sec*************
      mov    a,64h
;***************************
      sub    a,ram_point
      sz     acc
      jmp    time_adjust6
      jmp    time_adjust42
time_adjust41:
      mov    a,86h               ;the address of the
      mov    count,a             ;hi-byte of min
      mov    a,59h
      sz     time_or_alm
      jmp    time_min0
      jmp    time_min1
time_min0:
      sub    a,alm_min
      jmp    time_min2
time_min1:
      sub    a,min
time_min2:
      jmp    time_adjust43

time_adjust42:
      mov    a,0c1h              ;the address of the
      mov    count,a             ;hi-byte of sec
      sz     time_or_alm
      jmp    time_sec0
      jmp    time_sec1
time_sec0:
      mov    a,059h             
      sub    a,alm_sec
      jmp    time_adjust43
time_sec1:
      mov    a,059h             
      sub    a,sec              
                                
time_adjust43:
      sz     acc
      jmp    time_leave_chang_mode
      dec    mp0
      mov    a,30h
      mov    r0,a
      inc    mp0
      mov    a,30h
      mov    r0,a
      jmp    time_adjust9
time_leave_chang_mode:
      inc    temp
      mov    a,0fh
      and    a,temp
      xor    a,0ah
      sz     acc
      jmp    time_adjust8
      mov    a,30h
      mov    r0,a
      dec    mp0
      mov    a,r0
      add    a,1   
      mov    r0,a
      inc    mp0
      jmp    time_adjust9
;****************************
;********bell change*********
time_adjust6:   
      mov    a,00h
      sz     bell
      mov    a,01h
      call   write_char
      call   busy_chk
      mov    a,CURSOR_SHIFT_L
      call   snd_cmd
      call   busy_chk
      sz     bell
      jmp    time_adjust7
      set    bell
      jmp    key_scan1
time_adjust7:
      clr    bell
      jmp    key_scan1
;****************************
;***just display one words***
time_adjust8:
      jmp    year_adjust11
;****************************
;******display two words*****
time_adjust9:
      jmp    year_adjust12
;****************************

cursor_shf:
      call   delay
      snz    key_C.C_SHF
      jmp    cursor_shf
      mov    a,1                 ;if now in year_adj,then jmp time_adj
      sub    a,year_time_alm     ;if time_adj,then alarm_adj....
      sz     acc
      jmp    cursor_shf1
      jmp    cursor_year
cursor_shf1:
      mov    a,2
      sub    a,year_time_alm
      sz     acc
      jmp    cursor_alm
      jmp    cursor_time

cursor_year:
      mov    a,73h               ;the last position of year
      sub    a,ram_point
      sz     acc
      jmp    cursor_year1
      mov    a,86h              
      call   snd_cmd
      call   busy_chk
      mov    a,76h
      mov    ram_point,a
      jmp    key_scan1
cursor_year1:
      mov    a,76h               ;the last position of month
      sub    a,ram_point
      sz     acc
      jmp    cursor_year2
      mov    a,0c1h
      call   snd_cmd
      call   busy_chk
      mov    a,7ah
      mov    ram_point,a
      jmp    key_scan1
cursor_year2:
      mov    a,7ah               ;the last position of date
      sub    a,ram_point
      sz     acc
      jmp    cursor_year3
      mov    a,0c5h
      call   snd_cmd
      call   busy_chk
      mov    a,7eh
      mov    ram_point,a
      jmp    key_scan1
cursor_year3:
      mov    a,7eh               ;the last position of day
      sub    a,ram_point
      sz     acc
      jmp    cursor_year4
      mov    a,CURSOR_HOME     
      call   snd_cmd
      call   busy_chk
      mov    a,70h
      mov    ram_point,a
      jmp    key_scan1
cursor_year4:
      mov    a,CURSOR_SHIFT_R    ;just shift right one time
      call   snd_cmd
      call   busy_chk
      inc    ram_point
      inc    mp0
      jmp    key_scan1           

cursor_time:
      mov    a,67h               ;the last position of hour
      sub    a,ram_point
      sz     acc
      jmp    cursor_time1
      mov    a,87h
      call   snd_cmd
      call   busy_chk
      mov    a,6ah
      mov    ram_point,a
      jmp    key_scan1
cursor_time1:
      mov    a,6ah               ;the last position of time
      sub    a,ram_point
      sz     acc
      jmp    cursor_time2
      mov    a,0c2h
      call   snd_cmd
      call   busy_chk
      mov    a,6dh               ;the last position of sec
      mov    ram_point,a
      jmp    key_scan1
cursor_time2:
      mov    a,84h
      call   snd_cmd
      call   busy_chk
      mov    a,67h
      mov    ram_point,a
      jmp    key_scan1

cursor_alm:
      mov    a,5eh               ;the last position of alm_hour
      sub    a,ram_point
      sz     acc
      jmp    cursor_alm1
      mov    a,87h
      call   snd_cmd
      call   busy_chk
      mov    a,61h
      mov    ram_point,a
      jmp    key_scan1
cursor_alm1:
      mov    a,61h               ;the last position of alm_min
      sub    a,ram_point
      sz     acc
      jmp    cursor_alm2
      mov    a,0c2h
      call   snd_cmd
      call   busy_chk
      mov    a,64h
      mov    ram_point,a
      jmp    key_scan1
cursor_alm2:
      mov    a,64h               ;the last position of alm_sec
      sub    a,ram_point
      sz     acc
      jmp    cursor_alm3
      mov    a,0c7h
      call   snd_cmd
      call   busy_chk
      mov    a,65h               ;the position of bell figure
      mov    ram_point,a
      jmp    key_scan1
cursor_alm3:
      mov    a,84h
      call   snd_cmd
      call   busy_chk
      mov    a,5eh
      mov    ram_point,a
      jmp    key_scan1

leave_chang_mode:
      mov    a,JUST_TURN_ON
      call   snd_cmd
      call   busy_chk
      mov    a,LCM_CLS
      call   snd_cmd
      call   busy_chk
      clr    mode_flag

      set   ht1380_pin.RST       ;write the data of RAM
      mov   a,86h                ;to HT1380
      call  write_1380
      mov   a,date
      call  write_1380
      clr   ht1380_pin.RST     

      set   ht1380_pin.RST     
      mov   a,88h
      call  write_1380
      mov   a,month
      call  write_1380
      clr   ht1380_pin.RST     

      set   ht1380_pin.RST     
      mov   a,8ah
      call  write_1380
      mov   a,day
      call  write_1380
      clr   ht1380_pin.RST     

      set   ht1380_pin.RST     
      mov   a,8ch
      call  write_1380
      mov   a,year
      call  write_1380
      clr   ht1380_pin.RST     
;****************************
;**judge if change time_adj**
      snz   sec_write
      jmp   wait_mode

      set   ht1380_pin.RST     
      mov   a,82h
      call  write_1380
      mov   a,min
      call  write_1380
      clr   ht1380_pin.RST     

      set   ht1380_pin.RST     
      mov   a,84h
      call  write_1380
      mov   a,hour
      call  write_1380
      clr   ht1380_pin.RST     

      set   ht1380_pin.RST     
      mov   a,80h
      call  write_1380
      mov   a,sec              
      call  write_1380
      clr   ht1380_pin.RST     

      clr    sec_write
      jmp    wait_mode

store_sub:
;***transfer data from LCM***
      mov   a,5dh
      call  turn_from_lcm
      mov   alm_hour,a
      mov   a,60h
      call  turn_from_lcm
      mov   alm_min,a
      mov   a,63h
      call  turn_from_lcm
      mov   alm_sec,a
      mov   a,66h
      call  turn_from_lcm
      mov   hour,a
      mov   a,69h
      call  turn_from_lcm
      mov   min,a
      mov   a,6ch
      call  turn_from_lcm
      mov   sec,a
      mov   a,70h
      call  turn_from_lcm
      mov   year_h,a
      mov   a,72h
      call  turn_from_lcm
      mov   year,a
      mov   a,75h
      call  turn_from_lcm
      mov   month,a
      mov   a,79h
      call  turn_from_lcm
      mov   date,a
;****************************
;**judge if change time_adj**
      mov   a,2
      sub   a,year_time_alm
      sz    acc
      jmp   key_scan1
      snz   if_write
      jmp   key_scan1

      set   sec_write            ;it use for leave_chang_mode to judge
      jmp   key_scan1            ;if change the time_adj
;****************************

display proc
      mov    a,r0
      mov    temp,a
      mov    a,24h
      xor    a,temp
      sz     acc
      jmp    disp1
      jmp    new_add
disp1:
;**write_cmd***busy_chk**
      mov    a,0                 ;judge where to return lately
      mov    disp_judge,a
      mov    a,temp
      jmp    disp_w
;************************
disp1r:
      mov    a,1
      sub    a,disp_word_num
      sz     acc
      jmp    disp2
      ret
disp2:
      inc    mp0
      jmp    display
new_add:
      mov    a,8
      sub    a,disp_word_num
      sz     acc
      jmp    disp3
      ret
disp3:
;***snd_cmd***busy_chk***
      mov    a,1
      mov    disp_judge,a
      mov    a,0c0h
      jmp    disp_s
;*************************
disp3r:
      mov    a,r0
      mov    temp,a
      mov    a,24h
      xor    a,temp
      sz     acc
      jmp    disp4
      ret
disp4:
      mov    a,temp
      jmp    disp_w
;*******snd_cmd*************
disp_s:
      mov    lcm_data,a
      clr    lcm_ctrl.RW
      clr    lcm_ctrl.RS
      set    lcm_ctrl.E
      clr    lcm_ctrl.E
      jmp    disp_b
;***************************
;*******writ_cmd************
disp_w:
      mov    lcm_data,a
      clr    lcm_ctrl.RW
      set    lcm_ctrl.RS
      set    lcm_ctrl.E
      clr    lcm_ctrl.E
;***************************
;*******busy_chk***********
disp_b:
      set    lcm_data_ctrl
      clr    lcm_ctrl.RS
      set    lcm_ctrl.RW
busy_disp:
      set    lcm_ctrl.E
      mov    a,lcm_data
      sz     acc.7
      jmp    busy_disp
      clr    lcm_ctrl.E
      clr    lcm_ctrl.RW
      clr    lcm_data_ctrl
      mov    a,0
      sub    a,disp_judge
      sz     acc
      jmp    disp5
      jmp    disp1r
disp5:
      inc    mp0
      jmp    disp3r
;***************************
display endp

snd_cmd proc
      mov    lcm_data,a
      clr    lcm_ctrl.RW
      clr    lcm_ctrl.RS
      set    lcm_ctrl.E
      clr    lcm_ctrl.E
      ret
snd_cmd endp

write_char proc
      mov    lcm_data,a
      clr    lcm_ctrl.RW
      set    lcm_ctrl.RS
      set    lcm_ctrl.E
      clr    lcm_ctrl.E
      ret
write_char endp

busy_chk proc
      set    lcm_data_ctrl
      clr    lcm_ctrl.RS
      set    lcm_ctrl.RW
    busy:
      set    lcm_ctrl.E
      mov    a,lcm_data
      sz     acc.7
      jmp    busy
      clr    lcm_ctrl.E
      clr    lcm_ctrl.RW
      clr    lcm_data_ctrl
      ret                 
busy_chk endp

delay proc
      mov    a,02fh
      mov    count,a
      mov    count1,a
  lp0:
      sdz    count1
      jmp    lp0
      sdz    count
      jmp    lp0
      ret
delay endp

write_1380 proc
      mov   temp,a
      mov   a,8
      mov   count,a
 write:
      rrc   temp
      sz    c
      set   ht1380_pin.IO   
      set   ht1380_pin.SCLK
      clr   ht1380_pin.SCLK
      clr   ht1380_pin.IO   
      sdz   count
      jmp   write
      ret     
write_1380 endp

get_1380 proc
      clr   temp
      mov   a,8
      mov   count,a
      set   ht1380_ctrl.IO
get1380:
      clr   c
      set   ht1380_pin.SCLK
      sz    ht1380_pin.IO
      set   c
      rrc   temp
      clr   ht1380_pin.SCLK
      sdz   count
      jmp   get1380
      clr   ht1380_ctrl.IO
      clr   ht1380_pin.IO
      mov   a,temp
      ret
get_1380 endp

trn_to_lcm proc
      mov   temp,a
      swapa temp
      and   a,0fh
      or    a,30h
      mov   r0,a
      inc   mp0
      mov   a,temp
      and   a,0fh
      or    a,30h
      mov   r0,a
      inc   mp0
      ret
trn_to_lcm endp

delay1 proc
      mov    a,04fh
      mov    count,a
      mov    count1,a
  lp:
      sdz    count1
      jmp    lp
      sdz    count
      jmp    lp
      ret
delay1 endp

turn_from_lcm proc
      mov   mp0,a
      mov   a,r0
      and   a,0fh
      mov   temp,a
      swap  temp
      inc   mp0
      mov   a,r0
      and   a,0fh
      or    a,temp
      ret
turn_from_lcm endp

      org   07d9h
      dc    0000h,001fh,0015h,0015h,0017h,0011h,001fh,0000h,0024h
      org   07e2h
      dc    0000h,0004h,000ah,000ah,001fh,000ah,0004h,0000h,0024h
      org   07ebh
      dc    04dh,04fh,04eh
      dc    054h,055h,052h
      dc    057h,045h,044h
      dc    054h,048h,055h
      dc    046h,052h,049h
      dc    053h,041h,054h
      dc    053h,055h,04eh
end

文件下载(右键文件另存为)