diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index 543577bee5..887dc58e8f 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -112,6 +112,9 @@ interface RELOC_ABSOLUTE_HI8, RELOC_ABSOLUTE_LO8, {$endif z80} +{$ifdef WASM32} + RELOC_FUNCTION_INDEX_LEB, +{$endif WASM32} { Relative relocation } RELOC_RELATIVE, { PECoff (Windows) RVA relocation } diff --git a/compiler/wasm32/aasmcpu.pas b/compiler/wasm32/aasmcpu.pas index f782917be6..a9f80c69e2 100644 --- a/compiler/wasm32/aasmcpu.pas +++ b/compiler/wasm32/aasmcpu.pas @@ -585,6 +585,22 @@ implementation internalerror(2021092017); end; end; + a_call: + begin + if ops<>1 then + internalerror(2021092021); + with oper[0]^ do + case typ of + top_ref: + begin + if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then + internalerror(2021092023); + result:=6; + end; + else + internalerror(2021092022); + end; + end; else Writeln('Warning! Not implemented opcode, pass1: ', opcode); end; @@ -1037,6 +1053,23 @@ implementation internalerror(2021092017); end; end; + a_call: + begin + if ops<>1 then + internalerror(2021092021); + with oper[0]^ do + case typ of + top_ref: + begin + if not assigned(ref^.symbol) or (ref^.base<>NR_NO) or (ref^.index<>NR_NO) or (ref^.offset<>0) then + internalerror(2021092023); + WriteByte($10); + objdata.writeReloc(0,5,ObjData.symbolref(ref^.symbol),RELOC_FUNCTION_INDEX_LEB); + end; + else + internalerror(2021092022); + end; + end; else Writeln('Warning! Not implemented opcode, pass2: ', opcode); end;