cg386.pas 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. This unit implements the code generator for the i386
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit cg386;
  19. interface
  20. uses
  21. cgobj;
  22. type
  23. pcg386 = ^tcg386;
  24. tcg386 = object(tcg)
  25. procedure a_push_reg(list : paasmoutput;r : tregister);virtual;
  26. procedure a_call_name(list : paasmoutput;const s : string;
  27. offset : longint);virtual;
  28. procedure a_load_const8_ref(list : paasmoutput;b : byte;ref : treference);virtual;
  29. procedure a_load_const16_ref(list : paasmoutput;w : word;ref : treference);virtual;
  30. procedure a_load_const32_ref(list : paasmoutput;l : longint;ref : treference);virtual;
  31. procedure a_load_const64_ref(list : paasmoutput;{ q : qword; }ref : treference);virtual;
  32. procedure g_stackframe_entry(list : paasmoutput;localsize : longint);
  33. end;
  34. implementation
  35. procedure tcg386.g_stackframe_entry(list : paasmoutput;localsize : longint);
  36. begin
  37. if localsize<>0 then
  38. begin
  39. if (cs_littlesize in aktglobalswitches) and (stackframe<=65535) then
  40. list^.insert(new(pai386,op_const_const(A_ENTER,S_NO,stackframe,0)))
  41. else
  42. begin
  43. g_stackframe_entry(list,stackframe);
  44. list^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EBP)));
  45. list^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_ESP,R_EBP)));
  46. list^.concat(new(pai386,op_const_reg(A_SUB,S_L,localsize,R_ESP)));
  47. end;
  48. end
  49. else
  50. begin
  51. list^.concat(new(pai386,op_reg(A_PUSH,S_L,R_EBP)));
  52. list^.concat(new(pai386,op_reg_reg(A_MOV,S_L,R_ESP,R_EBP)));
  53. end;
  54. end;
  55. procedure tcg386.a_call_name(list : paasmoutput;const s : string;
  56. offset : longint);
  57. begin
  58. list^.concat(new(pai386,op_csymbol(A_CALL,S_NO,newcsymbol(s,offset))));
  59. end;
  60. end.
  61. {
  62. $Log$
  63. Revision 1.1 1998-12-15 22:17:02 florian
  64. * first version
  65. }