mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 05:29:34 +02:00
+ support reading of .p2align with op code and/or max. bytes in the gas assembler reader
+ test
This commit is contained in:
parent
b8102dcdc0
commit
7e73e0dd23
@ -949,6 +949,7 @@ interface
|
||||
constructor Create(b:byte);virtual;
|
||||
constructor Create_op(b: byte; _op: byte);virtual;
|
||||
constructor create_max(b: byte; max: byte);virtual;
|
||||
constructor create_op_max(b: byte; _op: byte; max: byte);virtual;
|
||||
constructor Create_zeros(b:byte);
|
||||
constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
|
||||
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||
@ -3349,6 +3350,21 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
constructor tai_align_abstract.create_op_max(b: byte; _op: byte; max: byte);
|
||||
begin
|
||||
inherited Create;
|
||||
typ:=ait_align;
|
||||
if b in [1,2,4,8,16,32] then
|
||||
aligntype := b
|
||||
else
|
||||
aligntype := 1;
|
||||
fillop:=_op;
|
||||
use_op:=true;
|
||||
maxbytes:=max;
|
||||
fillsize:=0;
|
||||
end;
|
||||
|
||||
|
||||
constructor tai_align_abstract.Create_zeros(b: byte);
|
||||
begin
|
||||
inherited Create;
|
||||
|
@ -1071,6 +1071,8 @@ unit raatt;
|
||||
lasTSec : TAsmSectiontype;
|
||||
l1,
|
||||
l2,
|
||||
l3,
|
||||
l4,
|
||||
symofs : tcgint;
|
||||
symtyp : TAsmsymtype;
|
||||
section : tai_section;
|
||||
@ -1255,7 +1257,35 @@ unit raatt;
|
||||
dec(l1);
|
||||
end;
|
||||
l1:=l2;
|
||||
ConcatAlign(curlist,l1);
|
||||
if actasmtoken=AS_COMMA then
|
||||
begin
|
||||
Consume(AS_COMMA);
|
||||
if not(actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
|
||||
begin
|
||||
l3:=BuildConstExpression(false,false);
|
||||
if (l3<0) or (l3>255) then
|
||||
Message(asmr_e_invalid_constant_expression);
|
||||
if actasmtoken=AS_COMMA then
|
||||
begin
|
||||
Consume(AS_COMMA);
|
||||
l4:=BuildConstExpression(false,false);
|
||||
if (l4<0) or (l4>l1) then
|
||||
Message(asmr_e_invalid_constant_expression);
|
||||
curlist.concat(Tai_align.create_op_max(l1,l3,l4));
|
||||
end
|
||||
end
|
||||
else if actasmtoken=AS_COMMA then
|
||||
begin
|
||||
Consume(AS_COMMA);
|
||||
l4:=BuildConstExpression(false,false);
|
||||
if (l4<0) or (l4>l1) then
|
||||
Message(asmr_e_invalid_constant_expression);
|
||||
curlist.concat(Tai_align.create_max(l1,l4));
|
||||
end
|
||||
end
|
||||
else
|
||||
ConcatAlign(curlist,l1);
|
||||
|
||||
if actasmtoken<>AS_SEPARATOR then
|
||||
Consume(AS_SEPARATOR);
|
||||
end;
|
||||
|
11
tests/test/tp2align.pp
Normal file
11
tests/test/tp2align.pp
Normal file
@ -0,0 +1,11 @@
|
||||
{ %cpu=x86_64,i386 }
|
||||
|
||||
begin
|
||||
asm
|
||||
nop
|
||||
.p2align 3
|
||||
.p2align 4,,10
|
||||
.p2align 4,0x90
|
||||
.p2align 4,0x90,10
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user