12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- {
- Copyright (c) 1998-2002 by Florian Klaempfl
- Generate i8086 assembler for in call nodes
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************
- }
- unit n8086cal;
- {$i fpcdefs.inc}
- interface
- { $define AnsiStrRef}
- uses
- nx86cal;
- type
- ti8086callnode = class(tx86callnode)
- protected
- procedure pop_parasize(pop_size:longint);override;
- procedure extra_interrupt_code;override;
- end;
- implementation
- uses
- globtype,systems,
- cutils,verbose,globals,
- cgbase,cgutils,
- cpubase,paramgr,
- aasmtai,aasmdata,aasmcpu,
- ncal,nbas,nmem,nld,ncnv,
- cga,cgobj,cpuinfo;
- {*****************************************************************************
- TI8086CALLNODE
- *****************************************************************************}
- procedure ti8086callnode.extra_interrupt_code;
- begin
- emit_none(A_PUSHF,S_W);
- emit_reg(A_PUSH,S_W,NR_CS);
- end;
- procedure ti8086callnode.pop_parasize(pop_size:longint);
- var
- hreg : tregister;
- begin
- if (paramanager.use_fixed_stack) then
- begin
- { very weird: in this case the callee does a "ret $4" and the }
- { caller immediately a "subl $4,%esp". Possibly this is for }
- { use_fixed_stack code to be able to transparently call }
- { old-style code (JM) }
- dec(pop_size,pushedparasize);
- if (pop_size < 0) then
- current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_SUB,S_W,-pop_size,NR_SP));
- exit;
- end;
- { better than an add on all processors }
- if pop_size=2 then
- begin
- hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
- current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_POP,S_W,hreg));
- end
- { the pentium has two pipes and pop reg is pairable }
- { but the registers must be different! }
- else
- if pop_size<>0 then
- current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_ADD,S_W,pop_size,NR_SP));
- end;
- begin
- ccallnode:=ti8086callnode;
- end.
|