mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-26 14:50:32 +02:00
+ support exporting labels from asm blocks in intel syntax asm blocks via the
'public' directive git-svn-id: trunk@37530 -
This commit is contained in:
parent
0c7306e1cd
commit
29558a74cd
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12423,6 +12423,7 @@ tests/test/tasm6.pp svneol=native#text/plain
|
|||||||
tests/test/tasm7.pp svneol=native#text/pascal
|
tests/test/tasm7.pp svneol=native#text/pascal
|
||||||
tests/test/tasm8.pp svneol=native#text/plain
|
tests/test/tasm8.pp svneol=native#text/plain
|
||||||
tests/test/tasm9.pp svneol=native#text/pascal
|
tests/test/tasm9.pp svneol=native#text/pascal
|
||||||
|
tests/test/tasmpublic1.pp svneol=native#text/pascal
|
||||||
tests/test/tasmread.pp svneol=native#text/plain
|
tests/test/tasmread.pp svneol=native#text/plain
|
||||||
tests/test/tasout.pp svneol=native#text/plain
|
tests/test/tasout.pp svneol=native#text/plain
|
||||||
tests/test/tassignmentoperator1.pp svneol=native#text/pascal
|
tests/test/tassignmentoperator1.pp svneol=native#text/pascal
|
||||||
|
@ -219,6 +219,7 @@ interface
|
|||||||
labelnr : longint;
|
labelnr : longint;
|
||||||
labeltype : TAsmLabelType;
|
labeltype : TAsmLabelType;
|
||||||
is_set : boolean;
|
is_set : boolean;
|
||||||
|
is_public : boolean;
|
||||||
constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
constructor Createlocal(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
constructor Createstatic(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
constructor Createstatic(AList: TFPHashObjectList; nr: longint; ltyp: TAsmLabelType);
|
||||||
constructor Createglobal(AList: TFPHashObjectList; const modulename: TSymStr; nr: longint; ltyp: TAsmLabelType);
|
constructor Createglobal(AList: TFPHashObjectList; const modulename: TSymStr; nr: longint; ltyp: TAsmLabelType);
|
||||||
|
@ -2483,7 +2483,7 @@ cg_f_max_units_reached=06057_F_Maximum number of units ($1) reached for the curr
|
|||||||
#
|
#
|
||||||
# Assembler reader
|
# Assembler reader
|
||||||
#
|
#
|
||||||
# 07136 is the last used one
|
# 07137 is the last used one
|
||||||
#
|
#
|
||||||
asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
|
asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
|
||||||
% This informs you that an assembler block is being parsed
|
% This informs you that an assembler block is being parsed
|
||||||
@ -2817,6 +2817,8 @@ asmr_e_pop_cs_not_valid=07135_E_Instruction "POP CS" is not valid for the curren
|
|||||||
% supported on the i386 or x86_64 targets.
|
% supported on the i386 or x86_64 targets.
|
||||||
asmr_w_pop_cs_not_portable=07136_W_Instruction "POP CS" is not portable (it only works on 8086 and 8088 CPUs)
|
asmr_w_pop_cs_not_portable=07136_W_Instruction "POP CS" is not portable (it only works on 8086 and 8088 CPUs)
|
||||||
% The 'pop cs' instruction doesn't work on any CPU, except 8086 and 8088.
|
% The 'pop cs' instruction doesn't work on any CPU, except 8086 and 8088.
|
||||||
|
asmr_e_public_must_be_used_before_label_definition=07137_E_Label $1 can only be declared public before it's defined
|
||||||
|
asmr_e_local_label_cannot_be_declared_public=07138_E_Local label $1 cannot be declared public
|
||||||
#
|
#
|
||||||
# Assembler/binary writers
|
# Assembler/binary writers
|
||||||
#
|
#
|
||||||
|
@ -818,6 +818,8 @@ const
|
|||||||
asmr_e_address_sizes_do_not_match=07134;
|
asmr_e_address_sizes_do_not_match=07134;
|
||||||
asmr_e_pop_cs_not_valid=07135;
|
asmr_e_pop_cs_not_valid=07135;
|
||||||
asmr_w_pop_cs_not_portable=07136;
|
asmr_w_pop_cs_not_portable=07136;
|
||||||
|
asmr_e_public_must_be_used_before_label_definition=07137;
|
||||||
|
asmr_e_local_label_cannot_be_declared_public=07138;
|
||||||
asmw_f_too_many_asm_files=08000;
|
asmw_f_too_many_asm_files=08000;
|
||||||
asmw_f_assembler_output_not_supported=08001;
|
asmw_f_assembler_output_not_supported=08001;
|
||||||
asmw_f_comp_not_supported=08002;
|
asmw_f_comp_not_supported=08002;
|
||||||
@ -1088,9 +1090,9 @@ const
|
|||||||
option_info=11024;
|
option_info=11024;
|
||||||
option_help_pages=11025;
|
option_help_pages=11025;
|
||||||
|
|
||||||
MsgTxtSize = 80799;
|
MsgTxtSize = 80913;
|
||||||
|
|
||||||
MsgIdxMax : array[1..20] of longint=(
|
MsgIdxMax : array[1..20] of longint=(
|
||||||
27,105,347,124,96,58,137,33,221,67,
|
27,105,347,124,96,58,139,33,221,67,
|
||||||
60,20,30,1,1,1,1,1,1,1
|
60,20,30,1,1,1,1,1,1,1
|
||||||
);
|
);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1065,7 +1065,11 @@ unit raatt;
|
|||||||
AS_LABEL:
|
AS_LABEL:
|
||||||
Begin
|
Begin
|
||||||
if SearchLabel(upper(actasmpattern),hl,true) then
|
if SearchLabel(upper(actasmpattern),hl,true) then
|
||||||
ConcatLabel(curlist,hl)
|
begin
|
||||||
|
if hl.is_public then
|
||||||
|
ConcatPublic(curlist,actasmpattern);
|
||||||
|
ConcatLabel(curlist,hl);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Message1(asmr_e_unknown_label_identifier,actasmpattern);
|
Message1(asmr_e_unknown_label_identifier,actasmpattern);
|
||||||
Consume(AS_LABEL);
|
Consume(AS_LABEL);
|
||||||
|
@ -40,7 +40,7 @@ Unit Rax86int;
|
|||||||
AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
|
AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
|
||||||
AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,
|
AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,
|
||||||
{------------------ Assembler directives --------------------}
|
{------------------ Assembler directives --------------------}
|
||||||
AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_DQ,AS_END,
|
AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_DQ,AS_PUBLIC,AS_END,
|
||||||
{------------------ Assembler Operators --------------------}
|
{------------------ Assembler Operators --------------------}
|
||||||
AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_OWORD,AS_XMMWORD,AS_YWORD,AS_YMMWORD,AS_NEAR,AS_FAR,
|
AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_OWORD,AS_XMMWORD,AS_YWORD,AS_YMMWORD,AS_NEAR,AS_FAR,
|
||||||
AS_HIGH,AS_LOW,AS_OFFSET,AS_SIZEOF,AS_VMTOFFSET,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
|
AS_HIGH,AS_LOW,AS_OFFSET,AS_SIZEOF,AS_VMTOFFSET,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
|
||||||
@ -48,6 +48,7 @@ Unit Rax86int;
|
|||||||
|
|
||||||
type
|
type
|
||||||
tx86intreader = class(tasmreader)
|
tx86intreader = class(tasmreader)
|
||||||
|
actasmpattern_origcase : string;
|
||||||
actasmtoken : tasmtoken;
|
actasmtoken : tasmtoken;
|
||||||
prevasmtoken : tasmtoken;
|
prevasmtoken : tasmtoken;
|
||||||
ActOpsize : topsize;
|
ActOpsize : topsize;
|
||||||
@ -116,7 +117,7 @@ Unit Rax86int;
|
|||||||
_count_asmoperators = longint(lastoperator)-longint(firstoperator);
|
_count_asmoperators = longint(lastoperator)-longint(firstoperator);
|
||||||
|
|
||||||
_asmdirectives : array[0.._count_asmdirectives] of tasmkeyword =
|
_asmdirectives : array[0.._count_asmdirectives] of tasmkeyword =
|
||||||
('ALIGN','DB','DW','DD','DQ','END');
|
('ALIGN','DB','DW','DD','DQ','PUBLIC','END');
|
||||||
|
|
||||||
{ problems with shl,shr,not,and,or and xor, they are }
|
{ problems with shl,shr,not,and,or and xor, they are }
|
||||||
{ context sensitive. }
|
{ context sensitive. }
|
||||||
@ -130,7 +131,7 @@ Unit Rax86int;
|
|||||||
',',',',',',',',',','[',']','(',
|
',',',',',',',',',','[',']','(',
|
||||||
')',':','.','+','-','*',
|
')',':','.','+','-','*',
|
||||||
';','identifier','register','opcode','/',
|
';','identifier','register','opcode','/',
|
||||||
'','','','','','END',
|
'','','','','','','END',
|
||||||
'','','','','','','','','',
|
'','','','','','','','','',
|
||||||
'','','sizeof','vmtoffset','','type','ptr','mod','shl','shr','not',
|
'','','sizeof','vmtoffset','','type','ptr','mod','shl','shr','not',
|
||||||
'and','or','xor','wrt','..gotpcrel'
|
'and','or','xor','wrt','..gotpcrel'
|
||||||
@ -284,6 +285,7 @@ Unit Rax86int;
|
|||||||
c:=current_scanner.asmgetchar;
|
c:=current_scanner.asmgetchar;
|
||||||
end;
|
end;
|
||||||
actasmpattern[0]:=chr(len);
|
actasmpattern[0]:=chr(len);
|
||||||
|
actasmpattern_origcase:=actasmpattern;
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
{ allow spaces }
|
{ allow spaces }
|
||||||
while (c in [' ',#9]) do
|
while (c in [' ',#9]) do
|
||||||
@ -331,6 +333,7 @@ Unit Rax86int;
|
|||||||
actasmpattern:=actasmpattern + c;
|
actasmpattern:=actasmpattern + c;
|
||||||
c:=current_scanner.asmgetchar;
|
c:=current_scanner.asmgetchar;
|
||||||
end;
|
end;
|
||||||
|
actasmpattern_origcase:=actasmpattern;
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
actasmtoken:=AS_ID;
|
actasmtoken:=AS_ID;
|
||||||
exit;
|
exit;
|
||||||
@ -345,6 +348,7 @@ Unit Rax86int;
|
|||||||
actasmpattern:=actasmpattern + c;
|
actasmpattern:=actasmpattern + c;
|
||||||
c:=current_scanner.asmgetchar;
|
c:=current_scanner.asmgetchar;
|
||||||
end;
|
end;
|
||||||
|
actasmpattern_origcase:=actasmpattern;
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
{ after prefix (or segment override) we allow also a new opcode }
|
{ after prefix (or segment override) we allow also a new opcode }
|
||||||
If (is_prefix(actopcode) or is_override(actopcode)) and is_asmopcode(actasmpattern) then
|
If (is_prefix(actopcode) or is_override(actopcode)) and is_asmopcode(actasmpattern) then
|
||||||
@ -533,6 +537,7 @@ Unit Rax86int;
|
|||||||
actasmpattern:=actasmpattern + c;
|
actasmpattern:=actasmpattern + c;
|
||||||
c:=current_scanner.asmgetchar;
|
c:=current_scanner.asmgetchar;
|
||||||
end;
|
end;
|
||||||
|
actasmpattern_origcase:=actasmpattern;
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
actasmtoken:=AS_ID;
|
actasmtoken:=AS_ID;
|
||||||
exit;
|
exit;
|
||||||
@ -656,6 +661,7 @@ Unit Rax86int;
|
|||||||
c:=current_scanner.asmgetchar;
|
c:=current_scanner.asmgetchar;
|
||||||
end;
|
end;
|
||||||
{ Get ending character }
|
{ Get ending character }
|
||||||
|
actasmpattern_origcase:=actasmpattern;
|
||||||
uppervar(actasmpattern);
|
uppervar(actasmpattern);
|
||||||
c:=upcase(c);
|
c:=upcase(c);
|
||||||
{ possibly a binary number. }
|
{ possibly a binary number. }
|
||||||
@ -2495,6 +2501,8 @@ Unit Rax86int;
|
|||||||
Var
|
Var
|
||||||
hl : tasmlabel;
|
hl : tasmlabel;
|
||||||
instr : Tx86Instruction;
|
instr : Tx86Instruction;
|
||||||
|
tmpsym: tsym;
|
||||||
|
tmpsrsymtable: TSymtable;
|
||||||
Begin
|
Begin
|
||||||
Message1(asmr_d_start_reading,'intel');
|
Message1(asmr_d_start_reading,'intel');
|
||||||
inexpression:=FALSE;
|
inexpression:=FALSE;
|
||||||
@ -2526,7 +2534,11 @@ Unit Rax86int;
|
|||||||
AS_LABEL:
|
AS_LABEL:
|
||||||
Begin
|
Begin
|
||||||
if SearchLabel(upper(actasmpattern),hl,true) then
|
if SearchLabel(upper(actasmpattern),hl,true) then
|
||||||
ConcatLabel(curlist,hl)
|
begin
|
||||||
|
if hl.is_public then
|
||||||
|
ConcatPublic(curlist,actasmpattern_origcase);
|
||||||
|
ConcatLabel(curlist,hl);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Message1(asmr_e_unknown_label_identifier,actasmpattern);
|
Message1(asmr_e_unknown_label_identifier,actasmpattern);
|
||||||
Consume(AS_LABEL);
|
Consume(AS_LABEL);
|
||||||
@ -2566,6 +2578,37 @@ Unit Rax86int;
|
|||||||
end;
|
end;
|
||||||
{$endif cpu64bitaddr}
|
{$endif cpu64bitaddr}
|
||||||
|
|
||||||
|
AS_PUBLIC:
|
||||||
|
Begin
|
||||||
|
Consume(AS_PUBLIC);
|
||||||
|
repeat
|
||||||
|
if actasmtoken=AS_ID then
|
||||||
|
begin
|
||||||
|
if (actasmpattern<>'') and (actasmpattern[1]='@') then
|
||||||
|
Message1(asmr_e_local_label_cannot_be_declared_public,actasmpattern)
|
||||||
|
else if SearchLabel(upper(actasmpattern),hl,false) then
|
||||||
|
begin
|
||||||
|
if not hl.is_public then
|
||||||
|
begin
|
||||||
|
hl.is_public:=true;
|
||||||
|
asmsearchsym(upper(actasmpattern),tmpsym,tmpsrsymtable);
|
||||||
|
if tlabelsym(tmpsym).defined then
|
||||||
|
Message1(asmr_e_public_must_be_used_before_label_definition,actasmpattern);
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Message1(asmr_e_unknown_label_identifier,actasmpattern);
|
||||||
|
end;
|
||||||
|
Consume(AS_ID);
|
||||||
|
if actasmtoken=AS_COMMA then
|
||||||
|
begin
|
||||||
|
Consume(AS_COMMA);
|
||||||
|
if actasmtoken<>AS_ID then
|
||||||
|
Consume(AS_ID);
|
||||||
|
end;
|
||||||
|
until actasmtoken=AS_SEPARATOR;
|
||||||
|
end;
|
||||||
|
|
||||||
AS_ALIGN:
|
AS_ALIGN:
|
||||||
Begin
|
Begin
|
||||||
Consume(AS_ALIGN);
|
Consume(AS_ALIGN);
|
||||||
|
32
tests/test/tasmpublic1.pp
Normal file
32
tests/test/tasmpublic1.pp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{ %CPU=i386,x86_64 }
|
||||||
|
program tasmpublic1;
|
||||||
|
|
||||||
|
{$goto on}
|
||||||
|
{$asmmode intel}
|
||||||
|
|
||||||
|
label
|
||||||
|
test_gLoBaL_label;
|
||||||
|
|
||||||
|
var
|
||||||
|
codeseg_var: LongWord; external name 'test_gLoBaL_label';
|
||||||
|
|
||||||
|
begin
|
||||||
|
asm
|
||||||
|
public test_gLoBaL_label
|
||||||
|
jmp @@skip
|
||||||
|
db 'some garbage here'
|
||||||
|
test_gLoBaL_label:
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
@@skip:
|
||||||
|
end;
|
||||||
|
if codeseg_var<>$90909090 then
|
||||||
|
begin
|
||||||
|
Writeln('Error!');
|
||||||
|
Halt(1);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Writeln('Ok!');
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user