sskss73

Untitled

May 13th, 2021 (edited)
223
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CSEG AT 0000H
  2. LJMP 0030H
  3.  
  4. ;ISR hozzarendelese az interrupt vektorhoz
  5. CSEG AT 000BH
  6. LJMP ISR_TIMER0_OVF
  7.  
  8. CSEG AT 0030H
  9. MOV SP, #2FH
  10. MOV P2, #16
  11. MOV R0, #1
  12. MOV R1, #0
  13. MOV DPTR, #0C001H
  14.  
  15. S_INIT_T0MODE1_FREERUN:
  16. ANL TMOD ,#0F0H
  17. ORL TMOD ,#01H
  18. SETB TR0
  19.  
  20. S_INIT_INTERRUPTS:
  21. SETB ET0
  22. SETB EA
  23.  
  24. END_OF_PROGRAM:
  25. LJMP END_OF_PROGRAM
  26.  
  27. RUN:
  28. ;Ha R1 == 0, a jobbra szamolot hivjuk meg, ha 1, akkor nem ugrunk, es rafutunk a balra szamolora
  29. CJNE R1,#1,RUN_RIGHT
  30.  
  31. RUN_LEFT:
  32. MOV A, P2
  33. RL A
  34. MOV P2, A
  35.  
  36. CPL A
  37. MOVX @DPTR,A
  38. CPL A
  39.  
  40. ;Ha a porton az MSB aktiv, iranyt valtunk, LEFT->RIGHT iranyba megyunk
  41. ANL A, #0x7F
  42. JZ DECREASE
  43. RET
  44.  
  45. DECREASE:
  46. MOV R1,#0H
  47. RET
  48.  
  49. INCREASE:
  50. MOV R1,#1H
  51. RET
  52.  
  53. RUN_RIGHT:
  54. MOV A, P2
  55. RR A
  56. MOV P2,A
  57. CPL A
  58. MOVX @DPTR,A
  59. CPL A
  60.  
  61. ;ha a porton az LSB aktiv, iranyt valtunk, RIGHT->LEFT iranyba megyunk
  62. ANL A, #0xFE
  63. JZ INCREASE
  64. RET
  65.  
  66. ISR_TIMER0_OVF:
  67. LCALL RUN
  68. RETI
  69.  
  70. END
  71.  
RAW Paste Data