mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-07 23:07:31 +01:00
+ allow declaring near and far procvars in all i8086 memory models. Only simple
procvars can be declared near or far. Methodpointers/nested proc vars, etc must still follow the default calling model of the current memory model. Note that this feature isn't TP7 compatible (TP7 doesn't allow near procvars at all), but is common to 16-bit C compilers and is quite useful for calling external code (e.g. for far calling BIOS or some other real mode API entry points from any memory model, etc.) git-svn-id: trunk@38595 -
This commit is contained in:
parent
48b57c2f9a
commit
23250a2ead
@ -110,6 +110,10 @@ type
|
||||
|
||||
tcpuprocvardef = class(ti86procvardef)
|
||||
constructor create(level:byte);override;
|
||||
function address_type:tdef;override;
|
||||
function size:asizeint;override;
|
||||
procedure declared_far;override;
|
||||
procedure declared_near;override;
|
||||
function is_far:boolean;
|
||||
end;
|
||||
tcpuprocvardefclass = class of tcpuprocvardef;
|
||||
@ -389,16 +393,65 @@ implementation
|
||||
constructor tcpuprocvardef.create(level: byte);
|
||||
begin
|
||||
inherited create(level);
|
||||
{ procvars are always far in the far code memory models }
|
||||
if current_settings.x86memorymodel in x86_far_code_models then
|
||||
procoptions:=procoptions+[po_far];
|
||||
end;
|
||||
|
||||
|
||||
function tcpuprocvardef.address_type:tdef;
|
||||
begin
|
||||
if is_addressonly then
|
||||
if is_far then
|
||||
result:=voidfarpointertype
|
||||
else
|
||||
begin
|
||||
{ near }
|
||||
if current_settings.x86memorymodel=mm_tiny then
|
||||
result:=voidnearpointertype
|
||||
else
|
||||
result:=voidnearcspointertype;
|
||||
end
|
||||
else
|
||||
result:=inherited;
|
||||
end;
|
||||
|
||||
|
||||
function tcpuprocvardef.size:asizeint;
|
||||
begin
|
||||
if is_addressonly then
|
||||
if is_far then
|
||||
result:=4
|
||||
else
|
||||
result:=2
|
||||
else
|
||||
result:=inherited;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcpuprocvardef.declared_far;
|
||||
begin
|
||||
if is_addressonly then
|
||||
include(procoptions,po_far)
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcpuprocvardef.declared_near;
|
||||
begin
|
||||
if is_addressonly then
|
||||
exclude(procoptions,po_far)
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
function tcpuprocvardef.is_far: boolean;
|
||||
begin
|
||||
{ procvars are always far in the far code memory models }
|
||||
result:=current_settings.x86memorymodel in x86_far_code_models;
|
||||
if is_addressonly then
|
||||
result:=po_far in procoptions
|
||||
else
|
||||
result:=current_settings.x86memorymodel in x86_far_code_models;
|
||||
end;
|
||||
|
||||
{****************************************************************************
|
||||
|
||||
Loading…
Reference in New Issue
Block a user