Advertisement
Guest User

Kodelås

a guest
Apr 12th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 18.84 KB | None | 0 0
  1. ;**** FIL OPLYSNINGER ******************************************************************
  2. ;   Fil:        LAB5_1.asm
  3. ;   Dato:       8.September 2014
  4. ;   Forfatter:  Ib Refer
  5. ;   Redigeret:  Steen Heide
  6. ; ****** BESKRIVELSE **********************************************************************
  7. ;   dette program anvender SDUboard.lib til at skrive til vores display
  8. ;   Der skrives i første omgang tekster (string´s) ud til displayet
  9. ; ****** UDVIDELSER ***********************************************************************
  10. ;   Udvidelser:
  11. ;           1:  du skal ændre teksterne  
  12. ; ****** Anvendte kommandoer **************************************************************
  13. ;       String er en kommando, der er konstrueret som en macro i SDUboard.lib,  
  14. ;       den anbringer tegnene på hver sin memmory adresse så vi senere ved hjælp af
  15. ;       strengens navn (msg) kan få skrevet strengens tegn ud på vores display
  16. ;       LCDstr er en kommando, der er konstrueret som en macro i SDUboard.lib
  17. ;       Den udskriver indholdet i en navngivet (msg) streng efter hinanden på displayet
  18. ; ******* PROCESSOR DEFINITIONER **********************************************************
  19.     processor   16f877a                 ;Sets processor
  20.     #include    p16f877a.inc
  21. ;   errorlevel -302                 ;fjerner meddelser om forkerte banker fra fejl listen
  22. ;   errorlevel -305                 ;fjerner meddelser om forkerte banker fra fejl listen
  23. ; ******* COMPILER configuration bits *****************************************************
  24.     __config    _HS_OSC & _PWRTE_OFF & _WDT_OFF & _CP_OFF & _CPD_OFF & _LVP_OFF
  25. ; ******* DEFFINITION AF VARIABLE *********************************************************
  26.     #include    "SDUboard.var"      ;Variable som bruges af SDUboard 0x79 - 0x7F)
  27.                                     ;INDSÆT DINE VARIABLE HER (start med 0x20)
  28. ; ******* OPSÆTNING AF PROGRAM POINTERE ***************************************************
  29.             org     0x0000          ;Programstart efter et reset
  30.             GOTO    init                ;Gå til opsætning
  31.             org     0x0005          ;Første position efter interrupt-vektor
  32. ;           GOTO    ISR
  33.  
  34.             Delay1      EQU 0x20
  35.             Delay2      EQU 0x21
  36.             Delay3      EQU 0x22
  37.  
  38.             RESULTAT    EQU 0X23
  39.  
  40.             KEY         equ 0x26
  41.             KEY1        equ 0x27
  42.             KEY2        equ 0x28
  43.             KEY3        equ 0x29
  44.             KEY4        equ 0x2A
  45.             PassKey1    equ 0x2B
  46.             PassKey2    equ 0x2C
  47.             PassKey3    equ 0x2D
  48.             PassKey4    equ 0x2E
  49.             KEYCOUNT    equ 0x2F
  50.             LockStatus  equ 0x30
  51.             NewKeyStatus        equ 0x31
  52.             NEWKEYCOUNT equ 0x32
  53.             TempPassKey equ 0x33
  54.             StartMessage        equ 0x34
  55.  
  56. ; ******* INCLUDEREDE FILER ***************************************************************
  57.     #Include    "SDUboard.lib"      ; SDU PICborad subroutine bibliotek.
  58.  
  59. ;   #Include    "Delay.LIB"             ; Tilføjer delay filen
  60.     #Include    "Transmitter.inc"       ; Tilføjer Transmitter filen
  61.     #Include    "Reciever.inc"          ; Tilføjer Reciever filen
  62.  
  63. ; ******* INITIALISERING AF PROGRAM   *****************************************************
  64. init        CALL    LCD_Init        ; Initialiser LCD og indsæt DK-bogstaver (æøå)
  65.        
  66.    
  67.         BCF STATUS,RP1  ; GÅR TIL BANK 1 }
  68.         BSF STATUS,RP0  ; GÅR TIL BANK 1 }
  69.        
  70.        
  71.         MOVLW b'00011111'
  72.         MOVWF TRISC
  73.  
  74.         MOVLW b'00000000'
  75.         MOVWF TRISB
  76.        
  77.         MOVLW b'00000000'
  78.         MOVWF CMCON        
  79.  
  80.         BCF STATUS,RP1  ; GÅR TIL BANK 0 }
  81.         BCF STATUS,RP0  ; GÅR TIL BANK 0 }
  82.  
  83.         ;KODE = 2587
  84.         MOVLW   d'2'
  85.         MOVWF   PassKey1
  86.         MOVLW   d'5'
  87.         MOVWF   PassKey2
  88.         MOVLW   d'8'
  89.         MOVWF   PassKey3
  90.         MOVLW   d'7'
  91.         MOVWF   PassKey4
  92.  
  93.         MOVLW b'00000000'
  94.         MOVWF KEY1
  95.         MOVWF KEY2
  96.         MOVWF KEY3
  97.         MOVWF KEY4
  98.         MOVWF KEY
  99.         MOVWF KEYCOUNT
  100.  
  101.         BSF LockStatus,0
  102.  
  103.         BCF PORTB,0
  104.         BCF PORTB,1
  105.         BCF PORTB,2
  106.  
  107.    
  108.         BCF     NewKeyStatus,0              ; Midlertidiget bit der er sat under ny-kode
  109.  
  110. ; ******* OPSÆT TRANSMITTER- / RECEIVERREGISTRE **********************************
  111.  
  112.  
  113.         BSF     STATUS,RP0          ; definer porte - start (bank1)
  114.         CLRF    TRISB               ; lav port C til udgange
  115.         BCF     TRISC,6             ; RC6/TX/CK
  116.         BSF     TRISC,7             ; RC7/RX/DT
  117.         BCF     STATUS,RP0          ; definer porte - slut (bank0)
  118.  
  119.  
  120.         CALL    TRANSMITTERSETUP    ; transmitter (Udkommenter RECIEVERSETUP)
  121.         CALL    RECIEVERSETUP       ; reciever (Udkommenter TRANSMITTERSETUP)
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. ; ******* HOVEDPROGRAM ********************************************************************
  129. main
  130.        
  131.         ; Send heartbeat
  132.         MOVLW   0X30                ; Fly hexkoden for 0 til W
  133.         CALL    TRANSMITTER         ; Send dataen fra W, ved at køre TRANSMITTER
  134.         CALL    Timeout4            ; Delay for at sikre tid nok til transmission
  135.  
  136.         CALL    RECIEVER            ; Tjek om PIC har modtaget data
  137.  
  138.         BTFSS   StartMessage,0
  139.         LCDstr  welcomemsg
  140.         BSF     StartMessage,0
  141.  
  142.         BTFSC   PORTC,4             ; Ny-kode ønsket
  143.         CALL    NewKeyTrigger
  144.  
  145.         BSF PORTB,4 ; Output0
  146.         BSF PORTB,5 ; Output1
  147.         BSF PORTB,6 ; Output2
  148.    
  149.         BTFSC PORTC,0 ; Input 0
  150.         GOTO  Row1
  151.        
  152.         BTFSC PORTC,1 ; Input 1
  153.         GOTO  Row2
  154.        
  155.         BTFSC PORTC,2 ; Input 2
  156.         GOTO  Row3
  157.        
  158.         BTFSC PORTC,3 ; Input 3
  159.         GOTO  Row4
  160.          
  161.          
  162.          
  163.         GOTO main
  164.        
  165. Row1  
  166.         ;LCDstr     row1
  167.         BSF PORTB,4
  168.         BCF PORTB,5
  169.         BCF PORTB,6
  170.         CALL Timeout2
  171.         BTFSC PORTC,0
  172.         GOTO Key1Pressed
  173.  
  174.         BCF PORTB,4
  175.         BSF PORTB,5
  176.         BCF PORTB,6
  177.         CALL Timeout2
  178.         BTFSC PORTC,0
  179.         GOTO Key2Pressed
  180.        
  181.         BCF PORTB,4
  182.         BCF PORTB,5
  183.         BSF PORTB,6
  184.         CALL Timeout2
  185.         BTFSC PORTC,0
  186.         GOTO Key3Pressed
  187.         GOTO main
  188.  
  189. Row2
  190.         ;LCDstr     row2
  191.         BSF PORTB,4
  192.         BCF PORTB,5
  193.         BCF PORTB,6
  194.         CALL Timeout2
  195.         BTFSC PORTC,1
  196.         GOTO Key4Pressed
  197.        
  198.         BCF PORTB,4
  199.         BSF PORTB,5
  200.         BCF PORTB,6
  201.         CALL Timeout2
  202.         BTFSC PORTC,1
  203.         GOTO Key5Pressed
  204.  
  205.         BCF PORTB,4
  206.         BCF PORTB,5
  207.         BSF PORTB,6
  208.         CALL Timeout2
  209.         BTFSC PORTC,1
  210.         GOTO Key6Pressed
  211.         GOTO main
  212.    
  213. Row3
  214.         ;LCDstr     row3
  215.         BSF PORTB,4
  216.         BCF PORTB,5
  217.         BCF PORTB,6
  218.         CALL Timeout2
  219.         BTFSC PORTC,2
  220.         GOTO Key7Pressed
  221.  
  222.         BCF PORTB,4
  223.         BSF PORTB,5
  224.         BCF PORTB,6
  225.         CALL Timeout2
  226.         BTFSC PORTC,2
  227.         GOTO Key8Pressed
  228.  
  229.         BCF PORTB,4
  230.         BCF PORTB,5
  231.         BSF PORTB,6
  232.         CALL Timeout2
  233.         BTFSC PORTC,2
  234.         GOTO Key9Pressed
  235.         GOTO main
  236.    
  237. Row4
  238.         ;LCDstr     row4
  239.         BSF PORTB,4
  240.         BCF PORTB,5
  241.         BCF PORTB,6
  242.         CALL Timeout2
  243.         BTFSC PORTC,3
  244.         GOTO Key10Pressed
  245.  
  246.         BCF PORTB,4
  247.         BSF PORTB,5
  248.         BCF PORTB,6
  249.         CALL Timeout2
  250.         BTFSC PORTC,3
  251.         GOTO Key11Pressed
  252.  
  253.         BCF PORTB,4
  254.         BCF PORTB,5
  255.         BSF PORTB,6
  256.         CALL Timeout2
  257.         BTFSC PORTC,3
  258.         GOTO Key12Pressed
  259.         GOTO main
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266. KeyPressed
  267.         CALL    Timeout ; Håndtér prel med en tidspildsrutine
  268.         CALL    ShiftKeys ; Ryk alle keys et "trin" ned
  269.         INCF    KEYCOUNT ; Inkrementér KeyCounteren
  270.         BTFSC   KEYCOUNT,2 ; Tjek om bit 2 i KEYCOUNTER er sat (Altså om den er 4 (Da den ikke kan blive større end 4))
  271.         GOTO    CodeEntered ; Hvis den er lig 4, udføres CodeEntered funktionen
  272.         GOTO    main
  273.  
  274. CodeEntered
  275.        
  276.         BCF     StartMessage,0  ;Geninizilatiser startbesked til LED       
  277.  
  278.         MOVFW   KEY1
  279.         XORWF   PassKey1,w
  280.         BTFSS   STATUS,Z ; Skip næste linje hvis Key1 og PassKey1 er ens
  281.         GOTO    WrongCode
  282.         MOVFW   KEY2
  283.         XORWF   PassKey2,w
  284.         BTFSS   STATUS,Z ; Skip næste linje hvis Key2 og PassKey2 er ens
  285.         GOTO    WrongCode
  286.         MOVFW   KEY3
  287.         XORWF   PassKey3,w
  288.         BTFSS   STATUS,Z ; Skip næste linje hvis Key3 og PassKey3 er ens
  289.         GOTO    WrongCode
  290.         MOVFW   KEY4
  291.         XORWF   PassKey4,w
  292.         BTFSS   STATUS,Z ; Skip næste linje hvis Key4 og PassKey4 er ens
  293.         GOTO    WrongCode
  294.  
  295.         GOTO    CorrectCode
  296.  
  297. WrongCode
  298.         CALL    ClearKeys
  299.         CALL    Timeout
  300.         LCDstr  wrongmsg
  301.         BSF PORTB,1
  302.         BCF PORTB,2
  303.         CALL    Timeout3
  304.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  305.         CALL    LCD_Reg     ; Clear LCD
  306.         BCF PORTB,1
  307.         BCF PORTB,2
  308.         GOTO main ; TEMP LØSNING
  309.  
  310. CorrectCode
  311.         BTFSC   LockStatus,0
  312.         GOTO    Unlock
  313.         GOTO    Lock
  314.        
  315. Lock
  316.         CALL    ClearKeys
  317.         CALL    Timeout
  318.         LCDstr  lockmsg
  319.         BCF PORTB,0
  320.         BCF PORTB,1
  321.         BSF PORTB,2
  322.         BSF LockStatus,0
  323.         CALL Timeout
  324.         BCF PORTB,2
  325.         CALL Timeout
  326.         BSF PORTB,2
  327.         CALL    Timeout3
  328.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  329.         CALL    LCD_Reg     ; Clear LCD
  330.         BCF PORTB,1
  331.         BCF PORTB,2
  332.         GOTO main ; TEMP LØSNING
  333.  
  334. Unlock
  335.         CALL    ClearKeys
  336.         CALL    Timeout
  337.         LCDstr  unlockmsg
  338.         BSF PORTB,0
  339.         BCF PORTB,1
  340.         BSF PORTB,2
  341.         BCF LockStatus,0
  342.         CALL    Timeout3
  343.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  344.         CALL    LCD_Reg     ; Clear LCD
  345.         BCF PORTB,1
  346.         BCF PORTB,2
  347.         GOTO main ; TEMP LØSNING
  348.  
  349.  
  350. ShiftKeys
  351.         MOVF    KEY2,w
  352.         MOVWF   KEY1
  353.         MOVF    KEY3,w
  354.         MOVWF   KEY2
  355.         MOVF    KEY4,w
  356.         MOVWF   KEY3
  357.         MOVF    KEY,w
  358.         MOVWF   KEY4
  359.  
  360.         RETURN
  361.  
  362.  
  363. ClearKeys
  364.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  365.         CALL    LCD_Reg     ; Clear LCD
  366.  
  367.         MOVLW   b'00000000' ;Reset variabler
  368.         MOVWF   KEYCOUNT
  369.         MOVWF   KEY
  370.         MOVWF   KEY1
  371.         MOVWF   KEY2
  372.         MOVWF   KEY3
  373.         MOVWF   KEY4
  374.  
  375.         RETURN
  376.  
  377.  
  378.  
  379.  
  380.  
  381. Key1Pressed
  382.         MOVLW d'1'
  383.         CALL    CONV2ASCII
  384.         CALL    LCD_Data
  385.         MOVLW d'1'
  386.         BTFSC   NewKeyStatus,0
  387.         GOTO    NewPass     ; Der anmodes om en ny kode
  388.         MOVWF KEY
  389.         CALL KeyPressed
  390.         CALL Timeout
  391.         GOTO main
  392.  
  393. Key2Pressed
  394.         MOVLW d'2'
  395.         CALL    CONV2ASCII
  396.         CALL    LCD_Data
  397.         MOVLW d'2'
  398.         BTFSC   NewKeyStatus,0
  399.         GOTO    NewPass     ; Der anmodes om en ny kode
  400.         MOVWF KEY
  401.         CALL KeyPressed
  402.         CALL Timeout
  403.         GOTO main
  404.  
  405. Key3Pressed
  406.         MOVLW d'3'
  407.         CALL    CONV2ASCII
  408.         CALL    LCD_Data
  409.         MOVLW d'3'
  410.         BTFSC   NewKeyStatus,0
  411.         GOTO    NewPass     ; Der anmodes om en ny kode
  412.         MOVWF KEY
  413.         CALL KeyPressed
  414.         CALL Timeout
  415.         GOTO main
  416. Key4Pressed
  417.         MOVLW d'4'
  418.         CALL    CONV2ASCII
  419.         CALL    LCD_Data
  420.         MOVLW d'4'
  421.         BTFSC   NewKeyStatus,0
  422.         GOTO    NewPass     ; Der anmodes om en ny kode
  423.         MOVWF KEY
  424.         CALL KeyPressed
  425.         CALL Timeout
  426.         GOTO main
  427. Key5Pressed
  428.         MOVLW d'5'
  429.         CALL    CONV2ASCII
  430.         CALL    LCD_Data
  431.         MOVLW d'5'
  432.         BTFSC   NewKeyStatus,0
  433.         GOTO    NewPass     ; Der anmodes om en ny kode
  434.         MOVWF KEY
  435.         CALL KeyPressed
  436.         CALL Timeout
  437.         GOTO main
  438. Key6Pressed
  439.         MOVLW d'6'
  440.         CALL    CONV2ASCII
  441.         CALL    LCD_Data
  442.         MOVLW d'6'
  443.         BTFSC   NewKeyStatus,0
  444.         GOTO    NewPass     ; Der anmodes om en ny kode
  445.         MOVWF KEY
  446.         CALL KeyPressed
  447.         CALL Timeout
  448.         GOTO main
  449. Key7Pressed
  450.         MOVLW d'7'
  451.         CALL    CONV2ASCII
  452.         CALL    LCD_Data
  453.         MOVLW d'7'
  454.         BTFSC   NewKeyStatus,0
  455.         GOTO    NewPass     ; Der anmodes om en ny kode
  456.         MOVWF KEY
  457.         CALL KeyPressed
  458.         CALL Timeout
  459.         GOTO main
  460. Key8Pressed
  461.         MOVLW d'8'
  462.         CALL    CONV2ASCII
  463.         CALL    LCD_Data
  464.         MOVLW d'8'
  465.         BTFSC   NewKeyStatus,0
  466.         GOTO    NewPass     ; Der anmodes om en ny kode
  467.         MOVWF KEY
  468.         CALL KeyPressed
  469.         CALL Timeout
  470.         GOTO main
  471. Key9Pressed
  472.         MOVLW d'9'
  473.         CALL    CONV2ASCII
  474.         CALL    LCD_Data
  475.         MOVLW d'9'
  476.         BTFSC   NewKeyStatus,0
  477.         GOTO    NewPass     ; Der anmodes om en ny kode
  478.         MOVWF   KEY
  479.         CALL    KeyPressed
  480.         CALL    Timeout
  481.         GOTO    main
  482. Key10Pressed
  483.         LCDstr  hashtag
  484.         MOVLW d'10'
  485.         BTFSC   NewKeyStatus,0
  486.         GOTO    NewPass     ; Der anmodes om en ny kode
  487.         MOVWF   KEY
  488.         CALL    KeyPressed
  489.         CALL    Timeout
  490.         GOTO    main
  491. Key11Pressed
  492.         MOVLW   d'0'
  493.         CALL    CONV2ASCII 
  494.         CALL    LCD_Data    ; Printer tallet 0
  495.         MOVLW   d'11'
  496.         BTFSC   NewKeyStatus,0
  497.         GOTO    NewPass     ; Der anmodes om en ny kode
  498.         MOVWF   KEY
  499.         CALL    KeyPressed
  500.         CALL    Timeout
  501.         GOTO    main
  502. Key12Pressed
  503.         LCDstr  star
  504.         MOVLW   d'12'
  505.         BTFSC   NewKeyStatus,0
  506.         GOTO    NewPass     ; Der anmodes om en ny kode
  507.         MOVWF   KEY
  508.         CALL    KeyPressed
  509.         CALL    Timeout
  510.         GOTO    main
  511.  
  512. NewKeyTrigger
  513.         BSF     NewKeyStatus,0      ; Ny-kode tjek bit sat
  514.        
  515.         BTFSS   NewKeyStatus,1
  516.         CALL    InitializeNewKey
  517.         BSF     NewKeyStatus,1
  518.         RETURN
  519.  
  520. InitializeNewKey
  521.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  522.         CALL    LCD_Reg     ; Clear LCD
  523.         CALL    ClearKeys
  524.         LCDstr  newcodemsg
  525.         RETURN
  526.  
  527. NewPass
  528.         MOVWF   TempPassKey     ; Flytter tallet trykket til TempPassKey
  529.         CALL    Timeout         ; Håndterer prel
  530.        
  531.         INCF    NEWKEYCOUNT
  532.  
  533.         MOVLW   d'1'
  534.         XORWF   NEWKEYCOUNT,w
  535.         BTFSC   STATUS,Z        ;Skipper ikke hvis det er første gang i NewPass
  536.         GOTO    MoveKey1
  537.         MOVLW   d'2'
  538.         XORWF   NEWKEYCOUNT,w
  539.         BTFSC   STATUS,Z        ;Skipper ikke hvis det er anden gang i NewPass
  540.         GOTO    MoveKey2
  541.         MOVLW   d'3'
  542.         XORWF   NEWKEYCOUNT,w
  543.         BTFSC   STATUS,Z        ;Skipper ikke hvis det er tredje gang i NewPass
  544.         GOTO    MoveKey3
  545.         MOVLW   d'4'
  546.         XORWF   NEWKEYCOUNT,w
  547.         BTFSC   STATUS,Z        ;Skipper ikke hvis det er fjerde gang i NewPass
  548.         GOTO    MoveKey4
  549.         GOTO    main            ;Backup, burde ikke køres
  550.  
  551. MoveKey1
  552.        
  553.         MOVF    TempPassKey,w   ;Flytter tallet trykket til w
  554.         MOVWF   PassKey1        ;Flytter tallet trykket til PassKey1
  555.         GOTO    main
  556. MoveKey2
  557.        
  558.         MOVF    TempPassKey,w   ;Flytter tallet trykket til w
  559.         MOVWF   PassKey2        ;Flytter tallet trykket til PassKey2
  560.         GOTO    main
  561. MoveKey3
  562.         MOVF    TempPassKey,w   ;Flytter tallet trykket til w
  563.         MOVWF   PassKey3        ;Flytter tallet trykket til PassKey3
  564.         GOTO    main
  565. MoveKey4
  566.  
  567.         MOVF    TempPassKey,w   ;Flytter tallet trykket til w
  568.         MOVWF   PassKey4        ;Flytter tallet trykket til PassKey4
  569.  
  570.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  571.         CALL    LCD_Reg     ; Clear LCD
  572.  
  573.         BCF     StartMessage,0  ;Geninizilatiser startbesked til LED
  574.         LCDstr  newcodeconfirmedmsg
  575.         BSF PORTB,2
  576.         CALL    Timeout3
  577.         MOVLW   LCDCLR      ; Flyt Clear til W registret
  578.         CALL    LCD_Reg     ; Clear LCD
  579.         BCF PORTB,2
  580.  
  581.         CLRF    NEWKEYCOUNT             ;Resseter NEWKEYCOUNT
  582.         BCF     NewKeyStatus,0          ;Resseter ny-kode tjek bitten
  583.         BCF     NewKeyStatus,1          ;Resseter ny-kode trigger bitten
  584.         goto    main
  585.                
  586.        
  587.        
  588.  
  589. Timeout
  590.             MOVLW   D'45'               ; Tidsforsinkelse på ca. 450 ms
  591.             MOVWF   Delay3              ;
  592. Loop12      MOVLW   D'115'              ; h'73'= 115 tælles op <=> 255-115 =140 der tælles ned
  593.             MOVWF   Delay1              ;
  594.             MOVLW   D'32'               ; h'DF'= 223 tælles op <=> 255-223 =32 der tælles ned
  595.             MOVWF   Delay2              ;
  596. Loop1       DECFSZ  Delay1,F            ;
  597.             GOTO    Loop1               ;
  598.             MOVLW   D'115'              ;
  599.             MOVWF   Delay1              ;
  600.             DECFSZ  Delay2,F            ;
  601.             GOTO    Loop1               ;
  602.             DECFSZ  Delay3,F            ;
  603.             GOTO    Loop12              ;
  604.  
  605.             RETURN
  606.  
  607.  
  608. Timeout2
  609.             MOVLW   D'1'                ; Tidsforsinkelse på ca. 10 ms
  610.             MOVWF   Delay3              ;
  611. Loop123     MOVLW   D'115'              ; h'73'= 115 tælles op <=> 255-115 =140 der tælles ned
  612.             MOVWF   Delay1              ;
  613.             MOVLW   D'32'               ; h'DF'= 223 tælles op <=> 255-223 =32 der tælles ned
  614.             MOVWF   Delay2              ;
  615. Loop13      DECFSZ  Delay1,F            ;
  616.             GOTO    Loop13              ;
  617.             MOVLW   D'115'              ;
  618.             MOVWF   Delay1              ;
  619.             DECFSZ  Delay2,F            ;
  620.             GOTO    Loop13              ;
  621.             DECFSZ  Delay3,F            ;
  622.             GOTO    Loop123             ;
  623.  
  624.             RETURN
  625.  
  626. Timeout3
  627.             MOVLW   D'1000'             ; Tidsforsinkelse på ca. 10000 ms
  628.             MOVWF   Delay3              ;
  629. Loop124     MOVLW   D'115'              ; h'73'= 115 tælles op <=> 255-115 =140 der tælles ned
  630.             MOVWF   Delay1              ;
  631.             MOVLW   D'32'               ; h'DF'= 223 tælles op <=> 255-223 =32 der tælles ned
  632.             MOVWF   Delay2              ;
  633. Loop14      DECFSZ  Delay1,F            ;
  634.             GOTO    Loop14              ;
  635.             MOVLW   D'115'              ;
  636.             MOVWF   Delay1              ;
  637.             DECFSZ  Delay2,F            ;
  638.             GOTO    Loop14              ;
  639.             DECFSZ  Delay3,F            ;
  640.             GOTO    Loop124             ;
  641.  
  642.             RETURN
  643.  
  644. Timeout4
  645.             MOVLW   D'4'                ; Tidsforsinkelse på ca. 10000 ms
  646.             MOVWF   Delay3              ;
  647. Loop125     MOVLW   D'115'              ; h'73'= 115 tælles op <=> 255-115 =140 der tælles ned
  648.             MOVWF   Delay1              ;
  649.             MOVLW   D'32'               ; h'DF'= 223 tælles op <=> 255-223 =32 der tælles ned
  650.             MOVWF   Delay2              ;
  651. Loop15      DECFSZ  Delay1,F            ;
  652.             GOTO    Loop15              ;
  653.             MOVLW   D'115'              ;
  654.             MOVWF   Delay1              ;
  655.             DECFSZ  Delay2,F            ;
  656.             GOTO    Loop15              ;
  657.             DECFSZ  Delay3,F            ;
  658.             GOTO    Loop125             ;
  659.  
  660.             RETURN
  661.  
  662. ;ISR
  663. ;
  664. ;   RETFIE
  665.  
  666.  
  667.  
  668.  
  669.  
  670. ; ******* OPSÆTNING AF TEKST STRENGE ******************************************************
  671. org         0x700
  672. hashtag             string  "#"
  673. star                string  "*"
  674. lockmsg             string  "Låst"
  675. unlockmsg           string  "Åben"
  676. wrongmsg            string  "Forkert"
  677. newcodemsg          string  "Ny kode:"
  678. newcodeconfirmedmsg string  " Ny kode godkendt"
  679. welcomemsg          string  "Indtast kode:"
  680.  
  681. ; ******* PROGRAM AFSLUTTET ***************************************************************    
  682.             END                     ;her slutter programmet...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement