PET VIC-20 C64 C16 Plus/4 C128 X16 M65

The WAIT command is used to halt the program until the contents of a memory location changes in a specific way.


WAIT <address>, <mask> [, <trig>]

The contents of the memory location are first exciusive-ORed with <trig> (if present), and then logically ANDed with <mask>. If the result is zero, the program goes back to that memory location and checks again. When the result is nonzero, the program continues with the next statement.

Please read this comprehensive article from Compute! Magazine for more information.