1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
{
Copyright (c) 1998-2002 by Florian Klaempfl
Generate code for i8086 assembler for type converting 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 n8086cnv;
{$i fpcdefs.inc}
interface
uses
node,ncgcnv,nx86cnv,defutil,defcmp;
type
{ t8086typeconvnode }
t8086typeconvnode = class(tx86typeconvnode)
protected
function typecheck_int_to_int: tnode;override;
function typecheck_proc_to_procvar: tnode;override;
procedure second_proc_to_procvar;override;
end;
implementation
uses
verbose,systems,globals,globtype,
aasmbase,aasmtai,aasmdata,aasmcpu,
symconst,symdef,symcpu,
cgbase,cga,procinfo,pass_1,pass_2,
ncon,ncal,ncnv,nmem,n8086mem,
cpubase,cpuinfo,
cgutils,cgobj,hlcgobj,cgx86,ncgutil,
tgobj;
function t8086typeconvnode.typecheck_int_to_int: tnode;
begin
Result:=inherited typecheck_int_to_int;
if (is_16bitint(totypedef) or is_8bitint(totypedef)) and (left.nodetype=addrn) then
begin
if left.nodetype=addrn then
ti8086addrnode(left).get_offset_only:=true;
end;
end;
function t8086typeconvnode.typecheck_proc_to_procvar: tnode;
begin
Result:=inherited typecheck_proc_to_procvar;
if tcnf_proc_2_procvar_get_offset_only in convnodeflags then
begin
if resultdef.typ<>procvardef then
internalerror(2018040401);
if po_far in tprocvardef(resultdef).procoptions then
resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_offset);
end
else if (tcnf_proc_2_procvar_2_voidpointer in convnodeflags) and
(current_settings.x86memorymodel in x86_far_code_models) then
begin
if resultdef.typ<>procvardef then
internalerror(2018040402);
if not (po_far in tprocvardef(resultdef).procoptions) then
resultdef:=cprocvardef.getreusableprocaddr(tabstractprocdef(left.resultdef),pc_far_address);
end;
end;
procedure t8086typeconvnode.second_proc_to_procvar;
begin
if (tcnf_proc_2_procvar_get_offset_only in convnodeflags) and
is_proc_far(tabstractprocdef(resultdef)) then
internalerror(2018040403);
inherited;
end;
begin
ctypeconvnode:=t8086typeconvnode
end.
|