n68kcal.pas 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. end;
  29. implementation
  30. uses
  31. globtype,systems,
  32. cutils,verbose,globals,
  33. symconst,symbase,symsym,symcpu,symtable,defutil,paramgr,parabase,
  34. cgbase,pass_2,
  35. cpuinfo,cpubase,aasmbase,aasmtai,aasmdata,aasmcpu,
  36. nmem,nld,ncnv,
  37. ncgutil,cgutils,cgobj,tgobj,regvars,rgobj,rgcpu,
  38. cg64f32,cgcpu,cpupi,procinfo;
  39. procedure tm68kcallnode.gen_syscall_para(para: tcallparanode);
  40. begin
  41. { lib parameter has no special type but proccalloptions must be a syscall }
  42. para.left:=cloadnode.create(tcpuprocdef(procdefinition).libsym,tcpuprocdef(procdefinition).libsym.owner);
  43. end;
  44. procedure tm68kcallnode.do_syscall;
  45. var
  46. tmpref: treference;
  47. begin
  48. case target_info.system of
  49. system_m68k_amiga:
  50. begin
  51. if po_syscall_legacy in tprocdef(procdefinition).procoptions then
  52. begin
  53. { according to Amiga Developer CD 2.1, system functions destroy the
  54. scratch regs D0-D1 and A0-A1, but preserve all other regs. A6 is
  55. not used as FP on Amiga any more (we use A5), so we don't need to
  56. save it. (KB)
  57. http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node0290.html }
  58. reference_reset_base(tmpref,NR_A6,-tprocdef(procdefinition).extnumber,4);
  59. current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_JSR,S_NO,tmpref));
  60. end
  61. else
  62. internalerror(2005010403);
  63. end;
  64. else
  65. internalerror(2004042901);
  66. end;
  67. end;
  68. begin
  69. ccallnode:=tm68kcallnode;
  70. end.