fixnasm.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. program fixnasm;
  2. {$ifndef FPC}
  3. procedure readln(var t:text;var s:string);
  4. var
  5. c : char;
  6. i : longint;
  7. begin
  8. c:=#0;
  9. i:=0;
  10. while (not eof(t)) and (c<>#10) do
  11. begin
  12. read(t,c);
  13. if c<>#10 then
  14. begin
  15. inc(i);
  16. s[i]:=c;
  17. end;
  18. end;
  19. if (i>0) and (s[i]=#13) then
  20. dec(i);
  21. s[0]:=chr(i);
  22. end;
  23. {$endif}
  24. const
  25. spaces=' ';
  26. var
  27. t,f : text;
  28. para,bytes,flags,
  29. opcode,lastop,
  30. s : string;
  31. i,j : longint;
  32. begin
  33. writeln('Fixing insns.dat -> insns.new');
  34. assign(t,'insns.dat');
  35. reset(t);
  36. assign(f,'insns.new');
  37. rewrite(f);
  38. lastop:='';
  39. while not eof(t) do
  40. begin
  41. readln(t,s);
  42. if (s<>'') and (s[1]<>';') then
  43. begin
  44. i:=pos(' ',s);
  45. j:=pos(',',s);
  46. if (j>0) and (j<i) then
  47. opcode:=Copy(s,1,j-1)
  48. else
  49. opcode:=Copy(s,1,i-1);
  50. if opcode<>lastop then
  51. begin
  52. writeln(f,'');
  53. writeln(f,'[',Copy(s,1,i-1),']');
  54. lastop:=opcode;
  55. end;
  56. while (i<length(s)) and (s[i+1]=' ') do
  57. inc(i);
  58. Delete(s,1,i);
  59. i:=pos(' ',s);
  60. para:=Copy(s,1,i-1);
  61. para:=para+Copy(spaces,1,22-length(para));
  62. while (i<length(s)) and (s[i+1]=' ') do
  63. inc(i);
  64. Delete(s,1,i);
  65. i:=pos(' ',s);
  66. bytes:=Copy(s,1,i-1);
  67. bytes:=bytes+Copy(spaces,1,32-length(bytes));
  68. while (i<length(s)) and (s[i+1]=' ') do
  69. inc(i);
  70. Delete(s,1,i);
  71. i:=pos(' ',s);
  72. if i=0 then
  73. i:=255;
  74. flags:=Copy(s,1,i-1);
  75. writeln(f,para,bytes,flags);
  76. end
  77. else
  78. writeln(f,s);
  79. end;
  80. close(f);
  81. close(t);
  82. end.