RC5.ASM
上传用户:kugapan
上传日期:2015-06-15
资源大小:1192k
文件大小:25k
源码类别:

文件格式

开发平台:

Asm

  1. ;this program use mitsubishi microcomputers.--M34283*
  2. ;all 7x8 KEY matrix
  3. ;have to use timer 1 and timer 2 to timing and send code.
  4. ;RAM DEFINE
  5. GPORTDATA          .EQU    0,0        
  6. EPORTDATA          .EQU    0,1
  7. ROWNO_NEW          .EQU    0,2        ; KEY ROW NO   (D0_7)
  8. COLNO_NEW          .EQU    0,3        ; KEY COL NO   (G0_3,E0_2)
  9. ROWNO_OLD          .EQU    0,4        ; KEY ROW NO   (D0_7)
  10. COLNO_OLD          .EQU    0,5        ; KEY COL NO   (G0_3,E0_2)
  11. ROWNO_SAE          .EQU    0,6        ; KEY ROW NO   (D0_7)
  12. COLNO_SAE          .EQU    0,7        ; KEY COL NO   (G0_3,E0_2)
  13. ROWNO_CUR          .EQU    0,8
  14. COLNO_CUR          .EQU    0,9
  15. CUR_FLAG           .EQU    0,10
  16. CUR_OK             .EQU    0,11
  17. ;=========================
  18. START_BIT   .EQU   1,0
  19. TOGGLE_BIT   .EQU   1,1
  20. CUSTOMH           .EQU    1,2
  21. CUSTOML           .EQU    1,3
  22. DATAH             .EQU    1,4
  23. DATAL             .EQU    1,5
  24. CUSTOMH_          .EQU    1,6
  25. CUSTOML_          .EQU    1,7
  26. DATAH_            .EQU    1,8
  27. DATAL_            .EQU    1,9
  28. ;=========================
  29. COUNTERA          .EQU    2,0
  30. COUNTERB          .EQU    2,1
  31. ROWNO_SEC   .EQU   2,2
  32. COLNO_SEC   .EQU   2,3
  33. ROWNO_FIRST   .EQU   2,4
  34. COLNO_FIRST   .EQU   2,5
  35. COUNTERA_S   .EQU   2,6
  36. ;=============================
  37. CHESUM_LoBYTELO   .EQU    3,0 ;00H
  38. CHESUM_LoBYTEHI   .EQU    3,1 ;
  39. CHESUM_HiBYTELO   .EQU    3,2 ;00H
  40. CHESUM_HiBYTEHI   .EQU    3,3 ;0000H
  41. INDEX   .EQU    3,4
  42. INDEX_D   .EQU    3,5
  43. P_INDEX   .EQU   3,6 
  44. ;=========================
  45. DIGT0   .EQU    0
  46. DIGT1   .EQU    1
  47. DIGT2   .EQU    2
  48. DIGT3   .EQU    3
  49. DIGT4   .EQU    4
  50. DIGT5   .EQU    5
  51. DIGT6   .EQU    6
  52. DIGT7   .EQU    7
  53. DIGT8   .EQU    8
  54. DIGT9   .EQU    9
  55. DIGTA   .EQU    10
  56. DIGTB   .EQU    11
  57. DIGTC   .EQU    12
  58. DIGTD   .EQU    13
  59. DIGTE   .EQU    14
  60. DIGTF   .EQU    15
  61. ;=============================
  62.                .ORG    0000H   
  63. START:
  64.                 NOP
  65.                 CLD                ;clear all D port to 0.
  66.                 RCAR               ;enable high level output invaild.
  67.                 SNZP               ;if cold start or warm. test flag P.
  68.                 BL  COLD_BOOT
  69. WARM_BOOT:
  70.                 LA       DIGTF     ;all G/E port set pull-down transistor
  71.                 TPU0A              ;and key-on wakeup valid
  72.                 LA       DIGT0     ;set D7-D4 port  no pull-down transistor.
  73.                 TPU1A              ;and key-on wakeup invalid.                
  74.                                    ;set Timer1
  75.                LA        DIGT1     ;may 32Ms to wait.
  76.                TBA
  77.                LA        DIGT6
  78.                T1AB               
  79.                LA        DIGT3
  80.                TV1A          
  81.                LA        DIGT2
  82.                TBA
  83.                LA        DIGTA
  84.                T1AB
  85.                WRST
  86. RESCAN:
  87. WaitToScan:
  88.                SNZT1
  89.                B       WaitToScan               
  90.                ;send a code,and scan key twice all time(use in)may 32MS              
  91.                ;first scan key, if have key save for second compare.                           
  92.                BML      SCANKEY               
  93.                LXY      COUNTERA
  94.                TAM      0
  95.                SEA      1
  96.                BL       COLD1
  97.                
  98.                LXY      ROWNO_NEW
  99.                TAM      0
  100.                LXY      ROWNO_OLD
  101.                XAM      0
  102.                LXY      COLNO_NEW
  103.                TAM      0
  104.                LXY      COLNO_OLD
  105.                XAM      0
  106.                
  107.                
  108.                BML      SCANKEY
  109.                LXY      COUNTERA
  110.                TAM      0
  111.                SEA      1
  112.                BL       COLD1
  113.                LXY      ROWNO_NEW
  114.                TAM      0
  115.                LXY      ROWNO_OLD
  116.                SEAM
  117.                BL       RESCAN           ;second scan key no equal first key
  118.                LXY      COLNO_NEW
  119.                TAM      0
  120.                LXY      COLNO_OLD        ;second scan key no equal first key
  121.                SEAM
  122.                BL       RESCAN
  123.                                                
  124. ;;=======================================================
  125. SEND_IR: 
  126.                   URSC
  127.                   LXY    COLNO_NEW
  128.                   TAM    0
  129.                   TBA
  130.                   LXY    ROWNO_NEW
  131.                   TAM    0
  132.                   TDA
  133.                   TAB
  134.                   TABP       6 
  135.                   TEAB
  136. ;-----------------------2006-10-19 8:11------------------------------               
  137. TOSETDATA2:
  138.   SZC
  139.   BL   GET_10_START ;if CY=1,the start bits are 10,ohterwise will be 11.
  140.   LA   DIGT3 ;CY=0,
  141.                   LXY   START_BIT  ;
  142.                   XAM   0                   
  143.                   BL   FETCH_DATA
  144. GET_10_START:       ;CY=1,
  145.   LA   DIGT2  ;
  146.                   LXY   START_BIT 
  147.                   XAM   0
  148.                             
  149. FETCH_DATA:   
  150.   LA      DIGT0  ;The custom code is 00000.
  151.                   LXY     CUSTOMH
  152.                   XAMI    0
  153.                   LA      DIGT0
  154.                   XAM     0
  155. ;-------------------------------------------------------------------                        
  156.   TABE ;get the data code from E register.
  157.                   LXY     DATAH
  158.                   XAM    0
  159.                   TAB
  160.                   LXY     DATAL
  161.                   XAM    0
  162.                                                                  
  163.                   LXY     DATAH
  164.                   TAM    0
  165.                   SEA   DIGTF
  166.                   BL   FIND_KEY
  167.                   LXY     DATAL
  168.                   TAM    0
  169.                   SEA   DIGTF
  170.                   BL   FIND_KEY
  171.                   BL   RESCAN
  172. FIND_KEY:
  173.   BML     COMP_KEY        ;if equal no skip,else  skip(new key)
  174.                   BL   HEADER
  175.                   BL   REP_SE  
  176. REP_SE:
  177.   LXY   TOGGLE_BIT
  178.   SZB   0
  179.   BL   SET1
  180. SET0:
  181.   SB   0
  182.   BL   HEADER
  183. SET1:                
  184.            RB   0                                       
  185. ;==============================================================
  186. HEADER:
  187.        ;send   form030  ir code. 
  188.        ;0:889us/889us. 1: 889us/889us.
  189.        
  190.        ;Timer 2 input source use f(Xin). use 0.25us CARR  unit.
  191.        ;set T2 and R2H/R2L.
  192.        ;Timer2 start with R2L.
  193. ;==============================================================
  194.                LA         DIGT4
  195.                TBA                  ;the lower time is 18.52us
  196.                LA         DIGT9
  197.                T2AB
  198.                LA         DIGT2
  199.                TBA                  ;the higher time is 9.26us
  200.                LA         DIGT4
  201.                T2HAB
  202.                WRST
  203.                LA         DIGT1     
  204.                TBA                   ;
  205.                LA         DIGTE 
  206.                T1AB        
  207.                LA         DIGTD       ;
  208. PreSendCode:
  209.                SNZT1
  210.                B          PreSendCode
  211.                TV2A
  212.                
  213.                LA 0 ;Stop the timer1 to change the count source to Carrier wave output (CARRY).
  214.                TV1A
  215.                
  216.                LXY        START_BIT ;
  217.                TAM   0
  218.                RAR
  219.                SZC
  220.                LA   DIGT5
  221.                LA   DIGT1
  222.                TV1A
  223. SENDDATA:
  224.                LXY         START_BIT       
  225.                BML         SEND_1BIT       ;
  226.                LXY    TOGGLE_BIT
  227.                BML    TOGGLE        
  228.                LXY         CUSTOMH         ;
  229.                BML         WORD            ;CUSTOM CODE LOW DATA
  230.                LXY         CUSTOML         ;
  231.                BML         SEND_1BIT       ;CUSTOM CODE HIGH DATA
  232.                LXY         DATAH
  233.                BML         WORD            ;LOW DATA CODE
  234.                LXY         DATAL
  235.                BML         SEND_2BIT       ;HIGH DATA CODE
  236.                LA          DIGT5
  237.                TBA
  238.                LA          DIGT7
  239.                T1AB
  240.                LA          DIGT9
  241. WaitEnd:
  242.                SNZT1
  243.                BL           WaitEnd
  244.                TV2A
  245.                LA         DIGT0
  246.                TV2A
  247.                TV1A
  248.                LA          DIGT3
  249.                TV1A
  250.                BL          RESCAN      
  251.                  
  252. ;===========================================================
  253. ; START SCAN KEY !
  254. SCANKEY:
  255.           WRST
  256.           LXY          0,7
  257. CLSDPORT:
  258.           RD
  259.           DEY
  260.           BL           CLSDPORT
  261.           LXY          ROWNO_NEW     ;CLEAR ROW & COL NO. TO 'F'
  262.           LA           DIGTF
  263.           XAMI         0
  264.           LA           DIGTF
  265.           XAM          0
  266.           LXY          COUNTERA
  267.           LA           0
  268.           XAM          0                ;CLEAR COUNTERA
  269.           LXY          COUNTERA_S
  270.           LA           0
  271.           XAM          0
  272. ;;-------------------------------------
  273.           LA           DIGT7            ;DIGT7
  274.           LXY          COUNTERB
  275.           TBA
  276.           XAM          0               ;7==>COUNTERB
  277.           TAB
  278.           TYA
  279. SetPortD1:
  280.           SD                       ;SET Di TO 1
  281.           LA           DIGTF      ;all G/E port set pull-down transistorE0
  282.           TPU0A
  283.           BML          WAIT10
  284.           NOP               
  285.           IAE
  286.           LXY          EPORTDATA       ;save E port data to EPORTDATA.
  287.           XAM          0          
  288.           IAG
  289.           LXY          GPORTDATA       ;save G port data to GPORTDATA.
  290.           XAM          0
  291.           LXY          COUNTERB       ;CLEAR Di TO 0.
  292.           TAM          0
  293.           TYA
  294.           RD
  295. G3_ROW:
  296.           LXY          GPORTDATA
  297.           SZB          3
  298.           BL           G3_KEY
  299.           BL           G2_ROW
  300. G3_KEY:
  301.           BML          INC_COUNTERA
  302.           LXY          ROWNO_NEW
  303.           LA           0
  304.           XAM          0
  305.           BML          COL_TRAN
  306. G2_ROW:
  307.           LXY          GPORTDATA
  308.           SZB          2
  309.           BL           G2_KEY
  310.           BL           G1_ROW
  311. G2_KEY:
  312.           BML          INC_COUNTERA
  313.           LXY          ROWNO_NEW
  314.           LA           0
  315.           XAM          0
  316.           BML          COLADD8         
  317. G1_ROW:
  318.           LXY           GPORTDATA
  319.           SZB           1
  320.           BL            G1_KEY
  321.           BL            G0_ROW
  322. G1_KEY:
  323.           BML           INC_COUNTERA
  324.           LXY           ROWNO_NEW
  325.           LA    1
  326.           XAM   0
  327.           BML           COL_TRAN
  328. G0_ROW:
  329.           LXY           GPORTDATA
  330.           SZB           0
  331.           BL            G0_KEY
  332.           BL            E0_ROW ;E2_ROW
  333. G0_KEY:
  334.           BML           INC_COUNTERA
  335.           LXY           ROWNO_NEW
  336.           LA            1
  337.           XAM           0
  338.           BML           COLADD8
  339. ;E2_ROW:
  340. ;          LXY           EPORTDATA
  341. ;          SZB           2
  342. ;          BL            E2_KEY
  343. ;          BL            E1_ROW
  344. ;E2_KEY:
  345. ;          BML           INC_COUNTERA
  346. ;          LXY           ROWNO_NEW
  347. ;          LA            2
  348. ;          XAM           0
  349. ;          BML           COL_TRAN
  350. ;E1_ROW:          
  351. ;          LXY           EPORTDATA
  352. ;          SZB           1
  353. ;          BL            E1_KEY
  354. ;          BL            E0_ROW
  355. ;E1_KEY:
  356. ;          BML           INC_COUNTERA
  357. ;          LXY           ROWNO_NEW
  358. ;          LA            2
  359. ;          XAM           0
  360. ;          BML           COLADD8
  361. E0_ROW:
  362.           LXY           EPORTDATA
  363.           SZB           0
  364.           BL            E0_KEY
  365.           BL            NEXT_COL
  366. E0_KEY:
  367.           BML           INC_COUNTERA
  368.           LXY           ROWNO_NEW
  369.           LA            2
  370.           XAM           0
  371.           BML           COL_TRAN
  372. ;=====================================================          
  373. NEXT_COL:
  374.           LXY           COUNTERB
  375.           TAM           0
  376.           TYA
  377.           DEY
  378.           BL            DPortNext
  379.           BL            SCANEND
  380. DPortNext:
  381.           TAY
  382.           LXY           COUNTERB
  383.           XAM           0
  384.           TAM           0
  385.           TYA
  386.           BL            SetPortD1
  387. SCANEND:
  388.   LA DIGTF
  389.   TPU0A
  390.   NOP
  391.   RT
  392.   
  393. ;=====================================
  394. INC_COUNTERA:
  395.          LXY            COUNTERA
  396.          TAM            0
  397.          SEA 1
  398.          BL EAU_2
  399.          LXY ROWNO_NEW
  400.          TAM 0
  401.          LXY ROWNO_FIRST
  402.          XAM 0
  403.          LXY COLNO_NEW
  404.          TAM 0
  405.          LXY COLNO_FIRST
  406.          XAM 0
  407.          BL INC_COUNTER
  408. EAU_2:
  409.  SEA 2
  410.  BL INC_COUNTER
  411.          LXY ROWNO_NEW
  412.          TAM 0
  413.          LXY ROWNO_SEC
  414.          XAM 0
  415.          LXY COLNO_NEW
  416.          TAM 0
  417.          LXY COLNO_SEC
  418.          XAM 0
  419. INC_COUNTER:  
  420.  LXY            COUNTERA
  421.          TAM            0
  422.          A 1
  423.          NOP
  424.          XAM            0
  425.          RT                  
  426. INC_COUNTERA_S:
  427.          LXY            COUNTERA_S
  428.          TAM            0
  429.          A 1
  430.          NOP
  431.          XAM            0
  432.          RT
  433. COL_TRAN:
  434.          LXY            COUNTERB
  435.          TAM            0
  436.          LXY            COLNO_NEW
  437.          XAM            0
  438.          RT
  439. COLADD8:
  440.          LXY            COUNTERB
  441.          TAM            0
  442.          A              DIGT8
  443.          NOP
  444.          LXY            COLNO_NEW
  445.          XAM            0
  446.          RT
  447.                
  448. ;=====================================
  449. ;; CODE TABLE.
  450. ;=====================================
  451.           .ORG    0300H
  452.                        ;;;;;;;G3
  453.        .DW   11AH       ;K22         ;-----D0
  454.        .DW   13DH       ;K19
  455.        .DW   0FFH       ;K-- 
  456.        .DW   0FFH       ;K21
  457.        .DW   035H    ;K20
  458.        .DW   009H       ;K17
  459.        .DW   03CH       ;K18
  460.        .DW   121H       ;K15          ;-----D7
  461.                        ;;;;;;;G2
  462.        .DW   011H       ;K16
  463.        .DW   024H       ;K13
  464.        .DW   018H       ;K10
  465.        .DW   004H       ;K12
  466.        .DW   000H       ;K14
  467.        .DW   038H       ;K11
  468.        .DW   028H       ;K09
  469.        .DW   008H       ;K08                                       
  470. ;============================
  471.           .ORG    0310H
  472.                       ;;;;;G1
  473.        .DW   030H    ;K07
  474.        .DW   025H       ;K04
  475.        .DW   0FFH       ;K--
  476.        .DW   010H       ;K06
  477.        .DW   020H    ;K05
  478.        .DW   02CH       ;K02
  479.        .DW   007H       ;K03
  480.        .DW   00CH       ;K01
  481.                         ;;;G0
  482.        .DW   0FFH    ;K28
  483.        .DW   01CH       ;K25
  484.        .DW   0FFH       ;K--
  485.        .DW   0FFH       ;K24
  486.        .DW   0FFH    ;K26
  487.        .DW   031H       ;K23
  488.        .DW   02DH       ;K27
  489.        .DW   0FFH       ;K--
  490.                        
  491. ;=========================
  492.           .ORG    0320H
  493.                        ;;;;E0
  494.        .DW   122H        ;K31
  495.        .DW   11AH        ;K34
  496.        .DW   0FFH        ;K--
  497.        .DW   00DH        ;K33
  498.        .DW   12AH        ;K32
  499.        .DW   102H        ;K29
  500.        .DW   112H        ;K30
  501.        .DW   0FFH        ;K--
  502. ;=====================================================
  503. ; RAM CLEAR
  504. ;=====================================================
  505. RAMCL0:
  506.         LXY     0,11              ;(X) <- 0 ,(Y) <- 11
  507. RAMCL1:
  508.         LXY     1,11              ;(X) <- 1 ,(Y) <- 11
  509. RAMCL2:
  510.         LXY     2,11              ;(X) <- 2 ,(Y) <- 11
  511. RAMCL3:
  512.         LXY     3,11              ;(X) <- 3 ,(Y) <- 11
  513. RAMCL:
  514.         LA      15                ;(A) <- F
  515.         XAMD    0              ;(A) <-> (M) ,Y-1
  516.         BL       RAMCL
  517.         RT
  518. ;======================================================
  519. WAIT20: NOP ;
  520. WAIT19: NOP ;
  521. WAIT18: NOP ;
  522. WAIT17: NOP ;
  523. WAIT16: NOP ;
  524. WAIT15: NOP ;
  525. WAIT14: NOP ;
  526. WAIT13: NOP ;
  527. WAIT12: NOP ;
  528. WAIT11: NOP ;
  529. WAIT10: NOP ;
  530. WAIT9: NOP ;
  531. WAIT8: NOP ;
  532. WAIT7: NOP ;
  533. WAIT6: NOP ;
  534. WAIT5: NOP ;
  535. WAIT4: RT ;
  536. ;*******************************************************
  537. ; BIT DATA TRANSMIT
  538. ;*******************************************************
  539. BIT2SEND:        
  540. LA        DIGT1 ;BIT=0
  541.                 TBA
  542.                 LA        DIGTF
  543.                 T1AB
  544.                 LA      DIGTD
  545. Pre2Htime:       
  546.                 SNZT1                                                 
  547.                 B         Pre2Htime
  548.                 TV2A
  549.                 LA      DIGT5
  550.                 TV1A
  551.                 LA        DIGT1
  552.                 TBA
  553.                 LA        DIGTF                
  554.                 T1AB                
  555.                 RC
  556. Send2Clow:
  557.                 SNZT1
  558.                 B         Send2Clow
  559.                 RT
  560. BITSEND:        
  561. SZC   
  562. BL   FIRST_OSC ;BIT=1
  563.                 LA        DIGT1 ;BIT=0
  564.                 TBA
  565.                 LA        DIGTF
  566.                 T1AB
  567.                
  568. PreHtime:       
  569.                 SNZT1                                                 
  570.                 B         PreHtime
  571.                
  572.                 LA      DIGT5
  573.                 TV1A
  574.                 LA        DIGT1
  575.                 TBA
  576.                 LA        DIGTF                
  577.                 T1AB                
  578.                 RC
  579. SendClow:
  580.                 SNZT1
  581.                 B         SendClow
  582.                 TABE
  583.                 RAR
  584.                 SZC
  585.                 LA   DIGT1
  586.                 LA   DIGT5
  587.                 TV1A
  588.                 RT
  589. ;=================================================               
  590. FIRST_OSC:                
  591.                 LA        DIGT1
  592.                 TBA
  593.                 LA        DIGTF
  594.                 T1AB
  595. Htime:       
  596.                 SNZT1                                                 
  597.                 B         Htime
  598.                 LA      DIGT5
  599.                 TV1A
  600.                 LA        DIGT1
  601.                 TBA
  602.                 LA        DIGTF                
  603.                 T1AB                
  604.                 RC                
  605.                 
  606. Sendlow:
  607.                 SNZT1
  608.                 B         Sendlow
  609.                
  610.                 TABE
  611.                 RAR
  612.                 SZC
  613.                 LA     DIGT5     
  614.                 LA     DIGT1
  615.                 TV1A
  616.                 RT
  617. ;=======================================================
  618. SEND_1BIT:
  619. TAM     0
  620.                 XAMI     0
  621.                 RAR
  622.                 SZC
  623.                 BL     SC_1
  624.                 RC
  625.                 BL     ROT_1
  626. SC_1:
  627.                 SC
  628. ROT_1:                   
  629. TAM     0 ;The toggle bit is transfered to A.
  630.                 TEAB
  631.                 BML         BITSEND             ;BIT DATA TRANSMIT
  632.                 RT
  633. TOGGLE:        
  634.                 TAM   0
  635.                 RAR
  636. SZC   
  637. BL   TGFIRST_OSC ;BIT=1
  638.                 LA        DIGT1 ;BIT=0
  639.                 TBA
  640.                 LA        DIGTF
  641.                 T1AB
  642.               
  643. TGPreHtime:       
  644.                 SNZT1                                                 
  645.                 B         TGPreHtime
  646.                 
  647.                 LA      DIGT5
  648.                 TV1A
  649.                 LA        DIGT1
  650.                 TBA
  651.                 LA        DIGTF                
  652.                 T1AB                
  653.                 RC
  654. TGSendClow:
  655.                 SNZT1
  656.                 B         TGSendClow
  657.                 LXY   CUSTOMH
  658.                 TAM   0
  659.                 RAR
  660.                 SZC
  661.                 LA   DIGT1
  662.                 LA   DIGT5
  663.                 TV1A
  664.                 RT
  665. ;=================================================               
  666. TGFIRST_OSC:                
  667.                 LA        DIGT1
  668.                 TBA
  669.                 LA        DIGTF
  670.                 T1AB
  671. TGHtime:       
  672.                 SNZT1                                                 
  673.                 B         TGHtime
  674.                 LA      DIGT5
  675.                 TV1A
  676.                 LA        DIGT1
  677.                 TBA
  678.                 LA        DIGTF                
  679.                 T1AB                
  680.                 RC                
  681.                 
  682. TGSendlow:
  683.                 SNZT1
  684.                 B         TGSendlow
  685.                 
  686.                 
  687.                 LXY   CUSTOMH
  688.                 TAM   0
  689.                 RAR
  690.                 SZC
  691.                 LA   DIGT5     
  692.                 LA   DIGT1
  693.                 TV1A
  694.                 RT
  695.                                 
  696. ;*******************************************************
  697. ; WORD DATA TRANSMIT
  698. ;*******************************************************
  699. WORD:
  700.                 BML     CHECK_NEXDATBIT
  701.                 RAR                        ;0  ;Clear C 
  702.                 TEAB                   
  703.                 BML         BITSEND             ;BIT DATA TRANSMIT
  704. TABE
  705.                 RAR                        ;1
  706. TEAB
  707.                 BML         BITSEND             ;BIT DATA TRANSMIT
  708.         TABE
  709. RAR                        ;2
  710. TEAB
  711.                 BML         BITSEND             ;BIT DATA TRANSMIT
  712. TABE
  713.                 RAR                        ;3
  714. TEAB
  715.                 BML         BITSEND             ;BIT DATA TRANSMIT
  716. TABE
  717.                 RT  
  718.                 
  719. SEND_2BIT:
  720.                 BML     CHECK_NEXDATBIT
  721.                 RAR                        ;0   ;Clear C 
  722.                 TEAB                   
  723.                 BML         BITSEND             ;BIT DATA TRANSMIT
  724. TABE
  725.                 RAR                        ;1
  726.                 LA     1
  727. TEAB
  728.                 BML         BITSEND             ;BIT DATA TRANSMIT
  729.         TABE                 
  730.                 RT
  731.                 
  732. ;==================================================                
  733. CHECK_NEXDATBIT:
  734. TAM     0
  735.                 XAMI     0
  736.                 TEAB
  737.                 TAM     0
  738.                 RAR
  739.                 SZC
  740.                 BL     SC_BIT
  741.                 RC
  742.                 BL     ROT_DATA
  743. SC_BIT:
  744.                 SC
  745. ROT_DATA:
  746. TABE                
  747. RT
  748. ;==================================================
  749. ;this program compare twice key if equal.
  750. ;if equal,return and  skip
  751. ;if no equal, save new scan key and no skip
  752. ;==================================================
  753. COMP_KEY:
  754.                    LXY     ROWNO_NEW
  755.                    TAM     0
  756.                    LXY     ROWNO_SAE
  757.                    SEAM
  758.                    BL      NoEqual
  759.                    LXY     COLNO_NEW
  760.                    TAM     0
  761.                    LXY     COLNO_SAE
  762.                    SEAM
  763.                    BL      NoEqual
  764.                    RT
  765. NoEqual:
  766.                    LXY     ROWNO_NEW
  767.                    TAM     0
  768.                    LXY     ROWNO_SAE
  769.                    XAM     0
  770.                    LXY     COLNO_NEW
  771.                    TAM     0
  772.                    LXY     COLNO_SAE
  773.                    XAM     0
  774.                    
  775.                    RTS
  776.                    
  777. ;=================================================
  778. ;;================================================
  779. COLD1:
  780.         SEA   0
  781.         BL    RESCAN2       
  782.         BL    WAITKEY       
  783. RESCAN2:
  784.         LXY    ROWNO_OLD
  785.         LA     DIGTF
  786.         XAMI   0            ;ROWNO_OLD
  787.         LA     DIGTF
  788.         XAMI   0            ;COLNO_OLD
  789.         LA     DIGTF
  790.         XAMI   0            ;ROWNO_SAE
  791.         LA     DIGTF
  792.         XAM    0            ;COLNO_SAE   
  793.                
  794.         BL     RESCAN
  795.         
  796. ;============================================================  
  797. COLD_BOOT:                
  798.                 BML     RAMCL0          ;RAM CLEAR TO F
  799.                 BML     RAMCL1          ;RAM CLEAR
  800.                 BML     RAMCL2          ;RAM CLEAR
  801.                 BML     RAMCL3
  802.                 
  803. WAITKEY:
  804.                 LXY      0,7                 
  805. SETD_H:         SD
  806.                 DEY
  807.                 BL      SETD_H          ;SET D0-D7=1.
  808.                 LXY     ROWNO_CUR
  809.                 LA      DIGTF
  810.                 XAMI    0
  811.                 LA      DIGTF
  812.                 XAM     0
  813.                 LXY     ROWNO_SAE
  814.                 LA      DIGTF
  815.                 XAMI    0
  816.                 LA      DIGTF
  817.                 XAM     0
  818.                 LA       DIGTF     ;all G/E port expect E0!!!set pull-down transistor
  819.                 TPU0A              ;and key-on wakeup valid
  820.                 LA       DIGT0     ;set D7-D4 port  no pull-down transistor.
  821.                 TPU1A              ;and key-on wakeup invalid.
  822.                 POF                ; WAIT FOR PRESS KEY
  823.                 
  824.        .END
  825. ;======================================================