# TAS Instruction

The instruction TAS (Test And Set) examines a specified byte with an effective address. The most significant bit in the byte is set. The N- and Z-flags are set according to the bytes value before the operation. The instruction reads, modifies and sets and can't be interrupted. The instruction is used to synchronize if two or more MPU use the same memory area. Since TAS can't be interrupted a MPU can mark a location in the memory to be "busy" before another processor can examine it. If the operation was interruptible, two processor could examine the same byte at the same time, and both processor would think the byte was
free to use, which would lead to an error. TAS guaranties that one processor wins and the other loses. TAS is used by high level languages to implement "Semaphores"
ADDRESS METHODS: Dn, (An), (An)+, -(An), x(An), x(An,xr.s), x.w, x.l
You can use TAS with a data register, but then it has nothing to do with synchronization.
DATA LENGTH: Byte

FLAGS: | X - U
N - S (before the operation)
Z - S (before the operation)
C - 0
V - 0

SYNTAX: TAS <ea>