1
0

4_1_2.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. XDEF Entry
  2. XREF __SEG_END_SSTACK
  3. Variables: Section
  4. Constants: Section
  5. SEQUENCE_1 dc.b $81,$42,$24,$18,$24,$42,$42,$00
  6. SEQUENCE_2 dc.b $80,$40,$20,$10,$08,$04,$01,$01,$00
  7. DDR_S equ $24A
  8. DDR_T equ
  9. PORT_S equ $248
  10. PORT_T equ $240
  11. Code: Section
  12. Entry:
  13. LDAA #$FF ;load all 1’s to acc. A
  14. STAA DDR_S ;set all 1’s from acc. to Port S DDR (all outputs)
  15. LDAA #$00 ;8-bit all 0’s in acc. A
  16. STAA DDR_T ;set all 0’s for Port T DDR (all inputs)
  17. ;use register X to point to the index of SEQUENCE_1
  18. ;use register Y to point to the index of SEQUENCE_2
  19. ;use acc. A to output the LED’s at Port S
  20. ;use acc. B to read the DIP switch at Port T
  21. Loop1: ;loop for SEQUENCE_1
  22. LDX #SEQUENCE_1 ;load the address of the 1st seq. value to reg. X
  23. LDAA 1,X+ ;load the value at address X to acc. A, increment X
  24. STAA PORT_S ;output the value of acc. A to PORT_S
  25. LDAB PORT_T ;load the DIP switches to acc. B
  26. CMPB #$00 ;check if the DIP switches are all off
  27. BNE Loop2 ;branch to Loop2 if a switch is on
  28. CMPA #$00 ;check if we are at the end of the array
  29. BEQ Loop1 ;loop if we are at the last array value
  30. Loop2: ;loop for SEQUENCE_2
  31. LDY #SEQUENCE_2 ;load the address of the 2nd seq. value to reg. Y
  32. LDAA 1,Y+ ;load the value at address Y to acc. A
  33. STAA PORT_S ;output acc. A to Port S
  34. LDAB PORT_T ;load the DIP switches to acc. B
  35. CMPB #$00 ;check if the DIP switches are all off
  36. BEQ Loop1 ;branch to Loop1 if all switches are off
  37. CMPA #$00 ;check if we are at the end of the array
  38. BEQ Loop2 ;continue from the beginning of SEQUENCE_2