ASSEMBLER CODES:
DS Define storage TS Test and Set BZ Branch if Zero SI Store ImmediateINITIALIZATION:
DS SEM1,BYTE / SEM1 is a byte SI SEM1,1 / initial value is 1 / 0 means BUSY, 1 means FREEP(SEM1):
L1: TS SEM1 / set SEM1 to BUSY, capture previous value in Z BZ L1 / if it was BUSY, loop / if not, enter critical section / SEM1 is set to BUSY now.V(SEM1):
SI SEM1,1 / reset SEM1 to FREE