Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 8.62 KB | None | 0 0
  1. ;
  2. ;   MPASM template supplied by BILBOROUGH COLLEGE  28228
  3.  
  4.  
  5. ;NAME ...................................................ENTER YOUR NAME AND PROJECT TITLE HERE
  6.  
  7. ;PROGRAM TITLE ...................................................
  8.  
  9. ; Version 2 board settings: J14 links: Digital
  10. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::
  11. ;
  12. ; The following lines embed configuration data into the PICmicro
  13.     LIST P=16F88
  14.     __CONFIG H'2007', H'3F7A'       ; RC mode
  15.     __CONFIG H'2008', H'3FFC'       ; Clock Fail-Safe disabled
  16.  
  17. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  18.  
  19.                
  20. #DEFINE PAGE0   BCF     STATUS,5   
  21. #DEFINE PAGE1   BSF     STATUS,5   
  22.                
  23. OPSHUN  EQU H'81'       ;
  24. STATUS  EQU H'03'       ;defines status register
  25. TRISA   EQU H'5'        ;defines trisA register
  26. PORTA   EQU H'05'       ;defines portA register
  27. TRISB   EQU H'6'        ;defines TrisB register
  28. PORTB   EQU H'06'       ;defines portB register
  29. PCL EQU H'02'       ;Names the register called program counter
  30. W   EQU 0       ;Sets up the name used for the working register
  31. F   EQU 1       ;Sets up the name used for file
  32. Z   EQU 2       ;Sets up the name used for the zero flag
  33. C       EQU     0           ;Sets up the name used for the carry flag
  34.  
  35.  
  36. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  37.  
  38. ;       NAME YOUR REGISTERS HERE
  39.                
  40. timer   EQU H'0C'       ;names the register called ????????
  41. line1   EQU H'0D'       ;names the register called ????????
  42. line2   EQU H'0E'       ;names the register called ????????      DELETE THIS SECTION IF NOT USING REGISTERS
  43. line3   EQU H'0F'       ;names the register called ????????
  44. dam EQU H'10'       ;names the register called ????????
  45. delayf  EQU H'11'       ;names the register called ????????
  46.  
  47. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  48.  
  49. ;       VECTORS
  50.                
  51.     ORG 00      ; Reset vector
  52.     GOTO    XYZ     ; Goto start of program
  53.     ORG 04      ; Interrupt vector address
  54.     GOTO    05      ; Goto start of program
  55.     ORG 05      ; Start of program memory
  56.        
  57. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  58.  
  59. ;       THIS SECTION IS USED TO SET THE DIRECTION OF THE OUTPUT PORTS.
  60.  
  61. ;ENTER the binary number for the Data Direction in the TRIS registers.
  62. ;Use 0 if you would like an output or 1 if you would like an input.
  63.  
  64. XYZ BSF STATUS,5    ;Bank 1 operation
  65.     CLRF    H'1B'       ;Makes the ANSEL (analogue) inputs digital
  66.     MOVLW   B'00011111';
  67.     MOVWF   TRISA       ;This sets portA data direction to #######
  68.     MOVLW   B'00000000' ;
  69.     MOVWF   TRISB       ;This sets portB data direction to #######
  70.     BCF STATUS,5    ;Back to bank 0
  71.  
  72. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  73.  
  74. ;   MAIN PROGRAM
  75.  
  76. start   CLRF    PORTA
  77.     CLRF    PORTB
  78.     CLRF    STATUS
  79.     CLRF    timer
  80.     CLRF    line1
  81.     CLRF    line2
  82.     CLRF    line3
  83.     CLRF    dam
  84.     CLRF    delayf
  85.  
  86.     CALL    input1
  87.     CALL    a8sub
  88.     CALL    a1sub5 
  89.  
  90.  
  91.  
  92.    
  93. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  94.  
  95. ;   SUBROUTINES
  96.  
  97. ; Any subroutines to go in this section.
  98.  
  99. input1  BTFSC   PORTA,0
  100.     GOTO    wait0
  101.     BTFSC   PORTA,1
  102.     GOTO    wait1
  103.     BTFSC   PORTA,2
  104.     GOTO    wait2
  105.     BTFSC   PORTA,3
  106.     GOTO    wait3
  107.     BTFSC   PORTA,4
  108.     GOTO    wait4
  109.     GOTO    input1
  110.  
  111.  
  112.  
  113. wait0   BTFSC   PORTA,0
  114.     GOTO    wait0
  115.     RETURN
  116.  
  117. wait1   BTFSC   PORTA,1
  118.     GOTO    wait1
  119.     GOTO    add1
  120.  
  121. wait2   BTFSC   PORTA,2
  122.     GOTO    wait2
  123.     GOTO    add2
  124.  
  125. wait3   BTFSC   PORTA,3
  126.     GOTO    wait3
  127.     GOTO    add4
  128.  
  129.  
  130. wait4   BTFSC   PORTA,4
  131.     GOTO    wait4
  132.     GOTO    add8
  133.  
  134.  
  135.  
  136.  
  137. add1    MOVLW   B'00000001'
  138.     ADDWF   timer,F
  139.     GOTO    input1
  140.  
  141. add2    MOVLW   B'00000011'
  142.     ADDWF   timer,F
  143.     GOTO    input1
  144.  
  145. add4    MOVLW   B'00000110'
  146.     ADDWF   timer,F
  147.     GOTO    input1
  148.  
  149. add8    MOVLW   B'00011101'
  150.     ADDWF   timer,F
  151.     GOTO    input1
  152.  
  153.  
  154.  
  155.  
  156. a1sub   MOVLW   B'00000110'
  157.     ADDWF   timer,F
  158.     CLRF    STATUS
  159.     MOVLW   B'00000001'
  160.     SUBWF   timer,F
  161.     BTFSC   STATUS,0
  162.     RETURN
  163.     INCF    line1,F
  164.     GOTO    a1sub
  165.  
  166. a4sub   MOVLW   B'00011101'
  167.     ADDWF   timer,F
  168.     CLRF    STATUS
  169.     MOVLW   B'00000110'
  170.     SUBWF   timer,F
  171.     BTFSC   STATUS,0
  172.     GOTO    a1sub
  173.     INCF    line2,F
  174.     GOTO    a4sub
  175.  
  176. a8sub   MOVLW   B'00011101'
  177.     SUBWF   timer,F
  178.     BTFSC   STATUS,0
  179.     GOTO    a4sub
  180.     INCF    line3,F
  181.     GOTO    a8sub
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. a1sub5  CLRF    STATUS
  189.     MOVLW   B'00000101'
  190.     SUBWF   line3,F
  191.     BTFSC   STATUS,0
  192.     GOTO    a1sub4
  193.     GOTO    a5dlay5
  194.  
  195. a5dlay5 CALL    a5lght5
  196.     CALL    a5del
  197.     CALL    a5lght4
  198.     CALL    a5del
  199.     CALL    a5lght3
  200.     CALL    a5del
  201.     CALL    a5lght2
  202.     CALL    a5del
  203.     CALL    5lght1
  204.     CALL    a5del
  205.     GOTO    a2sub4
  206.    
  207. a1sub4  MOVLW   B'00000101'
  208.     ADDWF   line3,F
  209.     CLRF    STATUS
  210.     MOVLW   B'00000100'
  211.     SUBWF   line3,F
  212.     BTFSC   STATUS,0
  213.     GOTO    a1sub3
  214.     GOTO    a5dlay4
  215.  
  216. a5dlay4 CALL    a5lght4
  217.     CALL    a5del
  218.     CALL    a5lght3
  219.     CALL    a5del
  220.     CALL    a5lght2
  221.     CALL    a5del
  222.     CALL    a5lght1
  223.     CALL    a5del
  224.     GOTO    a2sub4
  225.  
  226. a1sub3  MOVLW   B'00000100'
  227.     ADDWF   line3,F
  228.     CLRF    STATUS
  229.     MOVLW   B'00000011'
  230.     SUBWF   line3,F
  231.     BTFSC   STATUS,0
  232.     GOTO    a1sub2
  233.     GOTO    a5dlay3
  234.    
  235. a5dlay3 CALL    a5lght3
  236.     CALL    a5del
  237.     CALL    a5lght2
  238.     CALL    a5del
  239.     CALL    a5lght1
  240.     CALL    a5del
  241.     GOTO    a2sub4
  242.  
  243. a1sub2  MOVLW   B'00000011'
  244.     ADDWF   line3,F
  245.     CLRF    STATUS
  246.     MOVLW   B'00000010'
  247.     SUBWF   line3,F
  248.     BTFSC   STATUS,0
  249.     GOTO    a1sub1
  250.     GOTO    a5dlay2
  251.  
  252. a5dlay2 CALL    a5lght2
  253.     CALL    a5del
  254.     CALL    a5lght1
  255.     CALL    a5del
  256.     GOTO    a2sub4
  257.  
  258. a1sub1  MOVLW   B'00000010'
  259.     ADDWF   line3,F
  260.     CLRF    STATUS
  261.     MOVLW   B'00000001'
  262.     SUBWF   line3,F
  263.     BTFSC   STATUS,0
  264.     GOTO    a2sub4
  265.     GOTO    a5dlay1
  266.  
  267. a5dlay1 CALL    a5lght1
  268.     CALL    a5del
  269.     GOTO    a2sub4
  270.  
  271.  
  272. a5lght5 MOVLW   B'01111111'
  273.     MOVWF   PORTB
  274.     RETURN
  275.  
  276. a5lght4 MOVLW   B'01111110'
  277.     MOVWF   PORTB
  278.     RETURN
  279.  
  280. a5lght3 MOVLW   B'01111100'
  281.     MOVWF   PORTB
  282.     RETURN
  283.  
  284. a5lght2 MOVLW   B'01111000'
  285.     MOVWF   PORTB
  286.     RETURN
  287.  
  288. a5lght1 MOVLW   B'01110000'
  289.     MOVWF   PORTB
  290.     RETURN
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.    
  299. a2sub4  CLRF    STATUS
  300.     MOVLW   B'00000100'
  301.     SUBWF   line2,F
  302.     BTFSC   STATUS,0
  303.     GOTO    a2sub3
  304.     GOTO    a1dlay4
  305.  
  306. a1dlay4 CALL    a4lght4
  307.     CALL    a1del
  308.     CALL    a4lght3
  309.     CALL    a1del
  310.     CALL    a4lght2
  311.     CALL    a1del
  312.     CALL    a4lght1
  313.     CALL    a1del
  314.     GOTO    a3sub5
  315.  
  316. a2sub3  MOVLW   B'00000100'
  317.     ADDWF   line2,F
  318.     CLRF    STATUS
  319.     MOVLW   B'00000011'
  320.     SUBWF   line2,F
  321.     BTFSC   STATUS,0
  322.     GOTO    a2sub2
  323.     GOTO    a1dlay3
  324.    
  325. a1dlay3CALL a4lght3
  326.     CALL    a1del
  327.     CALL    a4lght2
  328.     CALL    a1del
  329.     CALL    a4lght1
  330.     CALL    a1del
  331.     GOTO    a3sub5
  332.  
  333. a2sub2  MOVLW   B'00000011'
  334.     ADDWF   line2,F
  335.     CLRF    STATUS
  336.     MOVLW   B'00000010'
  337.     SUBWF   line2,F
  338.     BTFSC   STATUS,0
  339.     GOTO    a2sub1
  340.     GOTO    a1dlay2
  341.  
  342. a1dlay2 CALL    a4lght2
  343.     CALL    a1del
  344.     CALL    a4lght1
  345.     CALL    a1del
  346.     GOTO    a3sub5
  347.  
  348. a2sub1  MOVLW   B'00000010'
  349.     ADDWF   line2,F
  350.     CLRF    STATUS
  351.     MOVLW   B'00000001'
  352.     SUBWF   line2,F
  353.     BTFSC   STATUS,0
  354.     GOTO    a3sub5
  355.     GOTO    a1dlay1
  356.  
  357. a1dlay1 CALL    a4lght1
  358.     CALL    a1del
  359.     GOTO    a3sub5
  360.  
  361. a4lght4 MOVLW   B'10111110'
  362.     MOVWF   PORTB
  363.     RETURN
  364.  
  365. a4lght3 MOVLW   B'10111100'
  366.     MOVWF   PORTB
  367.     RETURN
  368.  
  369. a4lght2 MOVLW   B'10111000'
  370.     MOVWF   PORTB
  371.     RETURN
  372.  
  373. a4lght1 MOVLW   B'10110000'
  374.     MOVWF   PORTB
  375.     RETURN
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385. a3sub5  CLRF    STATUS
  386.     MOVLW   B'00000101'
  387.     SUBWF   line1,F
  388.     BTFSC   STATUS,0
  389.     GOTO    a3sub4
  390.     GOTO    mdelay5
  391.  
  392. mdelay5 CALL    a3lght5
  393.     CALL    a10del
  394.     CALL    a3lght4
  395.     CALL    a10del
  396.     CALL    a3lght3
  397.     CALL    a10del
  398.     CALL    a3lght2
  399.     CALL    a10del
  400.     CALL    a3lght1
  401.     CALL    a10del
  402.     GOTO    tend
  403.    
  404. a3sub4  MOVLW   B'00000101'
  405.     ADDWF   line1,F
  406.     CLRF    STATUS
  407.     MOVLW   B'00000100'
  408.     SUBWF   line1,F
  409.     BTFSC   STATUS,0
  410.     GOTO    a3sub3
  411.     GOTO    mdelay4
  412.  
  413. mdelay4 CALL    a3lght4
  414.     CALL    a10del
  415.     CALL    a3lght3
  416.     CALL    a10del
  417.     CALL    a3lght2
  418.     CALL    a10del
  419.     CALL    a3lght1
  420.     CALL    a10del
  421.     GOTO    tend
  422.  
  423. a3sub3  MOVLW   B'00000100'
  424.     ADDWF   line1,F
  425.     CLRF    STATUS
  426.     MOVLW   B'00000011'
  427.     SUBWF   line1,F
  428.     BTFSC   STATUS,0
  429.     GOTO    a3sub2
  430.     GOTO    mdelay3
  431.    
  432. mdelay3 CALL    a3lght3
  433.     CALL    a10del
  434.     CALL    a3lght2
  435.     CALL    a10del
  436.     CALL    a3lght1
  437.     CALL    a10del
  438.     GOTO    tend
  439.  
  440. a3sub2  MOVLW   B'00000011'
  441.     ADDWF   line1,F
  442.     CLRF    STATUS
  443.     MOVLW   B'00000010'
  444.     SUBWF   line1,F
  445.     BTFSC   STATUS,0
  446.     GOTO    mdelay1
  447.     GOTO    mdelay2
  448.  
  449. mdelay2 CALL    a3lght2
  450.     CALL    a10del
  451.     CALL    a3lght1
  452.     CALL    a10del
  453.     GOTO    tend
  454.  
  455. a3sub1  MOVLW   B'00000010'
  456.     ADDWF   line1,F
  457.     CLRF    STATUS
  458.     MOVLW   B'00000001'
  459.     SUBWF   line1,F
  460.     BTFSC   STATUS,0
  461.     GOTO    tend
  462.     GOTO    a5dlay1
  463.  
  464. mdelay1 CALL    a3lght1
  465.     CALL    a10del
  466.     GOTO    tend
  467.  
  468.  
  469. a3lght5 MOVLW   B'11011111'
  470.     MOVWF   PORTB
  471.     RETURN
  472.  
  473. a3lght4 MOVLW   B'11011110'
  474.     MOVWF   PORTB
  475.     RETURN
  476.  
  477. a3lght3 MOVLW   B'11011100'
  478.     MOVWF   PORTB
  479.     RETURN
  480.  
  481. a3lght2 MOVLW   B'11011000'
  482.     MOVWF   PORTB
  483.     RETURN
  484.  
  485. a3lght1 MOVLW   B'11010000'
  486.     MOVWF   PORTB
  487.     RETURN
  488.  
  489.  
  490.  
  491.  
  492. a5del   MOVLW   B'00011110'
  493.     MOVWF   dam
  494.     DECF    dam
  495.     CALL    acdel
  496.     RETURN
  497.  
  498.  
  499.  
  500. a1del   MOVLW   B'00000110'
  501.     MOVWF   dam
  502.     DECF    dam
  503.     CALL    acdel
  504.     RETURN
  505.  
  506.  
  507. a10del  MOVLW   B'00000001'
  508.     MOVWF   dam
  509.     DECF    dam
  510.     CALL    acdel
  511.     RETURN
  512.  
  513.  
  514. acdel   MOVLW   B'11111111'
  515.     MOVWF   delayf
  516. acdel2  DECFSZ  delayf,F
  517.     GOTO    acdel2
  518.     DECFSZ  dam,F
  519.     RETURN
  520.  
  521.  
  522. tend    CALL    flash
  523.     CALL    flash
  524.     CALL    flash
  525.     CALL    flash
  526.     CALL    flash
  527.     GOTO    start
  528.  
  529. flash   MOVLW   B'00011111'
  530.     MOVWF   PORTB
  531.     MOVLW   B'11111111'
  532.     MOVWF   PORTB
  533.     MOVLW   B'00011111'
  534.     MOVWF   PORTB
  535.     MOVLW   B'11111111'
  536.     MOVWF   PORTB
  537.     MOVLW   B'00011111'
  538.     MOVWF   PORTB
  539.     MOVLW   B'11111111'
  540.     MOVWF   PORTB
  541.     MOVLW   B'00011111'
  542.     MOVWF   PORTB
  543.     MOVLW   B'11111111'
  544.     MOVWF   PORTB
  545.     RETURN
  546.  
  547.  
  548.     END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement