* changed the codepointer type in the i8086 small and compact memory models from

nearpointer to nearcspointer

git-svn-id: trunk@37730 -
This commit is contained in:
nickysn 2017-12-14 17:36:15 +00:00
parent 082c17fd93
commit 0119e7afb3
6 changed files with 54 additions and 24 deletions

View File

@ -35,7 +35,6 @@ interface
ti8086addrnode = class(ti86addrnode)
protected
procedure set_absvarsym_resultdef; override;
function typecheck_non_proc(realsource: tnode; out res: tnode): boolean; override;
procedure pass_generate_code;override;
public
get_offset_only: boolean;
@ -78,23 +77,6 @@ implementation
end;
function ti8086addrnode.typecheck_non_proc(realsource: tnode; out res: tnode): boolean;
begin
res:=nil;
if (realsource.nodetype=loadn) and
(tloadnode(realsource).symtableentry.typ=labelsym) then
begin
if current_settings.x86memorymodel in x86_far_code_models then
resultdef:=voidfarpointertype
else
resultdef:=voidnearpointertype;
result:=true
end
else
result:=inherited;
end;
procedure ti8086addrnode.pass_generate_code;
begin
if get_offset_only then

View File

@ -638,8 +638,14 @@ implementation
result:=false;
res:=nil;
if (realsource.nodetype=loadn) and
(tloadnode(realsource).symtableentry.typ=absolutevarsym) and
(tabsolutevarsym(tloadnode(realsource).symtableentry).abstyp=toaddr) then
(tloadnode(realsource).symtableentry.typ=labelsym) then
begin
resultdef:=voidcodepointertype;
result:=true;
end
else if (realsource.nodetype=loadn) and
(tloadnode(realsource).symtableentry.typ=absolutevarsym) and
(tabsolutevarsym(tloadnode(realsource).symtableentry).abstyp=toaddr) then
begin
offset:=tabsolutevarsym(tloadnode(realsource).symtableentry).addroffset;
hp:=left;

View File

@ -166,8 +166,10 @@ implementation
{$ifdef i8086}
if current_settings.x86memorymodel in x86_far_code_models then
voidcodepointertype:=voidfarpointertype
else if current_settings.x86memorymodel=mm_tiny then
voidcodepointertype:=voidnearpointertype
else
voidcodepointertype:=voidnearpointertype;
voidcodepointertype:=voidnearcspointertype;
voidstackpointertype:=voidnearsspointertype;
{$else i8086}
voidcodepointertype:=voidpointertype;

View File

@ -1045,6 +1045,36 @@ begin
HexStr:=HexStr(Word(Val),4);
end;
function HexStr(Val: NearCsPointer): ShortString;
begin
HexStr:='CS:'+HexStr(Word(Val),4);
end;
function HexStr(Val: NearDsPointer): ShortString;
begin
HexStr:='DS:'+HexStr(Word(Val),4);
end;
function HexStr(Val: NearEsPointer): ShortString;
begin
HexStr:='ES:'+HexStr(Word(Val),4);
end;
function HexStr(Val: NearSsPointer): ShortString;
begin
HexStr:='SS:'+HexStr(Word(Val),4);
end;
function HexStr(Val: NearFsPointer): ShortString;
begin
HexStr:='FS:'+HexStr(Word(Val),4);
end;
function HexStr(Val: NearGsPointer): ShortString;
begin
HexStr:='GS:'+HexStr(Word(Val),4);
end;
function HexStr(Val: FarPointer): ShortString;
type
TFarPointerRec = record

View File

@ -406,10 +406,14 @@ Type
CodePointer = FarPointer;
CodePtrInt = Longint;
CodePtrUInt = DWord;
{$elseif defined(FPC_X86_CODE_NEAR)}
{$elseif defined(FPC_MM_TINY)}
CodePointer = NearPointer;
CodePtrInt = Integer;
CodePtrUInt = Word;
{$elseif defined(FPC_X86_CODE_NEAR)}
CodePointer = NearCsPointer;
CodePtrInt = Integer;
CodePtrUInt = Word;
{$else}
CodePointer = Pointer;
CodePtrInt = PtrInt;
@ -1195,6 +1199,12 @@ Function OctStr(Val:qword;cnt:byte):shortstring;
Function binStr(Val:qword;cnt:byte):shortstring;
{$ifdef CPUI8086}
Function hexStr(Val:NearPointer):shortstring;
function hexStr(Val:NearCsPointer):shortstring;
function hexStr(Val:NearDsPointer):shortstring;
function hexStr(Val:NearEsPointer):shortstring;
function hexStr(Val:NearSsPointer):shortstring;
function hexStr(Val:NearFsPointer):shortstring;
function hexStr(Val:NearGsPointer):shortstring;
Function hexStr(Val:FarPointer):shortstring;
Function hexStr(Val:HugePointer):shortstring;{$ifdef SYSTEMINLINE}inline;{$endif}
{$else CPUI8086}

View File

@ -18,9 +18,9 @@
{ determine the type of the resource/form file }
{$define Win16Res}
{$if defined(FPC_MM_TINY) or defined(FPC_MM_SMALL) or defined(FPC_MM_LARGE) or defined(FPC_MM_HUGE)}
{$if defined(FPC_MM_TINY) or defined(FPC_MM_LARGE) or defined(FPC_MM_HUGE)}
{ CodePointer = Pointer; nothing to define }
{$elseif defined(FPC_MM_MEDIUM) or defined(FPC_MM_COMPACT)}
{$elseif defined(FPC_MM_SMALL) or defined(FPC_MM_MEDIUM) or defined(FPC_MM_COMPACT)}
{$define FPC_CODEPOINTER_DIFFERENT_THAN_POINTER}
{$else}
{$fatal Unknown i8086 memory model.}