Check rjmp destination range.

This commit is contained in:
ccrause 2025-03-02 19:50:30 +02:00
parent f29f794543
commit b0003f71dd
2 changed files with 10 additions and 2 deletions

View File

@ -482,7 +482,7 @@ implementation
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<-64*2)) then (taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<-64*2)) then
begin begin
if inasmblock then if inasmblock then
MessagePos(taicpu(curtai).fileinfo,asmw_e_brxx_out_of_range) MessagePos1(taicpu(curtai).fileinfo,asmw_e_destination_out_of_range,'BR'+uppercond2str[taicpu(curtai).condition])
else else
begin begin
current_asmdata.getjumplabel(l); current_asmdata.getjumplabel(l);
@ -497,6 +497,14 @@ implementation
again:=true; again:=true;
end; end;
end; end;
A_RJMP:
if inasmblock and (taicpu(curtai).oper[0]^.typ=top_ref) and
not(taicpu(curtai).oper[0]^.ref^.symbol.typ=AT_FUNCTION) and
((taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset>2047*2) or
(taicpu(curtai).InsOffset-taicpu(curtai).oper[0]^.ref^.symbol.offset<-2048*2)) then
begin
MessagePos1(taicpu(curtai).fileinfo,asmw_e_destination_out_of_range,'RJMP');
end;
A_JMP: A_JMP:
{ replace JMP by RJMP? ... { replace JMP by RJMP? ...
... but do not mess with asm block. ... but do not mess with asm block.

View File

@ -3079,7 +3079,7 @@ asmw_e_32bit_not_supported=08029_E_Asm: 32 bit references not supported
asmw_f_code_segment_too_large=08030_F_Code segment too large asmw_f_code_segment_too_large=08030_F_Code segment too large
asmw_f_data_segment_too_large=08031_F_Data segment too large asmw_f_data_segment_too_large=08031_F_Data segment too large
asmw_e_instruction_not_supported_by_cpu=08032_E_Instruction not supported by the selected instruction set asmw_e_instruction_not_supported_by_cpu=08032_E_Instruction not supported by the selected instruction set
asmw_e_brxx_out_of_range=08033_E_Asm: conditional branch destination is out of range asmw_e_destination_out_of_range=08033_E_Asm: $1 destination is out of range
asmw_e_illegal_use_of_rip=08034_E_Asm: RIP cannot be used as index register or with another register in a reference asmw_e_illegal_use_of_rip=08034_E_Asm: RIP cannot be used as index register or with another register in a reference
asmw_e_seh_invalid_data_size=08035_F_Illegal function size for SEH function asmw_e_seh_invalid_data_size=08035_F_Illegal function size for SEH function
asmw_e_illegal_use_of_sp=08036_E_Asm: ESP/RSP cannot be used as index register asmw_e_illegal_use_of_sp=08036_E_Asm: ESP/RSP cannot be used as index register