%%% %%% press the car button for fo Car SL $0,on,fo Get $f_o$ bit. OR callcar,callcar,$0 Set callcar. BNZ state,1F If state is neutral, CMP state,fo,floor \qquad set state as appropriate TRIP Continue,Elevator,25 \qquad and speed up the elevator. 1H POP 0,0 %%% %%% press the up(+1)/down(-1) button for fi depending on fo %%% if fi = floor and %%% if door is closing (just before E6) %%% interupt elevator immediately %%% and send it to E3 (door open) %%% if elevator is waiting (door closing has not started) %%% restart the loading routine. (set loading=1 waiting=0) %%% in both cases dont record the buttons, no further action %%% otherwise %%% set callup and calldown %%% if not bussy call decision %%% if bussy but elevator dormant (E1) call decission %%% UpDown CMP $0,fi,floor Is Elevator here? BNZ $0,2F Jump if $f_i\ne\.{floor}$. BZ closing,1F If the door is just closing, GETA $255,E3 \qquad reschedule the elevator at E3 TRIP Start,Elevator,0 \qquad to open the door. POP 0,0 1H BZ waiting,2F If the elevator is waiting, JMP Loading restart loading. % The last line is a subroutine call with last call optimization. 2H SL $0,on,fi Get $f_i$ bit. CMP $1,fo,fi Going up or down ? ZSP $2,$1,$0 If $f_o>f_i$ OR callup,callup,$2 \qquad set callup. ZSN $2,$1,$0 If $f_o