              li s0,0xffff0000
              csrw 0x801,s0            # Set MMIO base address

              li t0,0x7                # Pin D input, others output
              sb t0,0(s0)              # Write to mesecons I/O direction register

start:        lr.w x0,0(s0)            # Establish a reservation set on the mesecons I/O region
              wrs.nto                  # Wait for it to become invalid
              lb t0,1(s0)              # Read the mesecons I/O data
              andi t1,t0,0x8           # Is pin D on?
              beqz t1,start            # If not, go wait again

              li t0,1                  # only A on
              sb t0,1(s0)
              pause
              pause
              pause
              li t0,2                  # only B on
              sb t0,1(s0)
              pause
              pause
              pause
              li t0,4                  # only C on
              sb t0,1(s0)
              pause
              pause
              pause
              li t0,0                  # all off
              sb t0,1(s0)
              j start
