1
0

5_2.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. XDEF Entry
  2. XREF __SEG_END_SSTACK
  3. ; variable/data w
  4. MY_EXTENDED_RAM: SECTION
  5. FORWARD dc.b $0A,$12,$14,$0C,$00
  6. REVERSE dc.b $0C,$14,$12,$0A,$00
  7. PORT_P equ $258
  8. DDR_P equ $25A
  9. PORT_T equ $240
  10. DDR_T equ $242
  11. MY_CONSTANT_ROM: SECTION ; constant/definition section
  12. ; code section
  13. MyCode: SECTION
  14. main:
  15. _Startup:
  16. Entry:
  17. LDAA #$1E ;load the proper DDR direction modes to acc. A
  18. STAA DDR_P ;push the DDR direction modes into port P DDR
  19. LDAA #00 ;load port T DDR into acc. A
  20. STAA DDR_T ;push direction to port T DDR
  21. Main:
  22. BRSET PORT_P,#%00000011,Main ;do nothing if both bits are set
  23. BRCLR PORT_P,#%00000011,Main ;do nothing if both bits are clear
  24. StartForward:
  25. LDX #FORWARD ;load the start of sequence of bytes to spin the motor into register X
  26. BRA Spin
  27. StartReverse: ;initialize the reverse loop
  28. LDX #REVERSE
  29. BRA Spin
  30. Spin:
  31. LDAA 1,x+ ;load into A the first value of the array
  32. CMPA #00 ;check that we are not at the end of the array
  33. BEQ Main ;if we are at the end of the array, reload the first array value
  34. STAA PORT_P ;push the value in accumulator A to port P, spinning the motor one quarter turn
  35. ;check fast or slow
  36. ;branch to appropriate delay
  37. ;check direction
  38. ;branch to appropriate start direction
  39. ShortDelay: ;implement a 15 ms delay
  40. LDY #15000
  41. BRA DelayLoop
  42. LongDelay:
  43. LDY #60000 ;implement a 60 ms delay
  44. BRA DelayLoop
  45. DelayLoop: ;loop execution
  46. DEY ;decrement our delay value by 1
  47. BNE DelayLoop ;if we have not decreased our delay value to zero, continue
  48. ;decrementing our array value
  49. BRA Main ;repeat the code which turns the motor