%%% The user U1 PUSHJ $0,Values We make up our mind. STB fi,C,In Remember where we get in STB fo,C,Out and out. STW id,C,ID and who we are %%hide PUSHJ $0,:Log:U1 %%hide %%% PUSHJ $0,UpDown Push the up/down button. %%% 0H 16ADDU $0,fi,Enter Enter on floor $f_i$. TRIP Expect,$0,tg Wait up to $t_g$ units to enter. BNZ $255,1F Jump if ready to enter. PUSHJ $0,:Log:U4 %%hide LDB fi,C,In CMP $0,fi,floor Is the elevator alredy here? BNZ $0,2F If not, give up. BNZ loading,0B See exercise 7. %%% My users behave a little bit different here than Don Knuth's: %%% Mine give up their position in the queue, and on the way to the %%% staircaise they notice that the elevator is comming; %%% they go back and reenter the queue at the end. %%% His users, will notice the elevator arriving and cleverly keep %%% their position in the queue. JMP 2F Finaly give up. %%% 1H LDB fo,C,Out Where did we want to go? PUSHJ $0,:Log:U5 %%hide PUSHJ $0,Car Push the car button. %%% 16ADDU $0,fo,Exit Exit on floor $f_o$. TRIP Receive,$0,0 Wait until we are there. PUSHJ $0,:Log:U6 %%hide %%% 2H TRIP Receive,Reuse,0 Done and ready for reuse. JMP U1 On reuse, start over. %%off