

   CS IMP Compiler for M68000.  Version  3.0d

   LIB1  compiled on 08/10/87  at  10.34

    1  %include "mouse.inc"
    1& ! System include file for MOUSE
    2& ! August 1986 version
    3& 
    4& %option "-low-nons"
    5& 
    6& {* global object definitions *}
    7& 
    8& %recordformat queue fm -
    9+   (%short tag,size,
   10+   %record(queue fm)%name forward,backward,header)
   11& 
   12& %recordformat run queue fm -
   13+   (%record(queue fm)queue, %bytename interrupter)
   14& 
   15& %recordformat semaphore fm -
   16+   (%record(queue fm)queue,%integer count, %record(semaphore fm)%name assoc)
   17& 
   18& %recordformat mailbox fm -
   19+   (%record(queue fm)queue,%record(semaphore fm)%name semaphore)
   20& 
   21& %recordformat message fm -
   22+   (%record(queue fm)queue,
   23+    %record(mailbox fm)%name reply)
   24& 
   25& %recordformatspec poa fm {FE02 process-own area}
   26& 
   27& %recordformat process fm -
   28+   (%bytearray i(1:512) %or-
   29+    %record(queue fm)queue,
   30+    %record(run queue fm)%name target,
   31+    %record(mailbox fm)%name async,
   32+ 
   33+ {* boot processor local part follows *}
   34+ 
   35+    %integer ssp, xvt, tvt, reftime, cputime, membot, memtop,
   36+    %record(poa fm)%name poa,
   37+    %record(*)%name state, %short quota,hysteresis)
   38& 
   39& {* local objects *}
   40& 
   41& %recordformat interrupt handler fm -
   42+   (%record(queue fm)queue, %integer pc,a4)
   43& 
   44& %recordformat {priority} state fm -
   45+   (%record(queue fm)queue %or -
   46+    %short *,*,%record(state fm)%name lower,higher,*,
   47+    %record(run queue fm)%name target,
   48+    %short priority,quota,hysteresis,*)
   49& 
   50& {* kernel and local operations for interrupt handlers *}
   51& 
   52& @16_3f00-6*64 %routine int enqueue(%record(*)%name item,q)
   53& @16_3f00-6*63 %record(*)%map int dequeue(%record(queue fm)%name q)
   54& @16_3f00-6*62 %routine intrequeue(%record(*)%name item,q)
   55& @16_3f00-6*61 %record(*)%map int unqueue(%record(queue fm)%name q)
   56& @16_3f00-6*60 %record(queue fm)%map int inqueue(%record(*)%name item,left,right)
   57& @16_3f00-6*59 %record(queue fm)%map int exqueue(%record(*)%name item)
   58& @16_3f00-6*58 %routine int signal semaphore(%record(semaphore fm)%name s)
   59& @16_3f00-6*57 %integerfn int test semaphore(%record(semaphore fm)%name s)
   60& @16_3f00-6*56 %routine return from interrupt
   61& @16_3f00-6*55 %routine wait for interrupt
   62& @16_3f00-6*54 %routine add interrupt handler -
   63+                  (%record(interrupt handler fm)%name h,%integer level)
   64& @16_3f00-6*53 %routine remove interrupt handler -
   65+                  (%record(interrupt handler fm)%name h)
   66& 
   67& {* kernel operations for user processes *}
   68& 
   69& %systemroutinespec enqueue(%record(*)%name item,%record(queue fm)%name q)
   70& %systemrecord(*)%mapspec dequeue(%record(queue fm)%name q)
   71& %systemroutinespec requeue(%record(*)%name item,%record(queue fm)%name q)
   72& %systemrecord(*)%mapspec unqueue(%record(queue fm)%name q)
   73& %systemrecord(queue fm)%mapspec inqueue(%record(*)%name item,left,right)
   74& %systemrecord(queue fm)%mapspec exqueue(%record(*)%name item)
   75& 
   76& %systemroutinespec signal semaphore(%record(semaphore fm)%name s)
   77& %systemroutinespec semaphore wait(%record(semaphore fm)%name s)
   78& %systemintegerfnspec test semaphore(%record(semaphore fm)%name s)
   79& 
   80& %systemroutinespec send message -
   81+    (%record(*{message fm})%name message,
   82+     %record(mailbox fm)%name box,reply)
   83& %systemrecord(*{message fm})%mapspec receive message -
   84+    (%record(mailbox fm)%name box)
   85& 
   86& {* utility procedures for initialising kernel objects *}
   87& 
   88& %systemroutinespec setup queue(%record(queue fm)%name q)
   89& %systemroutinespec setup semaphore(%record(semaphore fm)%name s)
   90& %systemroutinespec setup message(%record(* {message fm})%name m,%integer size)
   91& %systemroutinespec setup mailbox -
   92+    (%record(mailbox fm)%name b,%record(semaphore fm)%name s)
   93& %systemroutinespec setup interrupt handler -
   94+    (%record(interrupt handler fm)%name i,%integer pc)
   95& %systemroutinespec setup process(%record(process fm)%name p)
   96& 
   97& {* local operations *}
   98& 
   99& %systemintegerfnspec set sr(%integer newsr)
  100& %systemintegerfnspec or to sr(%integer newsr)
  101& 
  102& %systemrecord(state fm)%mapspec scheduling state(%integer priority)
  103& %systemintegerfnspec cpu type
  104& %systemrecord(process fm)%mapspec current process
  105& %systemintegerfnspec real time
  106& %systemintegerfnspec cpu time
  107& 
  108& %systemroutinespec set priority(%record(process fm)%name p,%integer prio)
  109& 
  110& %systemrecord(process fm)%mapspec create process -
  111+    (%integer size,pc,priority,%record(queue fm)%name queue)
  112& 
  113& %systemroutinespec delete process(%record(process fm)%name pcb)
  114& 
  115& ! End of kernel specs - FE02 stuff follows
  116& 
  117& !Dictionaries are organised as binary trees with parent pointers.
  118& !Balancing is for further study.  Dictionary descriptors contain
  119& !a pointer to the root of the tree, plus a pointer to an alternative
  120& !dictionary, to be searched if the sought entry is not found in the
  121& !current dictionary's tree.  Dictionary cells are normally allocated
  122& !economically, i.e. they do not allow space for a 255 character string
  123& !at the end, but only enough.
  124& 
  125& %recordformatspec dict cell fm
  126& %recordformat dict fm -
  127+   (%record(dict fm)%name alt,%record(dict cell fm)%name tree)
  128& %recordformat dict cell fm -
  129+   (%record(dict cell fm)%name parent,left,right,
  130+    %integer token,%string(255)s)
  131& 
  132& !The event record officially contains only EVENT, SUB, LINE, EXTRA,
  133& !and MESSAGE.  Semi-officially also R.  PC and DISPLAY are unofficial,
  134& !and pun on MESSAGE being bigger than it needs to be.
  135& 
  136& %recordformat event fm -
  137+   (%byte event,sub, %half line,
  138+    %integer extra,%string(255-32)message,
  139+    %integer pc,%integerarray display(1:7),
  140+    %integerarray r(0:15))
  141& 
  142& !Stream control block.
  143& !P  points at next character to be transferred.
  144& !L  Refresh/Flush needs to be called if P>=L prior to transfer.
  145& !BS Start address of buffer.
  146& !BL End address of buffer (BL-BS = size of buffer).
  147& !FS Address of first character in file (whether or not mapped).
  148& !FL Address of last+1 character in file (w.o.n.m, FL-FS = file size).
  149& !Normally we have FS<=BS<=P<=L<=(BL,FL), and P-FL = current position
  150& !within file (relative to 0 being the first character).
  151& !FASTPC: Entry point of REFRESH or FLUSH routine (if input or output).
  152& !GLA: A4 of device driver module.
  153& !SERPC: Entry point of general service routine.
  154& !MODE: Determines whether input or output, and devdep modes.
  155& !NEXT: next SCB on this stream (to be re-instated on CLOSE).
  156& !ACB: Access control block (for further study).
  157& !A,B,C,D: Spare fields for device specific use.
  158& !FILENAME: (at end for economic allocation) Full canonical file name.
  159& 
  160& %recordformat scb fm -
  161+   (%integer p,l,bs,bl,fs,fl,fastpc,gla,serpc,mode,
  162+    %record(scb fm)%name next,%record(*)%name acb,
  163+    %integer a,b,c,d,%string(255)filename)
  164& 
  165& !File connection record.
  166& !Keeps track of pre-loaded files (tentative)
  167& 
  168& %recordformat fcr fm -
  169+   (%record(fcr fm)%name next,%integer start,size,%half count,flags)
  170& 
  171& %recordformat trap fm (%record(trap fm)%name next,%integer pc,gla,spare)
  172& 
  173& !Heap cells look like this when they're holes.  When they're used,
  174& !they look like (%byte level %or %integer size, <user portion>).
  175& 
  176& %recordformat heap cell fm -
  177+   (%byte level %or %integer size,
  178+    %record(heap cell fm)%name forward,backward)
  179& %recordformat heap header fm -
  180+   (%byte level %or %integer size,
  181+    %record(heap cell fm)%name holes,%integer front,limit,end)
  182& 
  183& !FE02 Object file header.
  184& 
  185& %recordformat fe02 header fm -
  186+   (%half tyver,flags,export,import,%integer codesize,%half reset,main,
  187+    %integer ownsize,stackreq,%short dlim,charlim,spare1,spare2)
  188& 
  189& !FE02 External object descriptor.
  190& 
  191& %recordformat fe02 object fm -
  192+   (%half flags,extra,%integer type,offset,%string(255)name)
  193& 
  194& !FE02 indirector (GLA entry).
  195& !For data object it's just a 4-byte pointer.
  196& !For %system procedures it's a 6-byte JMP.
  197& !For %external procedures it's a 12-byte {Move.l #??,A4; Jmp ??}.
  198& !For %dynamics it's also 12 bytes, which are like %externals after
  199& !the first call, but initially different.
  200& 
  201& %recordformat fe02 indir fm -
  202+   (%integer address %or -
  203+    %half op1, %integer opd1, %half op2,%integer opd2)
  204& 
  205& !(Loader's) Module activation record.
  206& !Keeps track, within the current program activation, of which
  207& !modules are loaded, and where their respective GLAs are.
  208& 
  209& %recordformat mar fm -
  210+   (%record(mar fm)%name next,%record(fe02 header fm)%name header,%integer gla)
  211&   
  212& !(Loader's) Loaded external object.
  213& !Keeps track, within the current program activation, of which
  214& !external objects are loaded, where their FE02 descriptors are,
  215& !what module they're in, and where the objects themselves are.
  216& 
  217& %recordformat leo fm -
  218+   (%record(leo fm)%name left,right,
  219+    %record(fe02 object fm)%name object,
  220+    %record(mar fm)%name module,%integer address)
  221& 
  222& !(Loader's) Program activation record.
  223& !Contains a link to the next (more global) program activation record
  224& !in the same process, and the roots for the list of module activation
  225& !records and the tree of object activatiuons records.
  226& 
  227& %recordformat par fm -
  228+   (%record(par fm)%name next,
  229+    %record(mar fm)%name modules,%record(leo fm)%name objects)
  230& 
  231& !(Loader's) Undischarged dynamic reference record.
  232& !Contains (a path to) all the information needed by the loader
  233& !to satisfy a dynamic procedure reference.
  234& 
  235& %recordformat dyn fm {undischarged dynamic reference} -
  236+   (%record(fe02 object fm)%name object,%record(par fm)%name program)
  237& 
  238& !Layout of a Process-Own-Area.
  239& 
  240& %recordformat poa fm(%bytearray b(1:1024) %or-
  241+   %record(trap fm)%name trap %or-
  242+   %integer evlink,%integerarray display(1:7),
  243+   %byte event,eventsub,%short eventline,%integer eventextra,
  244+   %string(255-32)eventmessage,
  245+   %integer eventpc,%integerarray eventdisplay(1:7),
  246+   %integerarray eventr(0:15),
  247+   %integer scratch1,scratch2,excepth,
  248+   %record(par fm)%name topprog,
  249+   (%record(heap header fm)%name heap %or %integer heapbase,stacklim),
  250+   %record(scb fm)%name curin,curout,%integer instream,outstream,
  251+   %record(scb fm)%namearray in,out(0:7),%string(255)cliparam,
  252+   %record(dict fm)%name masterdict,extdict,moddict,logdict,fildict,comdict,
  253+   %integer membot,memtop)
  254& 
  255& %systemroutinespec connectfile(%string(255)file,%integer mode,
  256+    %integername start,size)
  257& 
  258& %systemroutinespec resetinput
  259& %systemroutinespec resetoutput
  260& %systemintegerfnspec instream
  261& %systemintegerfnspec outstream
  262& !%systemstring(255)%fnspec cliparam
  263& %systempredicatespec split(%string(255)%name s,l,r)
  264& 
  265& %systemroutinespec heapput(%integer x)
  266& %systemroutinespec mark
  267& %systemroutinespec release
  268& 
  269& %systemroutinespec preconnect(%string(255)file,%integer start,size)
  270& %systemroutinespec install(%record(fe02 header fm)%name h,%string(255)file)
  271& %systemroutinespec preload(%String(255) file)
  272& 
  273& %externalroutinespec run process (%string(255) file,
  274+                                   %Integer space,priority)
  275& 
  276& %systemintegerfnspec makeentry(%string(255)name,%record(dict fm)%name dict)
  277& %systemintegerfnspec findentry(%string(255)name,%record(dict fm)%name dict)
  278& %systemstring(255)%fnspec translateentry(%integer t)
  279& %systemroutinespec deleteentry(%integer t,%record(dict fm)%name d)
  280& %systemintegerfnspec firstentry(%record(dict fm)%name d)
  281& %systemintegerfnspec nextentry(%integer t)
  282& %systemrecord(dict fm)%mapspec create dict(%string(255)s)
  283& %systemrecord(dict fm)%mapspec find dict(%string(255)s)
  284& 
  285& %systemrecord(scb fm)%mapspec new scb(%string(*)%name s)
  286& %systemrecord(scb fm)%mapspec open(%integer mode,%string(255)filename)
  287& 
  288& %systemroutinespec toupper(%string(*)%name s)
  289& %systemroutinespec tolower(%string(*)%name s)
  290& %systemroutinespec tomixed(%String(*)%name s)
  291& %systemstring(*)%mapspec newstring(%string(255)s)
  292& %systempredicatespec dynamicload(%string(255)s,%integername pc,gla)
  293& 
  294& %systemroutinespec prompt(%string(255)s)
  295& 
  296& %systemroutinespec createlogicalname(%string(255)log,equiv)
  297& %systemroutinespec deletelogicalname(%string(255)s)
  298& %systempredicatespec translatelogicalname(%string(*)%name s)
  299& 
  300& %constinteger inputmode=0,outputmode=1,appendmode=2,modifymode=3
  301& 
  302& %constinteger {function codes for IO service} -
  303+   ser closin = 0,
  304+   ser closout = 1,
  305+   ser setin = 2,
  306+   ser setout = 3,
  307+   ser prompt = 4,
  308+   ser dropout = 5,
  309+   ser refresh = 6,
  310+   ser flush = 7
  311& 
  312& @0(a5) %record(poa fm)poa
  313& 
  314& @16_3f00 -24 %integerfn muldiv(%integer a,b,c)
  315& @16_3f00-120 %integerfn heapget(%integer amount) {also NEW}
  316& @16_3f00-180 %routine setinput(%integer byte)
  317& @16_3f00-186 %routine setoutput(%integer byte)
  318& 
  319& ! Temporaries
  320& 
  321& @16_40c %routine putlong(%integer x)
  322& @16_41c %routine putsym(%integer x)
  323& @16_420 %routine putstring(%string(255)s)
    2  %option "-nocheck"
    3  
    4  %externalstring(127)%fnspec itos (%integer x,y)
    5  %Constinteger nfiles = 20
    6  
    7  !%Recordformat filefm (%Integer flags,%Record(scbfm)%Name scb) for mouse
    8  %Recordformat filefm (%Integer streamno,mode)
    9  
   10  %ownrecord(filefm)%array files (0:NFILES) =0(*)
   11  
   12  %Routine Setup IO
   13     %Integer i
   14     files(0)_streamno = 0; files(0)_mode = inputmode
    MOVE.L  D7,-(A7)             : 2F07
    CLR.L   0(A4)                : 4294
    CLR.L   4(A4)                : 42AC 0004
   15     files(1)_streamno = 0; files(1)_mode = outputmode
    CLR.L   8(A4)                : 42AC 0008
    MOVEQ   #1,D0                : 7001
    MOVE.L  D0,12(A4)            : 2940 000C
   16     files(2)_streamno = 0; files(2)_mode = outputmode
    CLR.L   16(A4)               : 42AC 0010
    MOVE.L  D0,20(A4)            : 2940 0014
   17     %for i = 3,1,nfiles %cycle
    MOVEQ   #2,D1                : 7202
    MOVE.L  D1,i                 : 2E81
L1  ADDQ.L  #1,i                 : 5297
   18        files(i)_mode = -1
    MOVE.L  i,D0                 : 2017
    ASL.L   #3,D0                : E780
    MOVEQ   #-1,D1               : 72FF
    MOVE.L  D1,4(A4,D0.L)        : 2981 0804
   19        files(i)_streamno = i-2
    MOVE.L  i,D2                 : 2417
    SUBQ.L  #2,D2                : 5582
    MOVE.L  D2,0(A4,D0.L)        : 2982 0800
   20     %Repeat
L1  MOVEQ   #20,D0               : 7014
    CMP.L   i,D0                 : B097
    BNE     L1                   : 6600 0014
   21     prompt("")
    LEA     0(PC),A0             : 41FA 0000
    JSR     prompt               : 4EAC 00A8
   22     Printstring("IO Setup");newline
    LEA     (PC),A0              : 41FA 0002
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
   23  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
   24  
   25  %Externalinteger ErrNO %Alias "C_ERRNO" = 0
   26  
   27  %Routine debug (%String(255) s)
   28     selectoutput(0)
    MOVEQ   #0,D0                : 7000
    JSR     selectoutput         : 4EB8 3E52
   29     printstring(s)
    LEA     s,A0                 : 41D7
    JSR     printstring          : 4EB8 3E6A
   30     newline
    BSR     newline              : 6100 00B5
   31  %End
^   LINK    #0,A6                : 4E56 0000
^   LEA     -256(A7),A7          : 4FEF FF00
^   MOVE.B  (A0),D4              : 1810
^   MOVE.B  0(A0,D4.L),0(A7,D4.L): 1FB0 4800 4800
^   SUBQ.B  #1,D4                : 5304
^   BCC     #-10                 : 64F6
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
   32  
   33  %Ownstring(255) clis 
   34  %ownintegerarray argptrs (1:20)
   35  %ownstring(5) argmain = "main"
   36  %Owninteger argc,argv
   37  
   38  %Routine Parse
   39     %integer p, l, i
   40  
   41     clis = cliparam
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    LEA     cliparam,A0          : 41ED 01D0
    LEA     clis,A1              : 43EC 00B2
    MOVE.B  (A0),D0              : 1010
    MOVE.B  (A0)+,(A1)+          : 12D8
    SUBQ.B  #1,D0                : 5300
    BCC     #-6                  : 64FA
   42     charno(argmain,5) = 0
    CLR.B   519(A4)              : 422C 0207
   43     argptrs(1)=addr(argmain)+1
    LEA     argmain,A0           : 41EC 0202
    ADDQ.L  #1,A0                : 5288
    MOVE.L  A0,434(A4)           : 2948 01B2
   44     l = length(clis)
    MOVE.B  178(A4),D4           : 182C 00B2
    MOVE.L  D4,l                 : 2F44 0004
   45     p = 1
    MOVEQ   #1,D0                : 7001
    MOVE.L  D0,p                 : 2F40 0008
   46     argc = 1
    MOVE.L  D0,argc              : 2940 0208
   47     %cycle
L1
   48        %exit %if p > l
    MOVE.L  p,D0                 : 202F 0008
    CMP.L   l,D0                 : B0AF 0004
    BGT     L2                   : 6E00 0000
   49        p = p + 1 %andcontinueif charno(clis,p) = ' '
    LEA     clis,A0              : 41EC 00B2
    CMPI.B  #32,0(A0,D0.L)       : 0C30 0020 0800
    BNE     L4                   : 6600 0000
    ADDQ.L  #1,p                 : 52AF 0008
    BRA     L1                   : 6000 0022
L4
   50        argc = argc + 1
    ADDQ.L  #1,argc              : 52AC 0208
   51        argptrs (argc) = addr(charno(clis,p))
    LEA     0(A0,D0.L),A0        : D1C0
    MOVE.L  argc,D1              : 222C 0208
    ASL.L   #2,D1                : E581
    LEA     argptrs,A1           : 43EC 01B2
    MOVE.L  A0,-4(A1,D1.L)       : 2388 18FC
   52        p = p + 1 %while p <= l %and charno(clis,p) # ' '
L3  MOVE.L  p,D0                 : 202F 0008
    CMP.L   l,D0                 : B0AF 0004
    BGT     L4                   : 6E00 0000
    LEA     clis,A0              : 41EC 00B2
    CMPI.B  #32,0(A0,D0.L)       : 0C30 0020 0800
    BEQ     L4                   : 6700 0047
    ADDQ.L  #1,p                 : 52AF 0008
    BRA     L3                   : 6000 0041
L4
   53        charno(clis,p)=0; p=p+1 %unless p > l
    LEA     clis,A0              : 41EC 00B2
    CLR.B   0(A0,D0.L)           : 4230 0800
    CMP.L   l,D0                 : B0AF 0004
    BGT     L4                   : 6E00 0000
    ADDQ.L  #1,p                 : 52AF 0008
L4
   54     %repeat
    BRA     L1                   : 6000 0022
L2
   55     argv = addr(argptrs(1))
    LEA     434(A4),A0           : 41EC 01B2
    MOVE.L  A0,argv              : 2948 020C
   56  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
?  56  I unused        %End
   57  
   58  %Externalroutine Start
   59     %Integer c
   60     
   61     %Routine Go
   62  !      %on 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 %start
   63  !         Printstring("Event_no  =");write(event_event,0);newline
   64  !         Printstring("Event_mess=".event_message);newline
   65  !         %Return
   66  !      %Finish
   67  
   68        *move.l argv,-(sp)
    MOVE.L  argv,-(A7)           : 2F2C 020C
?  68  Low level       |*move.l argv,-(sp)
   69        *move.l argc,-(sp)
    MOVE.L  argc,-(A7)           : 2F2C 0208
   70        *move.l c,a0
    MOVEA.L c,A0                 : 206E FFFC
   71        *jsr (a0)
    JSR     (A0)                 : 4E90
   72     %End
^   MOVE.L  8(A5),-(A7)          : 2F2D 0008
^   MOVE.L  A7,8(A5)             : 2B4F 0008
    MOVEA.L 8(A5),A7             : 2E6D 0008
    MOVE.L  (A7)+,8(A5)          : 2B5F 0008
    RTS                          : 4E75
   73  
   74     *move.l a0,c
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  A0,c                 : 2E88
?  74  Low level       |*move.l a0,c
   75     debug("Image Startup")
    LEA     (PC),A0              : 41FA 0154
    BSR     debug                : 6100 025A
   76     parse 
    BSR     parse                : 6100 0266
   77     setup IO
    BSR     setupio              : 6100 0257
   78     go
    BSR     go                   : 6100 026B
   79     printstring("Image Rundown");newline
    LEA     (PC),A0              : 41FA 0162
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
   80     %Stop
    CLR.L   D0                   : 4280
    JSR     SIGNAL               : 4EB8 3EFA
   81  %End
^   LINK    #0,A6                : 4E56 0000
   82  
   83  %Externalintegerfn EXIT (%integer reason)
   84     debug("+EXIT called+")
    LEA     (PC),A0              : 41FA 019E
    BSR     debug                : 6100 025A
   85     %Signal 1,1,1,"_exit called"
    LEA     (PC),A0              : 41FA 01AC
    MOVEQ   #1,D2                : 7401
    MOVE.L  D2,D1                : 2202
    MOVEQ   #113,D0              : 7071
    JSR     SIGNAL               : 4EB8 3EFA
   86  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
?  86  REASON unused   %End
   87  
   88  %Externalintegerfn SIGNAL
   89     debug("+Signal called+")
    LEA     (PC),A0              : 41FA 01D6
    BSR     debug                : 6100 025A
   90     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
   91  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
   92  
   93  %Externalintegerfn BRK (%integer addr)
   94     debug("+Brk called+")
    LEA     (PC),A0              : 41FA 01F8
    BSR     debug                : 6100 025A
   95     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
   96  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
?  96  ADDR unused     %End
   97  
   98  %Externalintegerfn EXECL (%integer name,argl)
   99     debug("+EXECL called+")
    LEA     (PC),A0              : 41FA 021A
    BSR     debug                : 6100 025A
  100     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  101  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 101  ARGL unused     %End
? 101  NAME unused     %End
  102  
  103  %Externalintegerfn EXECV (%Integer name, argv)
  104     debug("+EXECV called+")
    LEA     (PC),A0              : 41FA 0240
    BSR     debug                : 6100 025A
  105     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  106  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 106  ARGV unused     %End
? 106  NAME unused     %End
  107  
  108  %Externalintegerfn EXECLE (%integer name,argl)
  109     debug ("+EXECLE called+")
    LEA     (PC),A0              : 41FA 0266
    BSR     debug                : 6100 025A
  110     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  111  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 111  ARGL unused     %End
? 111  NAME unused     %End
  112  
  113  %Externalintegerfn FORK
  114     debug  ("+FORK called+")
    LEA     (PC),A0              : 41FA 028C
    BSR     debug                : 6100 025A
  115     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  116  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  117  
  118  %Externalintegerfn GETUID
  119     debug ("+GETUID called+")
    LEA     (PC),A0              : 41FA 02AC
    BSR     debug                : 6100 025A
  120     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  121  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  122  
  123  %Externalintegerfn GETEUID
  124     debug ("+GETEUID called+")
    LEA     (PC),A0              : 41FA 02CE
    BSR     debug                : 6100 025A
  125     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  126  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  127  
  128  %Externalintegerfn GETGID
  129     debug ("+GETGID called+")
    LEA     (PC),A0              : 41FA 02F2
    BSR     debug                : 6100 025A
  130     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  131  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  132  
  133  %Externalintegerfn GETEGID
  134     debug ("+GETEGID called+")
    LEA     (PC),A0              : 41FA 0314
    BSR     debug                : 6100 025A
  135     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  136  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  137  
  138  %Externalintegerfn GETPID
  139     debug ("+GETPID called+")
    LEA     (PC),A0              : 41FA 0338
    BSR     debug                : 6100 025A
  140     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  141  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  142  
  143  %Externalintegerfn KILL
  144     debug ("+KILL called+")
    LEA     (PC),A0              : 41FA 035A
    BSR     debug                : 6100 025A
  145     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  146  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  147  
  148  %Externalintegerfn LINK
  149     debug ("+LINK called+")
    LEA     (PC),A0              : 41FA 037A
    BSR     debug                : 6100 025A
  150     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  151  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  152  
  153  %Externalintegerfn NICE
  154     debug ("+NICE called+")
    LEA     (PC),A0              : 41FA 039A
    BSR     debug                : 6100 025A
  155     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  156  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  157  
  158  %Externalintegerfn PIPE (%Integer filedes)
  159     debug ("+PIPE called+")
    LEA     (PC),A0              : 41FA 03BA
    BSR     debug                : 6100 025A
  160     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  161  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 161  FILEDES unused  %End
  162  
  163  %Externalintegerfn PROFIL
  164     debug ("+PROFIL called+")
    LEA     (PC),A0              : 41FA 03DC
    BSR     debug                : 6100 025A
  165     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  166  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  167  
  168  %Externalintegerfn SETUID
  169     debug ("+SETUID called+")
    LEA     (PC),A0              : 41FA 03FE
    BSR     debug                : 6100 025A
  170     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  171  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  172  
  173  %Externalintegerfn SETGID
  174     debug ("+SETGID called+")
    LEA     (PC),A0              : 41FA 0420
    BSR     debug                : 6100 025A
  175     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  176  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  177  
  178  %Externalintegerfn UMASK
  179     debug ("+UMASK called+")
    LEA     (PC),A0              : 41FA 0442
    BSR     debug                : 6100 025A
  180     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  181  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  182  
  183  %Externalintegerfn WAIT (%integer status)
  184     debug ("+WAIT called+")
    LEA     (PC),A0              : 41FA 0464
    BSR     debug                : 6100 025A
  185     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  186  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 186  STATUS unused   %End
  187  
  188  %externalpredicatespec exists (%String(255) s)
  189  %Routine scopy (%integer name,%string(*)%name s)
  190     s = ""
    CLR.B   (A0)                 : 4210
  191     %While byteinteger(name) # 0 %cycle
L1  MOVEA.L name,A0              : 206F 0004
    TST.B   0(A0)                : 4A10
    BEQ     L2                   : 6700 0000
  192        s = s.tostring(byteinteger(name))
    MOVEA.L s,A1                 : 2257
    ADDQ.B  #1,(A1)              : 5211
    MOVE.B  (A1),D4              : 1811
    MOVE.B  0(A0),0(A1,D4.L)     : 1390 4800
  193        name = name + 1
    ADDQ.L  #1,name              : 52AF 0004
  194     %Repeat 
    BRA     L1                   : 6000 0003
L2
  195  %End      
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  A0,-(A7)             : 2F08
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  196  
  197  %Routine copy s (%string(*)%name s, %integer name)
  198     %integer i
  199     %for i = 1,1,length(s) %cycle
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.B  0(A0),D4             : 1810
    MOVE.L  D4,653               : 2F04
    CLR.L   i                    : 42AF 0004
L1  MOVE.L  i,D0                 : 202F 0004
    CMP.L   653,D0               : B097
    BEQ     L2                   : 6700 0000
    ADDQ.L  #1,i                 : 52AF 0004
  200        byteinteger(name) = charno (s,i)
    MOVEA.L s,A0                 : 206F 000C
    MOVE.L  i,D0                 : 202F 0004
    MOVEA.L name,A1              : 226F 0008
    MOVE.B  0(A0,D0.L),0(A1)     : 12B0 0800
  201        name = name + 1
    ADDQ.L  #1,name              : 52AF 0008
  202     %Repeat
    BRA     L1                   : 6000 0007
L2  ADDQ.L  #4,A7                : 588F
  203     byteinteger(name)=0
    MOVEA.L name,A0              : 206F 0004
    CLR.B   0(A0)                : 4210
  204  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  A0,-(A7)             : 2F08
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  205  
  206  %Externalroutine PS (%Integer x)
  207     %String(255) s
  208     debug ("+PS called+")
    MOVEQ   #63,D1               : 723F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D1,#-4               : 51C9 FFFC
    LEA     (PC),A0              : 41FA 04EC
    BSR     debug                : 6100 025A
  209     scopy (x,s)
    LEA     s,A0                 : 41D7
    MOVE.L  x,D0                 : 202F 0100
    BSR     scopy                : 6100 0284
  210     printstring(s);newline
    LEA     s,A0                 : 41D7
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  211  %End
^   MOVE.L  #$FEF4,D4            : 283C FFFF FEF4
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  212  
  213  %ExternalIntegerfn ACCESS (%Integer name,mode)
  214     %string(255) filename
  215  
  216     debug ("+ACCESS called+")
    MOVEQ   #63,D2               : 743F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D2,#-4               : 51CA FFFC
    LEA     (PC),A0              : 41FA 0566
    BSR     debug                : 6100 025A
  217     scopy (name,filename)
    LEA     filename,A0          : 41D7
    MOVE.L  name,D0              : 202F 0104
    BSR     scopy                : 6100 0284
  218     %Result = 0 %if exists(filename)
    MOVE.L  A4,-(A7)             : 2F0C
    LEA     filename,A0          : 41EF 0004
    JSR     exists               : 4EAC 0210
    MOVEA.L (A7)+,A4             : 285F
    MOVE.B  D0,D0                : 1000
    BEQ     L2                   : 6700 0000
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
L2
  219     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 001C
  220  %End
^   MOVE.L  #$FEEC,D4            : 283C FFFF FEEC
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 220  MODE unused     %End
  221  
  222  %Externalintegerfn CHDIR (%Integer name)
  223     %string(255) filename
  224  
  225     debug("+CHDIR called+")
    MOVEQ   #63,D1               : 723F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D1,#-4               : 51C9 FFFC
    LEA     (PC),A0              : 41FA 05BC
    BSR     debug                : 6100 025A
  226     scopy (name,filename)
    LEA     filename,A0          : 41D7
    MOVE.L  name,D0              : 202F 0100
    BSR     scopy                : 6100 0284
  227     ! Do something ???
  228     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  229  %End
^   MOVE.L  #$FEF4,D4            : 283C FFFF FEF4
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  230  
  231  %Externalintegerfn CHMOD (%Integer name,mode)
  232     %string(255) filename
  233  
  234     debug ("+CHMOD called+")
    MOVEQ   #63,D2               : 743F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D2,#-4               : 51CA FFFC
    LEA     (PC),A0              : 41FA 05FC
    BSR     debug                : 6100 025A
  235     scopy (name,filename)
    LEA     filename,A0          : 41D7
    MOVE.L  name,D0              : 202F 0104
    BSR     scopy                : 6100 0284
  236     ! Do something
  237     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  238  %End
^   MOVE.L  #$FEF0,D4            : 283C FFFF FEF0
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 238  MODE unused     %End
  239  
  240  %Externalintegerfn TIME (%Integer tloc)
  241     !Return no. of secs since Jan 1, 1970
  242     debug ("+TIME called+")
    LEA     (PC),A0              : 41FA 063E
    BSR     debug                : 6100 025A
  243     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  244  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 244  TLOC unused     %End
  245  
  246  %Recordformat Timebfm (%Integer time,%Short millitm,timezone,dstflag)
  247  
  248  %Externalintegerfn FTIME (%Integer tp)
  249     %Record(timebfm)%name t == record(tp)
    MOVEA.L D0,A0                : 2040
    MOVE.L  A0,t                 : 2F08
  250  
  251     debug ("+FTIME called+")
    LEA     (PC),A0              : 41FA 0660
    BSR     debug                : 6100 025A
  252     t_time = time(0)
    MOVEQ   #0,D0                : 7000
    BSR     time                 : 6100 0292
    MOVEA.L t,A0                 : 2057
    MOVE.L  D0,0(A0)             : 2080
  253     t_millitm = cputime
    JSR     cputime              : 4EAC 021C
    MOVEA.L t,A0                 : 2057
    MOVE.W  D0,4(A0)             : 3140 0004
  254     t_timezone = 0
    CLR.W   6(A0)                : 4268 0006
  255     t_dstflag = 0
    CLR.W   8(A0)                : 4268 0008
  256     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  257  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  258  
  259  %Recordformat tmsfm (%Integer utime,stime,ctime,cstime)
  260  
  261  %Externalintegerfn TIMES (%integer buff)
  262     %Record(tmsfm)%name b == record(buff)
    MOVEA.L D0,A0                : 2040
    MOVE.L  A0,b                 : 2F08
  263  
  264     debug ("+TIMES called+")
    LEA     (PC),A0              : 41FA 06A4
    BSR     debug                : 6100 025A
  265     b_utime = cputime // 10
    JSR     cputime              : 4EAC 021C
    MOVEQ   #10,D1               : 720A
    JSR     IDIV                 : 4EB8 3EEE
    MOVEA.L b,A0                 : 2057
    MOVE.L  D0,0(A0)             : 2080
  266  !NOSQUEAK   b_stime = realtime // 10
  267     b_ctime = 0
    CLR.L   8(A0)                : 42A8 0008
  268     b_cstime = 0
    CLR.L   12(A0)               : 42A8 000C
  269     %Result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  270  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  271  
  272  %Externalintegerfn UNLINK (%Integer name)
  273     %String(255) filename
  274  
  275     %on 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 %start
    MOVEQ   #63,D1               : 723F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D1,#-4               : 51C9 FFFC
    MOVE.L  D6,-(A7)             : 2F06
    MOVE.L  A4,-(A7)             : 2F0C
    PEA     10(PC)               : 487A 000A
    MOVE.L  (A5),-(A7)           : 2F15
    MOVE.L  A7,(A5)              : 2A8F
    BRA     L1                   : 6000 0000
    DC      $0000FFFF            : FFFF
  276        %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  277     %Finish
L1
  278  
  279     debug ("+UNLINK called+")
    LEA     (PC),A0              : 41FA 06E2
    BSR     debug                : 6100 025A
  280     scopy (name,filename)
    LEA     filename,A0          : 41EF 0010
    MOVE.L  name,D0              : 202F 0110
    BSR     scopy                : 6100 0284
  281  !   delete file (filename)
  282     %result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0012
  283  %End
    MOVE.L  -276(F1),(A5)        : 2A97
^   MOVE.L  #$FEE4,D4            : 283C FFFF FEE4
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  284  
  285  %Externalintegerfn GETWD (%integer name)
  286     %string(255) dirname
  287  
  288     debug ("+GETWD called+")
    MOVEQ   #63,D1               : 723F
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D1,#-4               : 51C9 FFFC
    LEA     (PC),A0              : 41FA 073C
    BSR     debug                : 6100 025A
  289  ! get default directory
  290     copys (dirname,name)
    MOVE.L  name,D0              : 202F 0100
    LEA     dirname,A0           : 41D7
    BSR     copys                : 6100 0288
  291     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  292  %End
^   MOVE.L  #$FEF4,D4            : 283C FFFF FEF4
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  293  
  294  %Externalintegerfn SBRK (%Integer inc)
  295     %integer a
  296     debug ("+SBRK ".itos(inc,0)." called+")
    MOVE.L  D7,-(A7)             : 2F07
    LEA     (PC),A0              : 41FA 077C
    MOVEQ   #-1,D0               : 70FF
    BSR     STRTOSTK             : 6100 0079
    MOVE.L  A4,-(A7)             : 2F0C
    MOVEQ   #0,D1                : 7200
    MOVE.L  inc,D0               : 202F 0108
    JSR     itos                 : 4EAC 0222
    MOVEA.L (A7)+,A4             : 285F
    MOVEA.L A7,A1                : 224F
    MOVEQ   #-1,D0               : 70FF
    BSR     CONCAT               : 6100 0070
    LEA     (PC),A0              : 41FA 0783
    MOVEA.L A7,A1                : 224F
    MOVEQ   #-1,D0               : 70FF
    BSR     CONCAT               : 6100 0070
    BSR     debug                : 6100 025A
    LEA     256(A7),A7           : 4FEF 0100
  297     a = heapget (inc)
    MOVE.L  inc,D0               : 202F 0004
    JSR     heapget              : 4EB8 3E88
    MOVE.L  D0,a                 : 2E80
  298     printstring("Allocated ");write(a,0);newline
    LEA     (PC),A0              : 41FA 0818
    JSR     printstring          : 4EB8 3E6A
    MOVEQ   #0,D1                : 7200
    MOVE.L  a,D0                 : 2017
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  299     %result = a
    MOVE.L  a,D0                 : 2017
    BRA     L0                   : 6000 0000
  300  %End
^   MOVE.L  #$FEEC,D4            : 283C FFFF FEEC
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  301  
  302  %Externalintegerfn FREE (%Integer adr)
  303     debug ("+FREE called+")
    LEA     (PC),A0              : 41FA 088E
    BSR     debug                : 6100 025A
  304     heapput (adr)
    MOVE.L  adr,D0               : 2017
    JSR     heapput              : 4EAC 0234
  305     %result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
  306  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  307  
  308  %Integerfn fdalloc
  309     %integer i
  310     %for i = 3,1,nfiles %cycle
    MOVEQ   #2,D0                : 7002
    MOVE.L  D0,i                 : 2F00
L1  ADDQ.L  #1,i                 : 5297
  311        %result = i %if files(i)_mode = -1
    MOVE.L  i,D0                 : 2017
    ASL.L   #3,D0                : E780
    MOVEQ   #-1,D1               : 72FF
    CMP.L   4(A4,D0.L),D1        : B2B4 0804
    BNE     L4                   : 6600 0000
    MOVE.L  i,D0                 : 2017
    BRA     L0                   : 6000 0000
L4
  312     %Repeat
L1  MOVEQ   #20,D0               : 7014
    CMP.L   i,D0                 : B097
    BNE     L1                   : 6600 0004
  313     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 000F
  314  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  315  
  316  %Externalintegerfn OPENC (%integer name, mode)
  317     %string(255) filename
  318     %Record(filefm)%name f
  319     %integer fd
  320  
  321     %on 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 %start
    MOVEQ   #65,D2               : 7441
    MOVE.L  D7,-(A7)             : 2F07
    DBRA    D2,#-4               : 51CA FFFC
    MOVE.L  D6,-(A7)             : 2F06
    MOVE.L  A4,-(A7)             : 2F0C
    PEA     10(PC)               : 487A 000A
    MOVE.L  (A5),-(A7)           : 2F15
    MOVE.L  A7,(A5)              : 2A8F
    BRA     L1                   : 6000 0000
    DC      $0000FFFF            : FFFF
  322        Printstring("OPENC signalled");newline
    LEA     (PC),A0              : 41FA 08DC
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  323        %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  324     %Finish
L1
  325  
  326     %result = -1 %unless 0<=mode<=1
    MOVE.L  D1,D1                : 2201
    BLT     L3                   : 6D00 0000
    MOVEQ   #1,D2                : 7401
    CMP.L   D2,D1                : B282
    BLE     L2                   : 6F00 0000
L3  MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0019
L2
  327     scopy (name,filename)
    LEA     filename,A0          : 41EF 0018
    BSR     scopy                : 6100 0284
  328     printstring("OPENC ".filename);newline
    LEA     (PC),A0              : 41FA 08EC
    JSR     printstring          : 4EB8 3E6A
    LEA     filename,A0          : 41EF 0018
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  329     fd = fdalloc; %result = -1 %if fd = -1
    BSR     fdalloc              : 6100 02A7
    MOVE.L  D0,fd                : 2F40 0010
    MOVEQ   #-1,D1               : 72FF
    CMP.L   D1,D0                : B081
    BNE     L2                   : 6600 0000
    MOVE.L  D1,D0                : 2001
    BRA     L0                   : 6000 0024
L2
  330     f == files(fd)
    ASL.L   #3,D0                : E780
    LEA     0(A4,D0.L),A0        : 41F4 0800
    MOVE.L  A0,f                 : 2F48 0014
  331     printstring("Imp stream = ");write(f_streamno,0);newline
    LEA     (PC),A0              : 41FA 08F3
    JSR     printstring          : 4EB8 3E6A
    MOVEA.L f,A0                 : 206F 0014
    MOVE.L  0(A0),D0             : 2010
    MOVEQ   #0,D1                : 7200
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  332     %if mode = input mode %start
    MOVE.L  mode,D0              : 202F 0118
    BNE     L2                   : 6600 0000
  333        open input (f_streamno,filename)
    MOVEA.L f,A0                 : 206F 0014
    MOVE.L  0(A0),D0             : 2010
    LEA     filename,A0          : 41EF 0018
    JSR     openinput            : 4EB8 3E64
  334        f_mode = input mode
    MOVEA.L f,A0                 : 206F 0014
    CLR.L   4(A0)                : 42A8 0004
  335     %Else
    BRA     L1                   : 6000 0000
L2
  336        open output (f_streamno,filename)
    MOVEA.L f,A0                 : 206F 0014
    MOVE.L  0(A0),D0             : 2010
    LEA     filename,A0          : 41EF 0018
    JSR     openoutput           : 4EB8 3E5E
  337        f_mode = output mode
    MOVEA.L f,A0                 : 206F 0014
    MOVEQ   #1,D0                : 7001
    MOVE.L  D0,4(A0)             : 2140 0004
  338     %finish
L1
  339     %Result = fd
    MOVE.L  fd,D0                : 202F 0010
    BRA     L0                   : 6000 0040
  340  %End
    MOVE.L  -288(F1),(A5)        : 2A97
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  341  
  342  %Predicate fdok (%integer fd)
  343     %falseunless 0<=fd<=nfiles
    MOVE.L  D0,D0                : 2000
    BLT     L3                   : 6D00 0000
    MOVEQ   #20,D1               : 7214
    CMP.L   D1,D0                : B081
    BLE     L2                   : 6F00 0000
L3  MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 0000
L2
  344     %falseif files(fd)_mode = -1
    ASL.L   #3,D0                : E780
    MOVEQ   #-1,D2               : 74FF
    CMP.L   4(A4,D0.L),D2        : B4B4 0804
    BNE     L2                   : 6600 0000
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 000B
L2
  345     %true
    MOVEQ   #1,D0                : 7001
    BRA     L0                   : 6000 0015
  346  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  347  
  348  %Externalintegerfn CLOSEC (%integer fd)
  349     %record(filefm)%name f
  350     
  351     printstring("CLOSEC ");write(fd,0);newline
    MOVE.L  D7,-(A7)             : 2F07
    LEA     (PC),A0              : 41FA 09FE
    JSR     printstring          : 4EB8 3E6A
    MOVEQ   #0,D1                : 7200
    MOVE.L  fd,D0                : 202F 0004
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  352     %Result = -1 %unless fdok (fd)
    MOVE.L  fd,D0                : 202F 0004
    BSR     fdok                 : 6100 02AB
    BNE     L2                   : 6600 0000
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
L2
  353     f == files(fd)
    MOVE.L  fd,D1                : 222F 0004
    ASL.L   #3,D1                : E781
    LEA     0(A4,D1.L),A0        : 41F4 1800
    MOVE.L  A0,f                 : 2E88
  354     printstring("just after f==");newline
    LEA     (PC),A0              : 41FA 0A06
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  355     printstring("Stream = ");write(f_streamno,0);newline
    LEA     (PC),A0              : 41FA 0A15
    JSR     printstring          : 4EB8 3E6A
    MOVEA.L f,A0                 : 2057
    MOVE.L  0(A0),D0             : 2010
    MOVEQ   #0,D1                : 7200
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  356     printstring("Mode = ");write(f_mode,0);newline
    LEA     (PC),A0              : 41FA 0A1F
    JSR     printstring          : 4EB8 3E6A
    MOVEA.L f,A0                 : 2057
    MOVE.L  4(A0),D0             : 2028 0004
    MOVEQ   #0,D1                : 7200
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  357     %if f_mode = input mode %start
    MOVEA.L f,A0                 : 2057
    MOVE.L  4(A0),D0             : 2028 0004
    BNE     L2                   : 6600 0000
  358        printstring("closing input");newline
    LEA     (PC),A0              : 41FA 0A27
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  359        select input(f_streamno);closeinput
    MOVEA.L f,A0                 : 2057
    MOVE.L  0(A0),D0             : 2010
    JSR     selectinput          : 4EB8 3E58
    JSR     closeinput           : 4EB8 3E40
  360        printstring("closed input");newline
    LEA     (PC),A0              : 41FA 0A35
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  361     %elseif f_mode = output mode
    BRA     L1                   : 6000 0000
L2  MOVEQ   #1,D1                : 7201
    CMP.L   D1,D0                : B081
    BNE     L2                   : 6600 0000
  362        printstring("closing output");newline
    LEA     (PC),A0              : 41FA 0A42
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  363        select output(f_streamno);closeoutput
    MOVEA.L f,A0                 : 2057
    MOVE.L  0(A0),D0             : 2010
    JSR     selectoutput         : 4EB8 3E52
    JSR     closeoutput          : 4EB8 3E3A
  364        printstring("closed output");newline
    LEA     (PC),A0              : 41FA 0A51
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  365     %else
    BRA     L1                   : 6000 005C
L2
  366        %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0017
  367     %finish
L1
  368     f_mode = -1
    MOVEA.L f,A0                 : 2057
    MOVEQ   #-1,D0               : 70FF
    MOVE.L  D0,4(A0)             : 2140 0004
  369     %Result = 0
    MOVEQ   #0,D0                : 7000
    BRA     L0                   : 6000 007C
  370  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  371  
  372  %Externalintegerfn UCLOSEC (%Integer fd)
  373     debug("+UCLOSEC called+")
    LEA     (PC),A0              : 41FA 0B40
    BSR     debug                : 6100 025A
  374     %result=Closec(fd)
    MOVE.L  fd,D0                : 2017
    BSR     closec               : 6100 02AD
    BRA     L0                   : 6000 0000
  375  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  376  
  377  %Externalintegerfn IOCTL (%integer fd,req,argp)
  378     debug ("+IOCTL Called+")
    LEA     (PC),A0              : 41FA 0B6A
    BSR     debug                : 6100 025A
  379     %result = 1 %if fd < 2  {temp}
    MOVEQ   #2,D0                : 7002
    CMP.L   fd,D0                : B0AF 0008
    BLE     L2                   : 6F00 0000
    MOVEQ   #1,D0                : 7001
    BRA     L0                   : 6000 0000
L2
  380     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 000E
  381  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
^   MOVE.L  D2,-(A7)             : 2F02
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 381  ARGP unused     %End
? 381  REQ unused      %End
  382  
  383  %Externalintegerfn CREAT (%Integer name,mode)
  384     %integer fd
  385     debug ("+CREAT called+")
    MOVE.L  D7,-(A7)             : 2F07
    LEA     (PC),A0              : 41FA 0B9E
    BSR     debug                : 6100 025A
  386     fd = openc (name,outputmode)
    MOVEQ   #1,D1                : 7201
    MOVE.L  name,D0              : 202F 0008
    BSR     openc                : 6100 02A9
    MOVE.L  D0,fd                : 2E80
  387     %result = fd
    BRA     L0                   : 6000 0000
  388  %End
^   MOVEQ   #-20,D4              : 78EC
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 388  MODE unused     %End
  389  
  390  %Externalintegerfn LSEEK (%Integer fd,offset,dir)
  391     %Integer curpos,newpos
  392     %Record(filefm)%name f
  393  
  394     printstring("+LSEEK called+");newline
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    LEA     (PC),A0              : 41FA 0BD6
    JSR     printstring          : 4EB8 3E6A
    BSR     newline              : 6100 00B5
  395  !   %Result = -1 %unless fdok (fd)
  396  !   f == files(fd)
  397  !   curpos = f_scb_p - f_scb_fs
  398  !   %if dir = 0 %start
  399  !      newpos = offset
  400  !   %elseif dir = 1
  401  !      newpos = curpos + offset
  402  !   %elseif dir = 2
  403  !      %Result = -1 %unless offset <= 0
  404  !      newpos = f_scb_fl + offset
  405  !   %finish
  406  !   %if f_scb_mode = input mode %start
  407  !      service (f_scb,ser set in ,newpos)
  408  !   %else
  409  !      service (f_scb,ser set out,newpos)
  410  !   %Finish
  411  !   %Result = newpos
  412     %result = -1
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
  413  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
^   MOVE.L  D2,-(A7)             : 2F02
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 413  F unused        %End
? 413  NEWPOS unused   %End
? 413  CURPOS unused   %End
? 413  DIR unused      %End
? 413  OFFSET unused   %End
? 413  FD unused       %End
  414  
  415  %Externalintegerfn READC (%Integer fd, buffer, nbytes)
  416     %Record(filefm)%name f
  417     %integer i,sym,count=0
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    CLR.L   count                : 42A7
  418  
  419     %on 9 %start
    MOVE.L  D6,-(A7)             : 2F06
    MOVE.L  A4,-(A7)             : 2F0C
    PEA     10(PC)               : 487A 000A
    MOVE.L  (A5),-(A7)           : 2F15
    MOVE.L  A7,(A5)              : 2A8F
    BRA     L1                   : 6000 0000
    DC      $0200                : 0200
  420        debug("Returning ".itos(count,0)." bytes")
    LEA     (PC),A0              : 41FA 0C08
    MOVEQ   #-1,D0               : 70FF
    BSR     STRTOSTK             : 6100 0079
    MOVE.L  A4,-(A7)             : 2F0C
    MOVEQ   #0,D1                : 7200
    MOVE.L  count,D0             : 202F 0114
    JSR     itos                 : 4EAC 0222
    MOVEA.L (A7)+,A4             : 285F
    MOVEA.L A7,A1                : 224F
    MOVEQ   #-1,D0               : 70FF
    BSR     CONCAT               : 6100 0070
    LEA     (PC),A0              : 41FA 0C13
    MOVEA.L A7,A1                : 224F
    MOVEQ   #-1,D0               : 70FF
    BSR     CONCAT               : 6100 0070
    BSR     debug                : 6100 025A
    LEA     256(A7),A7           : 4FEF 0100
  421        %result = count
    MOVE.L  count,D0             : 202F 0010
    BRA     L0                   : 6000 0000
  422     %finish
L1
  423  
  424     Printstring("READC ");write(nbytes,0);space
    LEA     (PC),A0              : 41FA 0C1A
    JSR     printstring          : 4EB8 3E6A
    MOVEQ   #0,D1                : 7200
    MOVE.L  nbytes,D0            : 202F 0020
    JSR     write                : 4EAC 022E
    BSR     space                : 6100 00B6
  425     printstring("Fd=");write(fd,0);space
    LEA     (PC),A0              : 41FA 0C28
    JSR     printstring          : 4EB8 3E6A
    MOVEQ   #0,D1                : 7200
    MOVE.L  fd,D0                : 202F 0028
    JSR     write                : 4EAC 022E
    BSR     space                : 6100 00B6
  426     printstring("addr=");write(buffer,0);newline
    LEA     (PC),A0              : 41FA 0C2C
    JSR     printstring          : 4EB8 3E6A
    MOVEQ   #0,D1                : 7200
    MOVE.L  buffer,D0            : 202F 0024
    JSR     write                : 4EAC 022E
    BSR     newline              : 6100 00B5
  427     %Result = -1 %unless fdok (fd)
    MOVE.L  fd,D0                : 202F 0028
    BSR     fdok                 : 6100 02AB
    BNE     L2                   : 6600 0000
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 002F
L2
  428     f == files(fd)
    MOVE.L  fd,D1                : 222F 0028
    ASL.L   #3,D1                : E781
    LEA     0(A4,D1.L),A0        : 41F4 1800
    MOVE.L  A0,f                 : 2F48 001C
  429     %result = -1 %unless f_mode = input mode
    MOVE.L  4(A0),D0             : 2028 0004
    BEQ     L2                   : 6700 0000
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 005D
L2
  430     select input (f_streamno)
    MOVE.L  0(A0),D0             : 2010
    JSR     selectinput          : 4EB8 3E58
  431     %if fd=0 %start {special for term}
    MOVE.L  fd,D0                : 202F 0028
    BNE     L2                   : 6600 0000
  432        readsymbol(sym)
    JSR     readsymbol           : 4EB8 3E76
    MOVE.L  D0,sym               : 2F40 0014
  433        byteinteger(buffer)=sym
    MOVEA.L buffer,A0            : 206F 0024
    MOVE.B  D0,0(A0)             : 1080
  434        %result=1
    MOVEQ   #1,D0                : 7001
    BRA     L0                   : 6000 006D
  435     %finish
L2
  436     %for i = 1,1,nbytes %cycle
    MOVE.L  nbytes,703           : 2F2F 0020
    CLR.L   i                    : 42AF 001C
L1  MOVE.L  i,D0                 : 202F 001C
    CMP.L   703,D0               : B097
    BEQ     L2                   : 6700 0000
    ADDQ.L  #1,i                 : 52AF 001C
  437        read symbol (sym)
    JSR     readsymbol           : 4EB8 3E76
    MOVE.L  D0,sym               : 2F40 0018
  438        byteinteger(buffer)=sym
    MOVEA.L buffer,A0            : 206F 0028
    MOVE.B  D0,0(A0)             : 1080
  439        buffer=buffer+1
    ADDQ.L  #1,buffer            : 52AF 0028
  440        count = count +1
    ADDQ.L  #1,count             : 52AF 0014
  441     %Repeat
    BRA     L1                   : 6000 0089
L2  ADDQ.L  #4,A7                : 588F
  442     %Result =count
    MOVE.L  count,D0             : 202F 0010
    BRA     L0                   : 6000 0083
  443  %End
    MOVE.L  -44(F1),(A5)         : 2A97
^   MOVE.L  #$FEC8,D4            : 283C FFFF FEC8
^   BSR     STACKOK              : 6100 006D
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
^   MOVE.L  D2,-(A7)             : 2F02
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  444  
  445  %Externalintegerfn WRITEC (%Integer fd,buffer,nbytes)
  446     %record(filefm)%name f
  447     %integer i
  448  
  449  !   Printstring("WRITEC");newline
  450     %Result = -1 %unless fdok(fd)
    MOVE.L  D7,-(A7)             : 2F07
    MOVE.L  D7,-(A7)             : 2F07
    BSR     fdok                 : 6100 02AB
    BNE     L2                   : 6600 0000
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 0000
L2
  451     f == files(fd)
    MOVE.L  fd,D1                : 222F 0010
    ASL.L   #3,D1                : E781
    LEA     0(A4,D1.L),A0        : 41F4 1800
    MOVE.L  A0,f                 : 2F48 0004
  452     %result = -1 %unless f_mode = output mode
    MOVEQ   #1,D0                : 7001
    CMP.L   4(A0),D0             : B0A8 0004
    BEQ     L2                   : 6700 0000
    MOVEQ   #-1,D0               : 70FF
    BRA     L0                   : 6000 000A
L2
  453     select output (f_streamno)
    MOVE.L  0(A0),D0             : 2010
    JSR     selectoutput         : 4EB8 3E52
  454     %for i=1,1,nbytes %cycle
    MOVE.L  nbytes,703           : 2F2F 0008
    CLR.L   i                    : 42AF 0004
L1  MOVE.L  i,D0                 : 202F 0004
    CMP.L   703,D0               : B097
    BEQ     L2                   : 6700 0000
    ADDQ.L  #1,i                 : 52AF 0004
  455        printsymbol(byteinteger(buffer))
    MOVEA.L buffer,A0            : 206F 0010
    MOVE.B  0(A0),D4             : 1810
    MOVE.L  D4,D0                : 2004
    JSR     printsymbol          : 4EB8 3E70
  456        buffer=buffer+1
    ADDQ.L  #1,buffer            : 52AF 0010
  457     %repeat
    BRA     L1                   : 6000 0025
L2  ADDQ.L  #4,A7                : 588F
  458     %Result = nbytes
    MOVE.L  nbytes,D0            : 202F 0008
    BRA     L0                   : 6000 001B
  459  %End
^   LINK    #0,A6                : 4E56 0000
^   MOVE.L  D0,-(A7)             : 2F00
^   MOVE.L  D1,-(A7)             : 2F01
^   MOVE.L  D2,-(A7)             : 2F02
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
  460  
  461  %Externalintegerfn IPENDC
  462     ! Number of unread characters in keyboard buffer
  463     %result = 1 {for now}
    MOVEQ   #1,D0                : 7001
    BRA     L0                   : 6000 0000
  464  %End
^   LINK    #0,A6                : 4E56 0000
    UNLK    A6                   : 4E5E
    RTS                          : 4E75
? 465  MULDIV unused   %End
? 465  POA unused      %End
LIB1 compiled: 502 statements (+ 108 comments) to 3544 bytes (+ 42)
