Advertisement
Guest User

Untitled

a guest
Oct 28th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include "common.h"
  2.  
  3. #define counter r10
  4. #define pin_A r31.t2
  5. #define pin_B r31.t16
  6.  
  7. .macro increment
  8. add counter, counter, 1
  9. sbco &counter, c24, 0, 4 // store counter to memory
  10. .endm
  11.  
  12. .macro decrement
  13. sub counter, counter, 1
  14. sbco &counter, c24, 0, 4 // store counter to memory
  15. .endm
  16.  
  17.  
  18. mov counter, 0
  19. sbco &counter, c24, 0, 4 // store initial counter to memory
  20.  
  21. // jump into right place of the loop based on initial state of A
  22. bbs Ahigh, pin_A
  23. jmp Alow
  24.  
  25. A0_Bfall:
  26. increment // B falling edge with A low
  27.  
  28. Alow:
  29. wbs pin_A // A is low, wait for A rise
  30. bbs Arise_B1, pin_B // A rising edge, check B
  31.  
  32. increment // A rising edge with B low
  33. jmp Blow
  34.  
  35.  
  36. Afall_B0:
  37. decrement // A falling edge with B low
  38.  
  39. Blow:
  40. wbs pin_B // B is low, wait for B rise
  41. bbs A1_Brise, pin_A // B rising edge, check A
  42.  
  43.  
  44. decrement // B rising edge with A low
  45. jmp Alow
  46.  
  47. A1_Brise:
  48. increment // B rising edge with A high
  49.  
  50. Ahigh:
  51. wbc pin_A // A is high, wait for A fall
  52. bbc Afall_B0, pin_B // A falling edge, check B
  53.  
  54. increment // A falling edge with B high
  55. jmp Bhigh
  56.  
  57. Arise_B1:
  58. decrement // A rising edge wit
  59.  
  60. Bhigh:
  61. wbc pin_B // B is high, wait for B fall
  62. bbc A0_Bfall, pin_A // B falling edge, check A
  63.  
  64. decrement // B falling edge with A high
  65. jmp Ahigh
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement