n386cal.pas 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate i386 assembler for in call nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  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. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit n386cal;
  18. {$i fpcdefs.inc}
  19. interface
  20. { $define AnsiStrRef}
  21. uses
  22. ncgcal;
  23. type
  24. ti386callnode = class(tcgcallnode)
  25. protected
  26. procedure pop_parasize(pop_size:longint);override;
  27. procedure extra_interrupt_code;override;
  28. end;
  29. implementation
  30. uses
  31. globtype,systems,
  32. cutils,verbose,globals,
  33. cgbase,
  34. cpubase,paramgr,
  35. aasmtai,aasmcpu,
  36. ncal,nbas,nmem,nld,ncnv,
  37. cga,cgobj,cpuinfo;
  38. {*****************************************************************************
  39. TI386CALLNODE
  40. *****************************************************************************}
  41. procedure ti386callnode.extra_interrupt_code;
  42. begin
  43. emit_none(A_PUSHF,S_L);
  44. emit_reg(A_PUSH,S_L,NR_CS);
  45. end;
  46. procedure ti386callnode.pop_parasize(pop_size:longint);
  47. var
  48. hreg : tregister;
  49. begin
  50. { better than an add on all processors }
  51. if pop_size=4 then
  52. begin
  53. hreg:=cg.getintregister(exprasmlist,OS_INT);
  54. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  55. end
  56. { the pentium has two pipes and pop reg is pairable }
  57. { but the registers must be different! }
  58. else
  59. if (pop_size=8) and
  60. not(cs_littlesize in aktglobalswitches) and
  61. (aktoptprocessor=ClassPentium) then
  62. begin
  63. hreg:=cg.getintregister(exprasmlist,OS_INT);
  64. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  65. hreg:=cg.getintregister(exprasmlist,OS_INT);
  66. exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
  67. end
  68. else
  69. if pop_size<>0 then
  70. exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
  71. end;
  72. begin
  73. ccallnode:=ti386callnode;
  74. end.