testpusw.pp 1.3 KB

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