home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_36.arc / PRNSYM.FIG < prev    next >
Text File  |  1979-12-31  |  4KB  |  117 lines

  1. (*
  2.  * PRNSYM, copyright (C) 1986 by Dan Griffith, is released into
  3.  *    the public domain for non-commercial use only.
  4.  *
  5.  * PRNSYM converts a .PRN file created by the Z80MR assembler (and
  6.  *    possibly others) and creates a .SYM (symbol table) file that
  7.  *    can be used by the Z8E monitor/debugger (and possibly others).
  8.  *
  9.  * Proper invocation syntax is:
  10.  *
  11.  *        PRNSYM [prnfile [symfile]]
  12.  *
  13.  *       where prnfile is the [optional] .PRN file,
  14.  *       and symfile is the [optional] .SYM file.
  15.  *    If no filename suffixes are given, .PRN and .SYM are assumed.
  16.  *    If no filenames are entered on the command line, the user will
  17.  *       be prompted for the .PRN filename.
  18.  *
  19.  *)
  20.  
  21. Var
  22.    f1,f2: Text;
  23.    inpstr: String[80];
  24.    filename: String[14];
  25.    count: Integer;
  26.  
  27. Begin
  28.  
  29.    WriteLn('PRNSYM v1.1');
  30.    WriteLn('(C) 1986 by Dan Griffith');
  31.    Write('Name of .PRN file to convert: ');
  32.  
  33.    If (ParamCount<1) Then
  34.       ReadLn(filename)                   (* get file name from user    *)
  35.    Else Begin
  36.       WriteLn(ParamStr(1));
  37.       filename:=ParamStr(1);        (* get file name from command line *)
  38.    End;
  39.  
  40.    If Pos('.',filename)=0 Then           (* if no suffix,              *)
  41.       Assign(f1,filename+'.PRN')         (*     assume .PRN            *)
  42.    Else
  43.       Assign(f1,filename);               (* otherwise, leave explicit  *)
  44.  
  45.    If (ParamCount<2) Then                (* if no output file named    *)
  46.       If (Pos('.',filename)=0) Then      (*    if no suffix,           *)
  47.          Assign(f2,filename+'.SYM')      (*       assume .SYM          *)
  48.       Else
  49.          Assign(f2,Copy(filename,1,Pred(Pos('.',filename)))+'.SYM')
  50.    Else                                  (* if output file named       *)
  51.       If (Pos('.',ParamStr(2))=0) Then   (*    if no suffix,           *)
  52.          Assign(f2,ParamStr(2)+'.SYM')   (*      assume .SYM           *)
  53.       Else
  54.          Assign(f2,ParamStr(2));         (* otherwise, leave explicit  *)
  55.  
  56.    {$i-} Reset(f1); {$i+}
  57.    If (IOResult=0) Then Begin            (* make sure file was opened  *)
  58.  
  59.       {$i-} ReWrite(f2); {$i+}
  60.       If (IOResult<>0) Then Begin        (* make sure file was created *)
  61.          WriteLn('Disk or directory full.  PRNSYM aborted.');
  62.          Close(f1);
  63.          Close(f2);
  64.          Erase(f2);
  65.          HALT;
  66.       End;
  67.  
  68.       inpstr:='';
  69.  
  70.                                          (* search for ASEG SYMBOLS    *)
  71.       While (Not ((Eof(f1) Or (inpstr='ASEG SYMBOLS')))) Do
  72.          ReadLn(f1,inpstr);
  73.  
  74.       If (inpstr<>'ASEG SYMBOLS') Then Begin
  75.          WriteLn('Symbols not found in .PRN file.  PRNSYM aborted.');
  76.          Close(f1);
  77.          Close(f2);
  78.          Erase(f2);
  79.          HALT;
  80.       End;
  81.  
  82.       ReadLn(f1,inpstr);
  83.  
  84.       count:=0;                          (* count # of symbols         *)
  85.       ReadLn(f1,inpstr);                 (* get a line of input        *)
  86.       Repeat
  87.          While (inpstr<>'') Do
  88.                                          (* reverse order and output   *)
  89.             While Pos(' ',inpstr)>0 Do Begin
  90.                {$i-} WriteLn(f2,Copy(inpstr,8,5),Copy(inpstr,1,7)); {$i+}
  91.                If (IOResult<>0) Then Begin
  92.                   WriteLn('Disk Full.  PRNSYM aborted.');
  93.                   WriteLn(count,' symbols converted.');
  94.                   Close(f2);
  95.                   Close(f1);
  96.                   HALT;
  97.                End;
  98.                inpstr:=Copy(inpstr,13,255);
  99.                count:=Succ(count);
  100.             End;
  101.          ReadLn(f1,inpstr);              (* get more input             *)
  102.       Until (inpstr='') Or (Eof(f1));
  103.  
  104.       Close(f2);
  105.       Close(f1);
  106.  
  107.       WriteLn(count,' symbols.');
  108.  
  109.    End Else Begin
  110.       WriteLn('.PRN file not found.  PRNSYM aborted.');
  111.       WriteLn('PRNSYM syntax is: PRNSYM [prnfile [symfile]]');
  112.       Close(f1);
  113.    End;
  114.  
  115. End.
  116. found.  PRNSYM aborted.');
  117.