| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- XDEF Entry
- XREF __SEG_END_SSTACK
- Variables: Section
- Constants: Section
- DDR_S equ $24A
- DDR_T equ $242
- PORT_T equ $240
- PORT_S equ $248
- ;starts high -> goes low -> goes high -> light on
- ;starts low -> goes high -> goes low -> goes high -> light on
- Code: Section
- Entry:
- BSET DDR_S,#$FF ;set all bits of DDR_S as output
- BSET DDR_T,#$00 ;clear all bits of DDR_T (input)
- BSET PORT_S,#$00 ;turn off all LED's
- Check1:
- ;if switch starts low
- LDAA #$00 ;condition of switch started low
- BRCLR PORT_T,#$01,AwaitHigh ;enter the high wait loop (switch started low)
- ;if switch starts high
- LDAA #$01 ;condition of switch started high
- ;proceed to low check loop if started high
- AwaitLow: ;loop until bit 0 is set low
- BRSET PORT_T,#$01,AwaitLow ;repeats if bit 0 is high/on (stops looping if low)
- AwaitHigh: ;loop until bit 0 is set high
- BRCLR PORT_T,#$01,AwaitHigh ;repeats if bit 0 is low/off (stops looping if high)
- ANDA #$01 ;checks if the switch started high
- BEQ AwaitLow ;if started low, wait for it to go high again
- Out:
- BSET PORT_S,#%01000000 ;turn on LED 6
- NOP
|