mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-10 22:06:08 +02:00
m68k: assembler reader changes
* don't reimplement BuildStringConst, use the inherited one * findopcode's string argument is now const, simplified the function and removed some dead code * removed an intentional null ptr write in an error path, which was debug code and left in accidentally git-svn-id: trunk@32829 -
This commit is contained in:
parent
bbfbab7e0c
commit
92e7c0b03f
@ -78,7 +78,7 @@ unit ra68kmot;
|
||||
function is_register(const s:string):boolean;
|
||||
procedure GetToken;
|
||||
function consume(t : tasmtoken):boolean;
|
||||
function findopcode(s: string; var opsize: topsize): tasmop;
|
||||
function findopcode(const s: string; var opsize: topsize): tasmop;
|
||||
Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : longint;
|
||||
Procedure BuildConstant(maxvalue: longint);
|
||||
Procedure BuildRealConstant(typ : tfloattype);
|
||||
@ -86,7 +86,6 @@ unit ra68kmot;
|
||||
Function BuildRefExpression: longint;
|
||||
procedure BuildReference(const oper:tm68koperand);
|
||||
Procedure BuildOperand(const oper:tm68koperand);
|
||||
Procedure BuildStringConstant(asciiz: boolean);
|
||||
Procedure BuildOpCode(instr:Tm68kinstruction);
|
||||
end;
|
||||
|
||||
@ -556,14 +555,10 @@ const
|
||||
{---------------------------------------------------------------------}
|
||||
|
||||
function tm68kmotreader.consume(t : tasmtoken):boolean;
|
||||
var
|
||||
p: pointer;
|
||||
begin
|
||||
Consume:=true;
|
||||
if t<>actasmtoken then
|
||||
begin
|
||||
p:=nil;
|
||||
dword(p^):=0;
|
||||
Message2(scan_f_syn_expected,token2str[t],token2str[actasmtoken]);
|
||||
Consume:=false;
|
||||
end;
|
||||
@ -573,24 +568,21 @@ const
|
||||
end;
|
||||
|
||||
|
||||
function tm68kmotreader.findopcode(s: string; var opsize: topsize): tasmop;
|
||||
function tm68kmotreader.findopcode(const s: string; var opsize: topsize): tasmop;
|
||||
{*********************************************************************}
|
||||
{ FUNCTION findopcode(s: string): tasmop; }
|
||||
{ Description: Determines if the s string is a valid opcode }
|
||||
{ if so returns correct tasmop token. }
|
||||
{*********************************************************************}
|
||||
var
|
||||
j: byte;
|
||||
op_size: string;
|
||||
j: longint;
|
||||
begin
|
||||
findopcode := A_NONE;
|
||||
j:=pos('.',s);
|
||||
if j<>0 then
|
||||
if (j <> 0) and (j < length(s)) then
|
||||
begin
|
||||
op_size:=copy(s,j+1,1);
|
||||
case op_size[1] of
|
||||
case s[j+1] of
|
||||
{ For the motorola only opsize size is used to }
|
||||
{ determine the size of the operands. }
|
||||
{ determine the size of the operands. }
|
||||
'B': opsize := S_B;
|
||||
'W': opsize := S_W;
|
||||
'L': opsize := S_L;
|
||||
@ -598,10 +590,8 @@ const
|
||||
'D': opsize := S_FD;
|
||||
'X': opsize := S_FX;
|
||||
else
|
||||
Message1(asmr_e_unknown_opcode,s);
|
||||
Message1(asmr_e_unknown_opcode,s);
|
||||
end;
|
||||
{ delete everything starting from dot }
|
||||
delete(s,j,length(s));
|
||||
end;
|
||||
result:=actopcode;
|
||||
end;
|
||||
@ -1655,46 +1645,6 @@ const
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure tm68kmotreader.BuildStringConstant(asciiz: boolean);
|
||||
{*********************************************************************}
|
||||
{ PROCEDURE BuildStringConstant }
|
||||
{ Description: Takes care of a ASCII, or ASCIIZ directive. }
|
||||
{ asciiz: boolean -> if true then string will be null terminated. }
|
||||
{*********************************************************************}
|
||||
{ EXIT CONDITION: On exit the routine should point to AS_SEPARATOR. }
|
||||
{ On ENTRY: Token should point to AS_STRING }
|
||||
{*********************************************************************}
|
||||
var
|
||||
expr: string;
|
||||
errorflag : boolean;
|
||||
begin
|
||||
errorflag := FALSE;
|
||||
Repeat
|
||||
Case actasmtoken of
|
||||
AS_STRING: begin
|
||||
expr:=actasmpattern;
|
||||
if asciiz then
|
||||
expr:=expr+#0;
|
||||
ConcatString(curlist,expr);
|
||||
Consume(AS_STRING);
|
||||
end;
|
||||
AS_COMMA: begin
|
||||
Consume(AS_COMMA);
|
||||
END;
|
||||
AS_SEPARATOR: ;
|
||||
else
|
||||
begin
|
||||
Consume(actasmtoken);
|
||||
if not errorflag then
|
||||
Message(asmr_e_invalid_string_expression);
|
||||
errorflag := TRUE;
|
||||
end;
|
||||
end; { end case }
|
||||
Until actasmtoken = AS_SEPARATOR;
|
||||
end;
|
||||
|
||||
|
||||
Procedure TM68kmotReader.BuildOpCode(instr:Tm68kinstruction);
|
||||
{*********************************************************************}
|
||||
{ PROCEDURE BuildOpcode; }
|
||||
|
Loading…
Reference in New Issue
Block a user