    integer low/0/
    integer high/10000/
    character ans,inbuf
    write(*,10) high
10  format(/,'Think of a number in the range 1-',i5,/)
    guess=high/2

quiz
    write(*,12) guess
12  format 'is your number larger than ',i5,' ?  ',$
    wait   ; next character from keyboard
    ans=al
    show_char
    write(*,*) ''  ; return

    if(ans.eq.'y') then
    low = guess
    ax=high-low
    shift ax
    if(ax.eq.0) then
    inc  guess
    write(*,23) guess
23  format('your number is',i6)
    stop
    endif
    add  ax,low
    guess=ax

    else
    if(ans.ne.'n') stop
    high=guess
    ax=ax-low
    shift ax
    if(ax.eq.0) then
    write(*,23) guess
    stop|    endif

+   mov  bx,high
+   sub  bx,ax
+   mov  guess,bx
    endif
    goto quiz
    end
