home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / PicSim / examples / parallax / 84.SRC < prev    next >
Encoding:
Text File  |  1978-03-06  |  4.1 KB  |  216 lines

  1.  
  2.  
  3.          DEVICE   PIC16C84,HS_OSC,WDT_OFF,PROTECT_OFF
  4.  
  5.  
  6.  
  7. ;this is a test source for PicSim (device=16C84)
  8. ;the commands are from Microchip, the assembler from parallax
  9. ;Copyright 04.02.97 Dirk Düsterberg
  10.  
  11.  
  12.  
  13.  
  14.  
  15. START    ADDWF    0Ch,0    ; C,DC,Z    add w and fileregister to w
  16.     ADDWF    0Ch,1    ; C,DC,Z    add w and fileregister to fileregister
  17.  
  18.  
  19.     ANDLW    115    ; Z         literal and w to w
  20.  
  21.     
  22.     ANDWF    0Ch,0    ; Z        fileregister and w to w
  23.     ANDWF    0Ch,1    ; Z        fileregister and w to fileregister
  24.  
  25.  
  26.     BCF    0Ch,7    ;        clear bit from fileregister
  27.     BSF    0Ch,7    ;        set bit from fileregister
  28.  
  29.  
  30.     BTFSC    0Ch,4    ;        skip next command if bit 0
  31.     BTFSS    0Ch,5    ;        skip next command if bit 1
  32.  
  33.  
  34.     CALL    LABEL    ;        call subroutine
  35.  
  36.  
  37.     CLRF    0Ch    ; Z        clear fileregister
  38.     CLRW        ; Z        clear w
  39.     CLRWDT        ; TO,PD        clear watchdogtimer
  40.  
  41.     
  42.     COMF    0Ch,0    ; Z        complement from fileregister to w
  43.     COMF    0Ch,1    ; Z        complement from fileregister to fileregister
  44.  
  45.  
  46.     DECF    0Ch,0    ; Z        count fileregister down to w
  47.     DECF    0Ch,1    ; Z        count fileregister down to fileregister
  48.  
  49.  
  50.     DECFSZ    0Ch,0    ;        count fileregister down to w and springe falls 0
  51.     DECFSZ    0Ch,1    ;        count fileregister down to fileregister and springe falls 0
  52.  
  53.  
  54.     INCF    0Ch,0    ; Z        count fileregister up to w
  55.     INCF    0Ch,1    ; Z        count fileregister up to fileregister
  56.  
  57.     
  58.     INCFSZ    0Ch,0    ;        count fileregister up to w and springe falls 0
  59.     INCFSZ    0Ch,1    ;        count fileregister up to fileregister and springe falls 0
  60.  
  61.     
  62.     IORLW    115    ; Z        write literal or w in w
  63.  
  64.  
  65.     IORWF    0Ch,0    ; Z        write fileregister or w to w
  66.     IORWF    0Ch,1    ; Z        write fileregister or w to fileregister
  67.  
  68.  
  69.     MOVF    0Ch,0    ; Z        write fileregister to w
  70.     MOVF    0Ch,1    ; Z        write fileregister to fileregister
  71.  
  72.     
  73.     MOVLW    115    ;        write literal to w
  74.  
  75.  
  76.     MOVWF    0Ch    ;         write w to fileregister
  77.  
  78.  
  79.     NOP        ;         no operation
  80.  
  81.  
  82.     OPTION        ;        write w in optionregister
  83.  
  84.  
  85.     RLF    0Ch,0    ; C        rotate fileregister left to w
  86.     RLF    0Ch,1    ; C        rotate fileregister left to fileregister
  87.  
  88.     
  89.     RRF    0Ch,0    ; C        rotate fileregister right to w
  90.     RRF    0Ch,1    ; C        rotate fileregister right to fileregister
  91.  
  92.  
  93.     SLEEP        ; TO,PD     do the sleep mode
  94.  
  95.  
  96.     SUBWF    0Ch,0    ; C,DC,Z    substract w from fileregister to w
  97.     SUBWF    0Ch,1    ; C,DC,Z    substract w from fileregister to fileregister
  98.  
  99.  
  100.     SWAPF    0Ch,0    ;        swap nibbles from fileregister to w
  101.     SWAPF    0Ch,1    ;        swap nibbles from fileregister to fileregister
  102.  
  103.  
  104.     TRIS    ra    ;        write w in tristate Register from port b
  105.     TRIS    rb    ;        write w in tristate Register from port b
  106.  
  107.  
  108. ;    XORLW    #15    ; Z        write literal exclusiv oder w to w
  109.  
  110.     
  111.     XORWF    0Ch,0    ; Z        write w exclusiv oder fileregister to w
  112.     XORWF    0Ch,1    ; Z        write w exclusiv oder fileregister to fileregister
  113.  
  114.     
  115.     
  116.     GOTO    START
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. LABEL    MOV    RA,#05h    ;          write literal to port
  128.     MOV    RB,#0aah         
  129.  
  130.  
  131.     MOV    !RA,#0h    ;          write literal ins tristate register
  132.     MOV    !RB,#45
  133.  
  134.     
  135.     MOV    w,RA    ;          write port to w
  136.     MOV    w,RB
  137.  
  138.  
  139.  
  140.  
  141.     SETB    RA.0    ;          set bit 0 from Port A
  142.     clrb    RA.0    ;          clear bit 0 from Port A
  143.  
  144.  
  145.     XOR    RA,#00000010b    ;  toggle (exclusive or) bit 1 from port A
  146.  
  147.     BTFSC    RA.1    ;          skip next command if not bit
  148.  
  149.     RETW    127     ;       jump back from subroutine and write literal to w
  150.     RETW    63     ;       jump back from subroutine and write literal to w
  151.          
  152.     
  153.  
  154.  
  155.  
  156.  
  157. ;indirect file addressing (clear fileregister betwen 0Ch and 1fh)
  158.  
  159.  
  160.     mov    FSR,#0Ch    ;file adress pointer to 10h
  161.     
  162.  
  163. milka    clr    INDIRECT    ;clear the indirect address
  164.     inc    FSR        ;next register
  165.     sb    FSR.5        ;all done ? (FSR >= 20h ?)
  166.     jmp    milka        ;do it
  167.     
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175. ;Data EEProm access
  176.  
  177. witedat mov     EEADR,0eh    ;0e is my address
  178.         
  179.         mov     EEDATA,0fh    ;0f is my data
  180.         
  181.  
  182.         setb    STATUS.5    ;select PAGE1
  183.  
  184.         setb    EECON1.2    ;set EEPROM write enable
  185.  
  186.     mov     EECON2,#55h
  187.     mov     EECON2,#0AAh
  188.         
  189.         setb    EECON1.1    ;init a write cycle
  190.  
  191.  
  192.  
  193.  
  194.  
  195. wait    sb    EECON1.4    ;wait for write to finish
  196.         jmp    wait
  197.     clr    EECON1        ;EEPROM write disable & int accept
  198.  
  199.         clrb    STATUS.5    ;select PAGE0
  200.         
  201.  
  202.  
  203.  
  204.  
  205. readdat clrb    STATUS.5
  206.     mov    EEADR,W
  207.         setb    STATUS.5            ;select PAGE1
  208.  
  209.         setb    EECON1.0            ;EEPROM read
  210.         clrb    STATUS.5            ;select PAGE0
  211.  
  212.         mov    w,EEDATA
  213.         
  214.     GOTO    START
  215.  
  216.