%%% Decision BNZ state,9F \ul{\sl D1. Decision necessary?} BZ dormant,D3 Jump if elevator not dormant. OR $0,callup,calldown OR $0,$0,callcar Collect all calls. AND $1,$0,1<<2 Check for call on 2nd floor. BNZ $1,8F Jump if call on 2nd floor. %%% D3 ANDN $0,$0,floorBit \ul{\sl D3. Any calls?} Ignore current floor. SUB $1,$0,1 SADD $2,$1,$0 Smallest $j$ with a call. BNZ $0,D4 Jump if calls available. GET $0,rJ Where do we return? GETA $1,E6B May be E6B? CMPU $1,$0,$1 If not invoked by step E6, BNZ $1,9F exit subroutine. SET $2,2 Else $j\is 2$. %%% D4 CMP state,$2,floor \ul{\sl D4. Set state.} BZ dormant,9F \ul{\sl D5. Elevator dormant?} Exit if not at E1. BZ state,9F Exit if still $j=2$. %%% 8H TRIP Continue,Elevator,0 Else get the elevator going. %%% 9H POP 0,0 %%off