diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas
index becfe3819c..7b527bf3b8 100644
--- a/compiler/aasmtai.pas
+++ b/compiler/aasmtai.pas
@@ -407,9 +407,7 @@ interface
         { for the OMF object format }
         asd_omf_linnum_line,
         { RISC-V }
-        asd_option,
-        { WebAssembly }
-        asd_end_function
+        asd_option
       );
 
       TAsmSehDirective=(
@@ -454,9 +452,7 @@ interface
         { for the OMF object format }
         'omf_line',
         { RISC-V }
-        'option',
-        { WebAssembly }
-        'end_function'
+        'option'
       );
       sehdirectivestr : array[TAsmSehDirective] of string[16]=(
         '.seh_proc','.seh_endproc',
diff --git a/compiler/aggas.pas b/compiler/aggas.pas
index 85f2eafe38..fe17b9c121 100644
--- a/compiler/aggas.pas
+++ b/compiler/aggas.pas
@@ -1811,8 +1811,6 @@ implementation
         name has to be translated as well }
       if dir=asd_cpu then
         writer.AsmWrite(asminfo^.comment+' CPU ')
-      else if dir=asd_end_function then
-        writer.AsmWrite(#9#9+directivestr[dir])
       else
         writer.AsmWrite('.'+directivestr[dir]+' ');
     end;
diff --git a/compiler/wasm32/cpubase.pas b/compiler/wasm32/cpubase.pas
index dbc30bab7a..e0b420be8d 100644
--- a/compiler/wasm32/cpubase.pas
+++ b/compiler/wasm32/cpubase.pas
@@ -40,7 +40,7 @@ uses
       TAsmOp=(A_None,
       // control flow
       a_block, a_loop, a_br, a_br_if, a_br_table, a_if, a_else, a_end_block,
-      a_end_loop, a_end_if, a_return, a_unreachable,
+      a_end_loop, a_end_if, a_end_function, a_return, a_unreachable,
       // basic
       a_nop, a_drop, a_i32_const, a_i64_const, a_f32_const, a_f64_const,
       a_get_local, a_set_local, a_tee_local, a_get_global, a_set_global,
diff --git a/compiler/wasm32/hlcgcpu.pas b/compiler/wasm32/hlcgcpu.pas
index c7b5790733..6cc22b75f3 100644
--- a/compiler/wasm32/hlcgcpu.pas
+++ b/compiler/wasm32/hlcgcpu.pas
@@ -1707,7 +1707,7 @@ implementation
       list.Concat(taicpu.op_sym(a_set_global,current_asmdata.RefAsmSymbol(STACK_POINTER_SYM,AT_LABEL)));
 
       list.concat(taicpu.op_none(a_return));
-      list.concat(tai_directive.Create(asd_end_function,''));
+      list.concat(taicpu.op_none(a_end_function));
     end;
 
   procedure thlcgwasm.gen_load_return_value(list: TAsmList);
diff --git a/compiler/wasm32/itcpugas.pas b/compiler/wasm32/itcpugas.pas
index 93031e109c..a946db0c00 100644
--- a/compiler/wasm32/itcpugas.pas
+++ b/compiler/wasm32/itcpugas.pas
@@ -39,7 +39,7 @@ interface
       '<none>',
       // control flow
       'block', 'loop', 'br', 'br_if', 'br_table', 'if', 'else', 'end_block',
-      'end_loop', 'end_if', 'return', 'unreachable',
+      'end_loop', 'end_if', 'end_function', 'return', 'unreachable',
       // basic
       'nop', 'drop', 'i32.const', 'i64.const', 'f32.const', 'f64.const',
       'local.get', 'local.set', 'local.tee', 'global.get', 'global.set',
diff --git a/compiler/wasm32/strinst.inc b/compiler/wasm32/strinst.inc
index 564fa6bf26..c57201b687 100644
--- a/compiler/wasm32/strinst.inc
+++ b/compiler/wasm32/strinst.inc
@@ -22,7 +22,7 @@
 
         '<none>',
         // control flow
-        'block', 'loop', 'br', 'br_if', 'br_table', 'if', 'else', 'end', 'end', 'end',
+        'block', 'loop', 'br', 'br_if', 'br_table', 'if', 'else', 'end', 'end', 'end', '',
         'return', 'unreachable',
         // basic
         'nop', 'drop', 'i32.const', 'i64.const', 'f32.const', 'f64.const',