home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 499.lha / Rxgen_v1.0 / rexx / FD2rxFD.rexx < prev    next >
OS/2 REXX Batch file  |  1991-04-08  |  4KB  |  97 lines

  1. /* This file is Copyright(C) 1990 Francois Rouaix and the Software Winery */
  2. /* This file must be distributed unmodified in the RXGEN package          */
  3.  
  4.  
  5. /* Transformation of _lib.fd files into .rxfd files */
  6. /* SYNTAX: fdtorxfd <library name>                  */
  7. /* Example: fdtorxfd exec                           */
  8. /* You will have to configure the variables         */
  9. /*    fddir   : directory of FD.FILES               */
  10. /*    rxfddir : directory where to put .rxfd files  */
  11. /* This program should take care of most of the     */
  12. /* irregularities in the CBM FD.FILES               */
  13. /* Register coding is                               */
  14. /*  D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4 A5 A6 A7 */
  15. /*  01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E ** ** */
  16. /*   A6 is reserved for library base                */
  17. /*   A7 is SP (!)                                   */
  18.  
  19. parse arg libname
  20.  
  21. fddir   ="work:fd.files/"
  22. rxfddir ="work:rxgen/rxfd/"
  23.  
  24. success = open('infd',lib2fd(libname),'Read')
  25. if ~success then do
  26.     say "I can't file FD file for" libname "in" fddir
  27.     exit 1
  28.     end
  29. success = open('outrxfd',lib2rxfd(libname),'Write')
  30. if ~success then do
  31.     say "I can't open RXFD file for" libname "in" rxfddir
  32.     exit 1
  33.     end
  34. offset = 0
  35. call writeln('outrxfd',"LIBRARIES."||libname||" = '00 00 00 00'x")
  36. call writeln('outrxfd',"LIBRARIES."||libname||".OPENCOUNT = 0")
  37. do until eof('infd')
  38.     line = readln('infd')
  39.     select
  40.         when left(line,1) == '*' then nop  /* skip comment */
  41.         when left(line,6) == '##bias' then do
  42.             parse var line '##bias' offset
  43.             offset = strip(offset) /* should be ok for multiple bias */
  44.             end
  45.         when left(line,8) == '##public'  then nop
  46.         when left(line,9) == '##private' then nop
  47.         when left(line,6) == '##base' then nop
  48.         when left(line,5) == '##end' then leave
  49.         when length(line) == 0 then nop
  50.         otherwise do
  51.             firstopenpar=index(line,"(",1)
  52.             fname=substr(line,1,firstopenpar - 1)
  53.             call Writech('outrxfd',"LIBS."||libname||"."||fname||"=")
  54.             call Writech('outrxfd',"'"||d2x(65536 - offset)||"'x||")
  55.             offset = offset + 6
  56.             numpars = 0
  57.             regcoding = "'20"
  58.             secondopenpar=index(line,"(",firstopenpar + 1)
  59.             select /* are there any parameters ? */
  60.                 when secondopenpar = 0 then nop
  61.                 when substr(line,secondopenpar) = "()" then nop
  62.                 otherwise do
  63.                     line = substr(line,secondopenpar)
  64.                     do until left(line,1) = ")"
  65.                         parse var line with 1 sep 2 regtype 3 regnum 4 line
  66.                         numpars = numpars + 1
  67.                         select
  68.                             when upper(regtype) = 'A' then regnum = regnum + 9
  69.                             when upper(regtype) = 'D' then regnum = regnum + 1
  70.                             otherwise do
  71.                                 say "Bad reg definition"
  72.                                 exit 5
  73.                                 end
  74.                             end /* of select */
  75.                         regcoding = regcoding||"0"||d2x(regnum)
  76.                         end  /* of do line */
  77.                     end /* of otherwise*/
  78.                 end /* of select */
  79.             if numpars ~= 0 then call writech('outrxfd',copies('?',numpars)||"||")
  80.             call writech('outrxfd',regcoding||"'x")
  81.             call writech('outrxfd','0A'x)
  82.             say fname
  83.             end /* of otherwise */
  84.         end /* of select */
  85.     end /* of do eof*/
  86. call close('infd')
  87. call close('outrxfd')
  88. exit 0
  89.  
  90. lib2fd: procedure expose fddir
  91.     arg libname
  92.     return fddir||libname||"_LIB.FD"
  93.  
  94. lib2rxfd: procedure expose rxfddir
  95.     arg libname
  96.     return rxfddir||libname||".rxfd"
  97.