5_1_2.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. XDEF Entry
  2. XREF __SEG_END_SSTACK
  3. Variables: Section
  4. Constants: Section
  5. DDR_S equ $24A
  6. DDR_T equ $242
  7. PORT_T equ $240
  8. PORT_S equ $248
  9. ;starts high -> goes low -> goes high -> light on
  10. ;starts low -> goes high -> goes low -> goes high -> light on
  11. Code: Section
  12. Entry:
  13. BSET DDR_S,#$FF ;set all bits of DDR_S as output
  14. BSET DDR_T,#$00 ;clear all bits of DDR_T (input)
  15. BSET PORT_S,#$00 ;turn off all LED's
  16. Check1:
  17. ;if switch starts low
  18. LDAA #$00 ;condition of switch started low
  19. BRCLR PORT_T,#$01,AwaitHigh ;enter the high wait loop (switch started low)
  20. ;if switch starts high
  21. LDAA #$01 ;condition of switch started high
  22. ;proceed to low check loop if started high
  23. AwaitLow: ;loop until bit 0 is set low
  24. BRSET PORT_T,#$01,AwaitLow ;repeats if bit 0 is high/on (stops looping if low)
  25. AwaitHigh: ;loop until bit 0 is set high
  26. BRCLR PORT_T,#$01,AwaitHigh ;repeats if bit 0 is low/off (stops looping if high)
  27. ANDA #$01 ;checks if the switch started high
  28. BEQ AwaitLow ;if started low, wait for it to go high again
  29. Out:
  30. BSET PORT_S,#%01000000 ;turn on LED 6
  31. NOP