/* Filename : convmif.p By : Michael Sugg Descript : This file takes a data file and converts it an Altera MIF format file for use in defining the initial values for RAM. Requirements: This program uses the Progress 4GL engine and is verified to be compatible with Progress version 7.3. DLC must be set the location of the Progress programs. To run the program: $DLC/bin/pro -p convmif.p */ /* DEFINITIONS */ def stream str_in. def stream str_out. def var c_filein as char format "x(20)" no-undo init "sort.lst" label "Source". def var c_fileout as char format "x(20)" no-undo init "instruct.mif" label "Dest". def var c_line as char format "x(76)" no-undo. /* MAIN PROGRAM STARTS HERE */ update c_filein c_fileout with 1 col. /* Request filenames from user */ /* Open Output file */ output stream str_out to value(c_fileout). /* Display header information */ put stream str_out unformatted "Depth = 256;" skip "Width = 32;" skip "Address_radix=hex;" skip "Data_radix=hex;" skip "% Instruction Pattern %" skip "Content" skip " Begin" skip " [01 .. FF] : 0;" skip. /* Open Input file */ input stream str_in through value("cat " + c_filein + "|quoter -c 1-100") no-echo. repeat: import stream str_in c_line. /* read in next line */ /* Strip out only needed lines and get rid of the comments */ if substr(c_line,1,3) = "000" and substr(c_line,7,1) <> "" then do: put stream str_out " " substr(c_line,4,2) format "x(2)" ": " substr(c_line,7,8) format "x(8)" ";" skip. end. end. /* End of REPEAT BLOCK */ input stream str_in close. put stream str_out "end;" skip. output stream str_out close. hide all no-pause. /*Close all display frames */ quit. /* Quit Progress RunTime */ /* Program End */