n68kcal.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. Implements the M68K specific part of 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 n68kcal;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symdef,node,ncal,ncgcal;
  22. type
  23. tm68kcallnode = class(tcgcallnode)
  24. protected
  25. procedure gen_syscall_para(para: tcallparanode); override;
  26. public
  27. procedure do_syscall;override;
  28. procedure pop_parasize(pop_size: longint);override;
  29. end;
  30. implementation
  31. uses
  32. globtype,systems,
  33. cutils,verbose,globals,
  34. symconst,symbase,symsym,symcpu,symtable,defutil,paramgr,parabase,
  35. cgbase,pass_2,
  36. cpuinfo,cpubase,aasmbase,aasmtai,aasmdata,aasmcpu,
  37. nmem,nld,ncnv,
  38. ncgutil,cgutils,cgobj,tgobj,regvars,rgobj,rgcpu,
  39. cg64f32,cgcpu,cpupi,procinfo;
  40. procedure tm68kcallnode.pop_parasize(pop_size: longint);
  41. begin
  42. if pop_size<>0 then
  43. current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_SP));
  44. end;
  45. procedure tm68kcallnode.gen_syscall_para(para: tcallparanode);
  46. begin
  47. { lib parameter has no special type but proccalloptions must be a syscall }
  48. para.left:=cloadnode.create(tcpuprocdef(procdefinition).libsym,tcpuprocdef(procdefinition).libsym.owner);
  49. end;
  50. procedure tm68kcallnode.do_syscall;
  51. var
  52. tmpref: treference;
  53. begin
  54. case target_info.system of
  55. system_m68k_amiga:
  56. begin
  57. if po_syscall_legacy in tprocdef(procdefinition).procoptions then
  58. begin
  59. { according to Amiga Developer CD 2.1, system functions destroy the
  60. scratch regs D0-D1 and A0-A1, but preserve all other regs. A6 is
  61. not used as FP on Amiga any more (we use A5), so we don't need to
  62. save it. (KB)
  63. http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node0290.html }
  64. reference_reset_base(tmpref,NR_A6,-tprocdef(procdefinition).extnumber,4);
  65. current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_JSR,S_NO,tmpref));
  66. end
  67. else
  68. internalerror(2005010403);
  69. end;
  70. else
  71. internalerror(2004042901);
  72. end;
  73. end;
  74. begin
  75. ccallnode:=tm68kcallnode;
  76. end.