start LDA a       # load a and add b
      ADD b
      OUT         # output and store in c
      STO c
      LDA b       # load b and store in a
      STO a
      LDA c       # load c and store in b
      STO b
      LDA max     # load max
      SUB c       # subtract c from max
      BRP start   # if max > c, jump to start
end   HLT         # stop

# state
a     DAT 0       # lower value
b     DAT 1       # upper value
c     DAT 0       # temporary

# constants
max   DAT 100     # max value
