tcg1.pp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. { %CPU=i386 }
  2. {$R-}
  3. program test_register_pushing;
  4. var
  5. before, after : longint;
  6. wpush,lpush : longint;
  7. const
  8. haserror : boolean = false;
  9. begin
  10. {$ifdef CPUI386}
  11. {$asmmode att}
  12. asm
  13. movl %esp,before
  14. pushw %es
  15. movl %esp,after
  16. popw %es
  17. end;
  18. wpush:=before-after;
  19. if wpush<>2 then
  20. begin
  21. Writeln('Compiler does not push "pushw %es" into 2 bytes');
  22. haserror:=true;
  23. end;
  24. asm
  25. movl %esp,before
  26. pushl %es
  27. movl %esp,after
  28. popl %es
  29. end;
  30. lpush:=before-after;
  31. if lpush<>4 then
  32. begin
  33. Writeln('Compiler does not push "pushl %es" into 4 bytes');
  34. haserror:=true;
  35. end;
  36. asm
  37. movl %esp,before
  38. pushw %gs
  39. movl %esp,after
  40. popw %gs
  41. end;
  42. wpush:=before-after;
  43. if wpush<>2 then
  44. begin
  45. Writeln('Compiler does not push "pushw %gs" into 2 bytes');
  46. haserror:=true;
  47. end;
  48. asm
  49. movl %esp,before
  50. pushl %gs
  51. movl %esp,after
  52. popl %gs
  53. end;
  54. lpush:=before-after;
  55. if lpush<>4 then
  56. begin
  57. Writeln('Compiler does not push "pushl %gs" into 4 bytes');
  58. haserror:=true;
  59. end;
  60. {$asmmode intel}
  61. asm
  62. mov before,esp
  63. push es
  64. mov after,esp
  65. pop es
  66. end;
  67. Writeln('Intel "push es" uses ',before-after,' bytes');
  68. {$endif CPUI386}
  69. if haserror then
  70. Halt(1);
  71. end.