Advertisement
Slyfoxx724

Untitled

Jan 27th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1.  
  2. list p=18F1220 ;Set processor
  3. radix hex
  4. config WDT=OFF, LVP=OFF
  5.  
  6. #define PORTB 0xF81
  7. #define TRISB 0xF93
  8. #define ADCON1 0xFC1
  9. #define STATUS 0xFD8
  10.  
  11. INPUTS_CURR equ 0x080
  12. INPUTS_PREV equ 0x081
  13. INPUTS_B1_B0 equ 0x082
  14. RESULT equ 0x083
  15.  
  16. org 0x000
  17.  
  18. CLRF PORTB
  19. MOVLW 0x7F
  20. MOVWF ADCON1
  21. MOVLW 0x0F
  22. MOVWF TRISB
  23. CLRF PORTB
  24. CLRF INPUTS_PREV
  25.  
  26.  
  27. Loop: MOVFF PORTB, INPUTS_CURR
  28. MOVF INPUTS_PREV, W
  29. XORWF INPUTS_CURR, W
  30. ANDLW 0x0F
  31. BTFSS STATUS, 2
  32. CALL Adder
  33. MOVFF INPUTS_CURR, INPUTS_PREV
  34. BRA Loop
  35.  
  36.  
  37. Adder: MOVF INPUTS_CURR, W
  38. ANDLW 0x0C ;Isolating bits B1, B0, setting rest to 0
  39. MOVWF INPUT_B1_B0
  40. RRNCF INPUT_B1_B0 ;Shifts bits to right (Rotate Right No Carry)
  41. RRNCF INPUT_B1_B0
  42.  
  43. MOVF INPUTS_CURR, W
  44. ANDLW 0x03 ;Isolates A1, A0
  45.  
  46. ADDWF INPUT_B1_B0, W ;Adding (B1, B0) with (A1, A0)
  47. MOVWF RESULT
  48.  
  49. RLNCF RESULT
  50. RLNCF RESULT
  51. RLNCF RESULT
  52. RLNCF RESULT
  53. RLNCF RESULT
  54.  
  55. MOVFF RESULT, PORTB
  56.  
  57. RETURN
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement