mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 05:09:07 +02:00
* MIPS: some clean up of assembler reader:
- references cannot be in brackets - registers are only prefixed by dollar, never by percent - syntax x@LO is not supported, must be %lo(x). git-svn-id: trunk@24633 -
This commit is contained in:
parent
eeabb9403e
commit
0ad96d2099
@ -35,7 +35,6 @@ Interface
|
|||||||
procedure BuildReference(oper : TOperand);
|
procedure BuildReference(oper : TOperand);
|
||||||
procedure BuildOperand(oper : TOperand);
|
procedure BuildOperand(oper : TOperand);
|
||||||
procedure BuildOpCode(instr : TInstruction);
|
procedure BuildOpCode(instr : TInstruction);
|
||||||
procedure ReadPercent(oper : TOperand);
|
|
||||||
procedure ReadSym(oper : TOperand);
|
procedure ReadSym(oper : TOperand);
|
||||||
procedure ConvertCalljmp(instr : TInstruction);
|
procedure ConvertCalljmp(instr : TInstruction);
|
||||||
procedure handlepercent;override;
|
procedure handlepercent;override;
|
||||||
@ -100,52 +99,28 @@ Interface
|
|||||||
begin
|
begin
|
||||||
Inherited handledollar;
|
Inherited handledollar;
|
||||||
if (c in ['0'..'9','a'..'z']) then
|
if (c in ['0'..'9','a'..'z']) then
|
||||||
begin
|
begin
|
||||||
Consume(AS_DOLLAR);
|
Consume(AS_DOLLAR);
|
||||||
if (actasmtoken=AS_INTNUM) or (actasmtoken=AS_ID) then
|
if (actasmtoken=AS_INTNUM) or (actasmtoken=AS_ID) then
|
||||||
begin
|
|
||||||
{ Try to convert to std register }
|
|
||||||
if actasmtoken=AS_INTNUM then
|
|
||||||
actasmregister:=gas_regnum_search('$'+actasmpattern)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
{ AS_ID is uppercased by default but register names
|
|
||||||
are lowercase }
|
|
||||||
actasmpattern:=lower(actasmpattern);
|
|
||||||
actasmregister:=gas_regnum_search(actasmpattern);
|
|
||||||
if actasmregister=NR_NO then
|
|
||||||
actasmregister:=std_regnum_search(actasmpattern);
|
|
||||||
end;
|
|
||||||
if actasmregister<>NR_NO then
|
|
||||||
begin
|
|
||||||
// Consume(actasmtoken);
|
|
||||||
actasmtoken:=AS_REGISTER;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMipsReader.ReadPercent(oper : TOperand);
|
|
||||||
begin
|
|
||||||
{ check for ...@ }
|
|
||||||
if actasmtoken=AS_AT then
|
|
||||||
begin
|
|
||||||
if (oper.opr.ref.symbol=nil) and
|
|
||||||
(oper.opr.ref.offset = 0) then
|
|
||||||
Message(asmr_e_invalid_reference_syntax);
|
|
||||||
Consume(AS_AT);
|
|
||||||
if actasmtoken=AS_ID then
|
|
||||||
begin
|
begin
|
||||||
if upper(actasmpattern)='LO' then
|
{ Try to convert to std register }
|
||||||
oper.opr.ref.refaddr:=addr_low
|
if actasmtoken=AS_INTNUM then
|
||||||
else if upper(actasmpattern)='HI' then
|
actasmregister:=gas_regnum_search('$'+actasmpattern)
|
||||||
oper.opr.ref.refaddr:=addr_high
|
|
||||||
else
|
else
|
||||||
Message(asmr_e_invalid_reference_syntax);
|
begin
|
||||||
Consume(AS_ID);
|
{ AS_ID is uppercased by default but register names
|
||||||
end
|
are lowercase }
|
||||||
else
|
actasmpattern:=lower(actasmpattern);
|
||||||
Message(asmr_e_invalid_reference_syntax);
|
actasmregister:=gas_regnum_search(actasmpattern);
|
||||||
|
if actasmregister=NR_NO then
|
||||||
|
actasmregister:=std_regnum_search(actasmpattern);
|
||||||
|
end;
|
||||||
|
if actasmregister<>NR_NO then
|
||||||
|
begin
|
||||||
|
// Consume(actasmtoken);
|
||||||
|
actasmtoken:=AS_REGISTER;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -154,13 +129,11 @@ Interface
|
|||||||
var
|
var
|
||||||
l : aint;
|
l : aint;
|
||||||
regs : byte;
|
regs : byte;
|
||||||
opening : TAsmToken;
|
|
||||||
hasimm : boolean;
|
hasimm : boolean;
|
||||||
begin
|
begin
|
||||||
oper.initref;
|
oper.initref;
|
||||||
regs:=0;
|
regs:=0;
|
||||||
hasimm:=false;
|
hasimm:=false;
|
||||||
opening:=ActAsmToken;
|
|
||||||
Consume(ActAsmToken);
|
Consume(ActAsmToken);
|
||||||
repeat
|
repeat
|
||||||
Case actasmtoken of
|
Case actasmtoken of
|
||||||
@ -203,15 +176,11 @@ Interface
|
|||||||
inc(oper.opr.ref.offset,l);
|
inc(oper.opr.ref.offset,l);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
AS_RPAREN,
|
AS_RPAREN:
|
||||||
AS_RBRACKET:
|
|
||||||
begin
|
begin
|
||||||
if (regs=0) and (not hasimm) then
|
if (regs=0) and (not hasimm) then
|
||||||
Message(asmr_e_invalid_reference_syntax);
|
Message(asmr_e_invalid_reference_syntax);
|
||||||
if opening=AS_LPAREN then
|
Consume(AS_RPAREN);
|
||||||
Consume(AS_RPAREN)
|
|
||||||
else
|
|
||||||
Consume(AS_RBRACKET);
|
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -242,14 +211,12 @@ Interface
|
|||||||
end;
|
end;
|
||||||
actasmpattern[0]:=chr(len);
|
actasmpattern[0]:=chr(len);
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
if is_register(actasmpattern) then
|
|
||||||
exit;
|
|
||||||
if (actasmpattern='%HI') then
|
if (actasmpattern='%HI') then
|
||||||
actasmtoken:=AS_HI
|
actasmtoken:=AS_HI
|
||||||
else if (actasmpattern='%LO')then
|
else if (actasmpattern='%LO')then
|
||||||
actasmtoken:=AS_LO
|
actasmtoken:=AS_LO
|
||||||
else
|
else
|
||||||
Message(asmr_e_invalid_register);
|
Message(asmr_e_invalid_reference_syntax);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -376,7 +343,6 @@ Interface
|
|||||||
negative:=(prevasmtoken=AS_MINUS);
|
negative:=(prevasmtoken=AS_MINUS);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AS_LBRACKET,
|
|
||||||
AS_LPAREN :
|
AS_LPAREN :
|
||||||
begin
|
begin
|
||||||
{ memory reference }
|
{ memory reference }
|
||||||
@ -459,9 +425,7 @@ Interface
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if oper.SetupVar(expr,false) then
|
if not oper.SetupVar(expr,false) then
|
||||||
ReadPercent(oper)
|
|
||||||
else
|
|
||||||
Begin
|
Begin
|
||||||
{ look for special symbols ... }
|
{ look for special symbols ... }
|
||||||
if expr= '__HIGH' then
|
if expr= '__HIGH' then
|
||||||
|
Loading…
Reference in New Issue
Block a user