mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 17:10:14 +02:00
m68k: fix DB/DW/DD handling in inline assembler, update BuildConstant() method to current standards. issue reported/initial patch by Marcel Kilgus in QLForum.co.uk
git-svn-id: trunk@47548 -
This commit is contained in:
parent
7169b6d04c
commit
7444733f5d
@ -83,7 +83,7 @@ unit ra68kmot;
|
|||||||
procedure consume_all_until(tokens : tasmtokenset);
|
procedure consume_all_until(tokens : tasmtokenset);
|
||||||
function findopcode(const s: string; var opsize: topsize): tasmop;
|
function findopcode(const s: string; var opsize: topsize): tasmop;
|
||||||
Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint;
|
Function BuildExpression(allow_symbol : boolean; asmsym : pshortstring) : tcgint;
|
||||||
Procedure BuildConstant(maxvalue: tcgint);
|
Procedure BuildConstant(constsize: tcgint);
|
||||||
Procedure BuildRealConstant(typ : tfloattype);
|
Procedure BuildRealConstant(typ : tfloattype);
|
||||||
Procedure BuildScaling(const oper:tm68koperand);
|
Procedure BuildScaling(const oper:tm68koperand);
|
||||||
Function BuildRefExpression: tcgint;
|
Function BuildRefExpression: tcgint;
|
||||||
@ -932,72 +932,53 @@ const
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure tm68kmotreader.BuildConstant(maxvalue: tcgint);
|
procedure tm68kmotreader.BuildConstant(constsize: tcgint);
|
||||||
{*********************************************************************}
|
{*********************************************************************}
|
||||||
{ PROCEDURE BuildConstant }
|
{ PROCEDURE BuildConstant }
|
||||||
{ Description: This routine takes care of parsing a DB,DD,or DW }
|
{ Description: This routine takes care of parsing a DB,DD,or DW }
|
||||||
{ line and adding those to the assembler node. Expressions, range- }
|
{ line and adding those to the assembler node. Expressions, range- }
|
||||||
{ checking are fullly taken care of. }
|
{ checking are fully taken care of. }
|
||||||
{ maxvalue: $ff -> indicates that this is a DB node. }
|
|
||||||
{ $ffff -> indicates that this is a DW node. }
|
|
||||||
{ $ffffffff -> indicates that this is a DD node. }
|
|
||||||
{*********************************************************************}
|
{*********************************************************************}
|
||||||
{ EXIT CONDITION: On exit the routine should point to AS_SEPARATOR. }
|
{ EXIT CONDITION: On exit the routine should point to AS_SEPARATOR. }
|
||||||
{*********************************************************************}
|
{*********************************************************************}
|
||||||
var
|
var
|
||||||
expr: string;
|
expr: string;
|
||||||
value : tcgint;
|
value : tcgint;
|
||||||
begin
|
begin
|
||||||
Repeat
|
repeat
|
||||||
Case actasmtoken of
|
case actasmtoken of
|
||||||
AS_STRING: begin
|
AS_STRING:
|
||||||
if maxvalue <> $ff then
|
begin
|
||||||
Message(asmr_e_string_not_allowed_as_const);
|
expr:=actasmpattern;
|
||||||
expr := actasmpattern;
|
Consume(AS_STRING);
|
||||||
if length(expr) > 1 then
|
if (constsize <> 1) or (length(expr) > 1) then
|
||||||
Message(asmr_e_string_not_allowed_as_const);
|
Message(asmr_e_string_not_allowed_as_const);
|
||||||
Consume(AS_STRING);
|
|
||||||
Case actasmtoken of
|
|
||||||
AS_COMMA: Consume(AS_COMMA);
|
|
||||||
AS_SEPARATOR: ;
|
|
||||||
else
|
|
||||||
Message(asmr_e_invalid_string_expression);
|
|
||||||
end; { end case }
|
|
||||||
ConcatString(curlist,expr);
|
|
||||||
end;
|
|
||||||
AS_INTNUM,AS_BINNUM,
|
|
||||||
AS_OCTALNUM,AS_HEXNUM:
|
|
||||||
begin
|
|
||||||
value:=BuildExpression(false,nil);
|
|
||||||
ConcatConstant(curlist,value,maxvalue);
|
|
||||||
end;
|
|
||||||
AS_ID:
|
|
||||||
begin
|
|
||||||
value:=BuildExpression(false,nil);
|
|
||||||
if value > maxvalue then
|
|
||||||
begin
|
|
||||||
Message(asmr_e_constant_out_of_bounds);
|
|
||||||
{ assuming a value of maxvalue }
|
|
||||||
value := maxvalue;
|
|
||||||
end;
|
|
||||||
ConcatConstant(curlist,value,maxvalue);
|
|
||||||
end;
|
|
||||||
{ These terms can start an assembler expression }
|
|
||||||
AS_PLUS,AS_MINUS,AS_LPAREN,AS_NOT: begin
|
|
||||||
value := BuildExpression(false,nil);
|
|
||||||
ConcatConstant(curlist,value,maxvalue);
|
|
||||||
end;
|
|
||||||
AS_COMMA: begin
|
|
||||||
Consume(AS_COMMA);
|
|
||||||
END;
|
|
||||||
AS_SEPARATOR: ;
|
|
||||||
|
|
||||||
else
|
if not (actasmtoken in [AS_COMMA, AS_SEPARATOR]) then
|
||||||
begin
|
Message(asmr_e_invalid_string_expression);
|
||||||
Message(asmr_e_syntax_error);
|
|
||||||
end;
|
ConcatString(curlist,expr);
|
||||||
end; { end case }
|
end;
|
||||||
Until actasmtoken = AS_SEPARATOR;
|
AS_ID,
|
||||||
|
AS_INTNUM,AS_BINNUM,
|
||||||
|
AS_OCTALNUM,AS_HEXNUM,
|
||||||
|
{ These terms can start an assembler expression }
|
||||||
|
AS_PLUS,AS_MINUS,AS_LPAREN,AS_NOT:
|
||||||
|
begin
|
||||||
|
value:=BuildExpression(false,nil);
|
||||||
|
ConcatConstant(curlist,value,constsize);
|
||||||
|
end;
|
||||||
|
AS_COMMA:
|
||||||
|
begin
|
||||||
|
Consume(AS_COMMA);
|
||||||
|
end;
|
||||||
|
AS_SEPARATOR: ;
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Message(asmr_e_syntax_error);
|
||||||
|
end;
|
||||||
|
end; { end case }
|
||||||
|
until actasmtoken = AS_SEPARATOR;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1713,17 +1694,17 @@ const
|
|||||||
AS_DW:
|
AS_DW:
|
||||||
begin
|
begin
|
||||||
Consume(AS_DW);
|
Consume(AS_DW);
|
||||||
BuildConstant($ffff);
|
BuildConstant(sizeof(word));
|
||||||
end;
|
end;
|
||||||
AS_DB:
|
AS_DB:
|
||||||
begin
|
begin
|
||||||
Consume(AS_DB);
|
Consume(AS_DB);
|
||||||
BuildConstant($ff);
|
BuildConstant(sizeof(byte));
|
||||||
end;
|
end;
|
||||||
AS_DD:
|
AS_DD:
|
||||||
begin
|
begin
|
||||||
Consume(AS_DD);
|
Consume(AS_DD);
|
||||||
BuildConstant(tcgint($ffffffff));
|
BuildConstant(sizeof(dword));
|
||||||
end;
|
end;
|
||||||
AS_XDEF:
|
AS_XDEF:
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user