! > imp.ModHand
%const %integer Swi OS Exit = 16_11
%external %integer  ext int = 42
%own %integer       own int = 17
%routine print symbol(%integer ch)
  *Swi _ 0
  %if ch=10 %start
    *Swi_269
  %finish
%end

%routine print string(%string(255) s)
%integer i
  print symbol(charno(s,i)) %for i = 1, 1, length(s)
%end

%routine newline
  print symbol(nl)
%end

%routine write(%integer n, pl)
%integer i
  i = n>>3
  write(i,0) %if i<>0
  print symbol(n-i<<3+'0')
%end

%external %routine main %alias "3L_imp___entry_point"
  %external %routine %spec execute main program %alias "3L___main_program"

  ! Unlike standard Imp, this reloctable-module code is entered with its
  ! environment set up already. (but with a fairly small stack)

  *MOV_15,14
! This code is normally jumped into as an application!!!
!  execute main program


!  *Mov _ 1, #0
!  *Mov _ 2,1
!  *Swi _ Swi OS Exit

%end

%external %routine mysig %alias "3L___signal"
%end

%externalroutine spell %alias "spell"

  print string("Spell: ext int is ");write(ext int,0);newline
  print string("     : own int is ");write(own int,0);newline
  ext int = ext int+1
  own int = own int+1
%end

%external %routine check
  %routine trample(%integer depth)
    %return %if depth=0
    trample(depth-1)
  %end
  %if own int=17 %and ext int=42 %then %start
    print string("NO WAY Spelling checker initialised
")
  %else
    print string("NO SIRREE BOB Spelling checker re-entered - now lets use some stack...
")
    trample(20)
  %finish
%end

%begin
%endofprogram
