|
@@ -35,7 +35,7 @@ interface
|
|
|
|
|
|
uses
|
|
|
cutils,cclasses,
|
|
|
- globtype,
|
|
|
+ globtype,globals,
|
|
|
cgbase
|
|
|
;
|
|
|
|
|
@@ -286,6 +286,9 @@ uses
|
|
|
function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
|
|
|
function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
|
|
|
|
|
|
+ { checks whether two segment registers are normally equal in the current memory model }
|
|
|
+ function segment_regs_equal(r1,r2:tregister):boolean;
|
|
|
+
|
|
|
{$ifdef i8086}
|
|
|
{ returns the next virtual register }
|
|
|
function GetNextReg(const r : TRegister) : TRegister;
|
|
@@ -553,6 +556,48 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ function segment_regs_equal(r1, r2: tregister): boolean;
|
|
|
+ begin
|
|
|
+ if not is_segment_reg(r1) or not is_segment_reg(r2) then
|
|
|
+ internalerror(2013062301);
|
|
|
+ { every segment register is equal to itself }
|
|
|
+ if r1=r2 then
|
|
|
+ exit(true);
|
|
|
+{$if defined(i8086)}
|
|
|
+ case current_settings.x86memorymodel of
|
|
|
+ mm_tiny:
|
|
|
+ begin
|
|
|
+ { CS=DS=SS }
|
|
|
+ if ((r1=NR_CS) or (r1=NR_DS) or (r1=NR_SS)) and
|
|
|
+ ((r2=NR_CS) or (r2=NR_DS) or (r2=NR_SS)) then
|
|
|
+ exit(true);
|
|
|
+ { the remaining are distinct from each other }
|
|
|
+ exit(false);
|
|
|
+ end;
|
|
|
+ mm_small,mm_medium:
|
|
|
+ begin
|
|
|
+ { DS=SS }
|
|
|
+ if ((r1=NR_DS) or (r1=NR_SS)) and
|
|
|
+ ((r2=NR_DS) or (r2=NR_SS)) then
|
|
|
+ exit(true);
|
|
|
+ { the remaining are distinct from each other }
|
|
|
+ exit(false);
|
|
|
+ end;
|
|
|
+ mm_compact,mm_large,mm_huge: internalerror(2013062303);
|
|
|
+ else
|
|
|
+ internalerror(2013062302);
|
|
|
+ end;
|
|
|
+{$elseif defined(i386) or defined(x86_64)}
|
|
|
+ { DS=SS=ES }
|
|
|
+ if ((r1=NR_DS) or (r1=NR_SS) or (r1=NR_ES)) and
|
|
|
+ ((r2=NR_DS) or (r2=NR_SS) or (r2=NR_ES)) then
|
|
|
+ exit(true);
|
|
|
+ { the remaining are distinct from each other }
|
|
|
+ exit(false);
|
|
|
+{$endif}
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
{$ifdef i8086}
|
|
|
function GetNextReg(const r: TRegister): TRegister;
|
|
|
begin
|