* High() and Length() for dynamic arrays deal with sizesinttype instead of ossinttype (on AVR the former is 16-bit while the later is 8-bit thus this is an important distinction)

This commit is contained in:
Sven/Sarah Barth 2022-01-18 21:54:05 +01:00
parent c062061d6d
commit c59b6a5d8d
2 changed files with 4 additions and 4 deletions

View File

@ -295,7 +295,7 @@ implementation
if is_widestring(left.resultdef) then if is_widestring(left.resultdef) then
lendef:=u32inttype lendef:=u32inttype
else else
lendef:=ossinttype; lendef:=sizesinttype;
{ volatility of the ansistring/widestring refers to the volatility of the { volatility of the ansistring/widestring refers to the volatility of the
string pointer, not of the string data } string pointer, not of the string data }
hlcg.reference_reset_base(href,left.resultdef,left.location.register,-lendef.size,ctempposinvalid,lendef.alignment,[]); hlcg.reference_reset_base(href,left.resultdef,left.location.register,-lendef.size,ctempposinvalid,lendef.alignment,[]);
@ -338,12 +338,12 @@ implementation
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,left.resultdef,OC_EQ,0,left.location.register,nillab); hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,left.resultdef,OC_EQ,0,left.location.register,nillab);
{ volatility of the dyn. array refers to the volatility of the { volatility of the dyn. array refers to the volatility of the
string pointer, not of the string data } string pointer, not of the string data }
hlcg.reference_reset_base(href,left.resultdef,left.location.register,-ossinttype.size,ctempposinvalid,ossinttype.alignment,[]); hlcg.reference_reset_base(href,left.resultdef,left.location.register,-sizesinttype.size,ctempposinvalid,ossinttype.alignment,[]);
{ if the string pointer is nil, the length is 0 -> reuse the register { if the string pointer is nil, the length is 0 -> reuse the register
that originally held the string pointer for the length, so that we that originally held the string pointer for the length, so that we
can keep the original nil/0 as length in that case } can keep the original nil/0 as length in that case }
hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,def_cgsize(resultdef)); hregister:=cg.makeregsize(current_asmdata.CurrAsmList,left.location.register,def_cgsize(resultdef));
hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,ossinttype,resultdef,href,hregister); hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,sizesinttype,resultdef,href,hregister);
hlcg.a_jmp_always(current_asmdata.CurrAsmList,donelab); hlcg.a_jmp_always(current_asmdata.CurrAsmList,donelab);
cg.a_label(current_asmdata.CurrAsmList,nillab); cg.a_label(current_asmdata.CurrAsmList,nillab);

View File

@ -3201,7 +3201,7 @@ implementation
if is_shortstring(left.resultdef) then if is_shortstring(left.resultdef) then
resultdef:=u8inttype resultdef:=u8inttype
else else
resultdef:=ossinttype; resultdef:=sizesinttype;
end; end;
in_typeinfo_x: in_typeinfo_x: