| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- XDEF Entry
- XREF __SEG_END_SSTACK
- ; variable/data w
- MY_EXTENDED_RAM: SECTION
- FORWARD dc.b $0A,$12,$14,$0C,$00
- REVERSE dc.b $0C,$14,$12,$0A,$00
- PORT_P equ $258
- DDR_P equ $25A
- PORT_T equ $240
- DDR_T equ $242
- MY_CONSTANT_ROM: SECTION ; constant/definition section
- ; code section
- MyCode: SECTION
- main:
- _Startup:
- Entry:
- LDAA #$1E ;load the proper DDR direction modes to acc. A
- STAA DDR_P ;push the DDR direction modes into port P DDR
- LDAA #00 ;load port T DDR into acc. A
- STAA DDR_T ;push direction to port T DDR
- Main:
- BRSET PORT_P,#%00000011,Main ;do nothing if both bits are set
- BRCLR PORT_P,#%00000011,Main ;do nothing if both bits are clear
- StartForward:
- LDX #FORWARD ;load the start of sequence of bytes to spin the motor into register X
- BRA Spin
- StartReverse: ;initialize the reverse loop
- LDX #REVERSE
- BRA Spin
- Spin:
- LDAA 1,x+ ;load into A the first value of the array
- CMPA #00 ;check that we are not at the end of the array
- BEQ Main ;if we are at the end of the array, reload the first array value
- STAA PORT_P ;push the value in accumulator A to port P, spinning the motor one quarter turn
- ;check fast or slow
- ;branch to appropriate delay
- ;check direction
- ;branch to appropriate start direction
- ShortDelay: ;implement a 15 ms delay
- LDY #15000
- BRA DelayLoop
- LongDelay:
- LDY #60000 ;implement a 60 ms delay
- BRA DelayLoop
- DelayLoop: ;loop execution
- DEY ;decrement our delay value by 1
- BNE DelayLoop ;if we have not decreased our delay value to zero, continue
- ;decrementing our array value
- BRA Main ;repeat the code which turns the motor
|