diff --git a/compiler/wasm32/aasmcpu.pas b/compiler/wasm32/aasmcpu.pas index aba4748ed4..8b5acd809f 100644 --- a/compiler/wasm32/aasmcpu.pas +++ b/compiler/wasm32/aasmcpu.pas @@ -347,17 +347,23 @@ uses { TWasmValueStack } function TWasmValueStack.GetItems(AIndex: Integer): TWasmBasicType; + var + I: Integer; begin - if (AIndexHigh(FValStack)) then + I:=High(FValStack)-AIndex; + if (IHigh(FValStack)) then internalerror(2024011702); - Result:=FValStack[AIndex]; + Result:=FValStack[I]; end; procedure TWasmValueStack.SetItems(AIndex: Integer; AValue: TWasmBasicType); + var + I: Integer; begin - if (AIndexHigh(FValStack)) then + I:=High(FValStack)-AIndex; + if (IHigh(FValStack)) then internalerror(2024011703); - FValStack[AIndex]:=AValue; + FValStack[I]:=AValue; end; procedure TWasmValueStack.Push(wbt: TWasmBasicType);