m68k: improve getreferencestring function a bit

git-svn-id: trunk@35634 -
This commit is contained in:
Károly Balogh 2017-03-20 23:48:28 +00:00
parent 44c5fe99c9
commit a405b5a150

View File

@ -104,60 +104,66 @@ interface
function getreferencestring(var ref : treference) : string; function getreferencestring(var ref : treference) : string;
var var
s,basestr,indexstr : string; s: string absolute getreferencestring; { shortcut name to result }
basestr, indexstr : string;
begin begin
s:=''; s:='';
with ref do with ref do
begin begin
basestr:=gas_regname(base); basestr:=gas_regname(base);
indexstr:=gas_regname(index); indexstr:=gas_regname(index);
if assigned(symbol) then
s:=s+symbol.name;
if offset<0 then s:=s+tostr(offset) if assigned(symbol) then
else if (offset>0) then begin
begin s:=s+symbol.name;
if (symbol=nil) then s:=tostr(offset) if (offset <> 0) then
else s:=s+'+'+tostr(offset); s:=s+tostr_with_plus(offset);
end end
else if (index=NR_NO) and (base=NR_NO) and not assigned(symbol) then else
s:=s+'0'; if (offset <> 0) or ((index=NR_NO) and (base=NR_NO)) then
s:=s+tostr(offset);
if (index<>NR_NO) and (base=NR_NO) and (direction=dir_none) then case direction of
dir_none:
begin begin
if (scalefactor = 1) or (scalefactor = 0) then if (base<>NR_NO) and (index=NR_NO) then
s:=s+'('+indexstr+'.l)' begin
else if not (scalefactor in [0,1]) then
s:=s+'('+indexstr+'.l*'+tostr(scalefactor)+')' internalerror(2017011303);
end s:=s+'('+basestr+')';
else if (index=NR_NO) and (base<>NR_NO) and (direction=dir_inc) then exit;
begin end;
if (scalefactor = 1) or (scalefactor = 0) then if (base<>NR_NO) and (index<>NR_NO) then
s:=s+'('+basestr+')+' begin
else if scalefactor in [0,1] then
InternalError(10002); s:=s+'('+basestr+','+indexstr+'.l)'
end else
else if (index=NR_NO) and (base<>NR_NO) and (direction=dir_dec) then s:=s+'('+basestr+','+indexstr+'.l*'+tostr(scalefactor)+')';
begin exit;
if (scalefactor = 1) or (scalefactor = 0) then end;
s:=s+'-('+basestr+')' if (base=NR_NO) and (index<>NR_NO) then
else begin
InternalError(10003); if scalefactor in [0,1] then
end s:=s+'('+indexstr+'.l)'
else if (index=NR_NO) and (base<>NR_NO) and (direction=dir_none) then else
begin s:=s+'('+indexstr+'.l*'+tostr(scalefactor)+')';
s:=s+'('+basestr+')' exit;
end end;
else if (index<>NR_NO) and (base<>NR_NO) and (direction=dir_none) then
begin
if (scalefactor = 1) or (scalefactor = 0) then
s:=s+'('+basestr+','+indexstr+'.l)'
else
s:=s+'('+basestr+','+indexstr+'.l*'+tostr(scalefactor)+')';
end; end;
end; dir_inc:
getreferencestring:=s; begin
if (base=NR_NO) or (index<>NR_NO) or not (scalefactor in [0,1]) then
internalerror(2017011301);
s:=s+'('+basestr+')+';
end;
dir_dec:
begin
if (base=NR_NO) or (index<>NR_NO) or not (scalefactor in [0,1]) then
internalerror(2017011302);
s:=s+'-('+basestr+')';
end;
end;
end;
end; end;