fixnasm.pp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Peter Vreman
  4. Convert insns.dat from Nasm to an i386ins.dat for usage with
  5. the Free pascal compiler
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program fixnasm;
  13. {$ifndef FPC}
  14. procedure readln(var t:text;var s:string);
  15. var
  16. c : char;
  17. i : longint;
  18. begin
  19. c:=#0;
  20. i:=0;
  21. while (not eof(t)) and (c<>#10) do
  22. begin
  23. read(t,c);
  24. if c<>#10 then
  25. begin
  26. inc(i);
  27. s[i]:=c;
  28. end;
  29. end;
  30. if (i>0) and (s[i]=#13) then
  31. dec(i);
  32. s[0]:=chr(i);
  33. end;
  34. {$endif}
  35. const
  36. spaces=' ';
  37. var
  38. t,f : text;
  39. para,bytes,flags,
  40. opcode,lastop,
  41. s : string;
  42. i,j : longint;
  43. begin
  44. writeln('Fixing insns.dat -> i386ins.dat');
  45. assign(t,'insns.dat');
  46. reset(t);
  47. assign(f,'insns.new');
  48. rewrite(f);
  49. lastop:='';
  50. while not eof(t) do
  51. begin
  52. readln(t,s);
  53. if (s<>'') and (s[1]<>';') then
  54. begin
  55. i:=pos(' ',s);
  56. j:=pos(',',s);
  57. if (j>0) and (j<i) then
  58. opcode:=Copy(s,1,j-1)
  59. else
  60. opcode:=Copy(s,1,i-1);
  61. if opcode<>lastop then
  62. begin
  63. writeln(f,'');
  64. writeln(f,'[',Copy(s,1,i-1),']');
  65. writeln(f,'(Ch_All, Ch_None, Ch_None)');
  66. lastop:=opcode;
  67. end;
  68. while (i<length(s)) and (s[i+1]=' ') do
  69. inc(i);
  70. Delete(s,1,i);
  71. i:=pos(' ',s);
  72. para:=Copy(s,1,i-1);
  73. para:=para+Copy(spaces,1,22-length(para));
  74. while (i<length(s)) and (s[i+1]=' ') do
  75. inc(i);
  76. Delete(s,1,i);
  77. i:=pos(' ',s);
  78. bytes:=Copy(s,1,i-1);
  79. bytes:=bytes+Copy(spaces,1,32-length(bytes));
  80. while (i<length(s)) and (s[i+1]=' ') do
  81. inc(i);
  82. Delete(s,1,i);
  83. i:=pos(' ',s);
  84. if i=0 then
  85. i:=255;
  86. flags:=Copy(s,1,i-1);
  87. writeln(f,para,bytes,flags);
  88. end
  89. else
  90. writeln(f,s);
  91. end;
  92. close(f);
  93. close(t);
  94. end.
  95. {
  96. $Log$
  97. Revision 1.5 2002-05-18 13:34:27 peter
  98. * readded missing revisions
  99. Revision 1.4 2002/05/16 19:46:53 carl
  100. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  101. + try to fix temp allocation (still in ifdef)
  102. + generic constructor calls
  103. + start of tassembler / tmodulebase class cleanup
  104. }