diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas
index 542a5a6541..6e38c63550 100644
--- a/compiler/hlcgobj.pas
+++ b/compiler/hlcgobj.pas
@@ -631,6 +631,8 @@ unit hlcgobj;
           procedure gen_load_return_value(list:TAsmList);virtual;
 
           { extras refactored from other units }
+          procedure gen_stack_check_size_para(list:TAsmList); virtual;
+          procedure gen_stack_check_call(list:TAsmList); virtual;
 
           { queue the code/data generated for a procedure for writing out to
             the assembler/object file }
@@ -5191,6 +5193,35 @@ implementation
         gen_load_uninitialized_function_result(list,current_procinfo.procdef,retdef,current_procinfo.procdef.funcretloc[calleeside])
     end;
 
+  procedure thlcgobj.gen_stack_check_size_para(list: TAsmList);
+    var
+      paraloc1 : tcgpara;
+      pd       : tprocdef;
+    begin
+      pd:=search_system_proc('fpc_stackcheck');
+      paraloc1.init;
+      paramanager.getintparaloc(current_asmdata.CurrAsmList,pd,1,paraloc1);
+      hlcg.a_load_const_cgpara(list,paraloc1.def,current_procinfo.calc_stackframe_size,paraloc1);
+      paramanager.freecgpara(list,paraloc1);
+      paraloc1.done;
+    end;
+
+  procedure thlcgobj.gen_stack_check_call(list: TAsmList);
+    var
+      paraloc1 : tcgpara;
+      pd       : tprocdef;
+    begin
+      pd:=search_system_proc('fpc_stackcheck');
+      paraloc1.init;
+      { The parameter to fpc_stackcheck is loaded seperately via
+        gen_stack_check_size_para() }
+      paramanager.getintparaloc(list,pd,1,paraloc1);
+      paramanager.freecgpara(list,paraloc1);
+      { Call the helper }
+      hlcg.g_call_system_proc(list,pd,[@paraloc1],nil);
+      paraloc1.done;
+    end;
+
   procedure thlcgobj.record_generated_code_for_procdef(pd: tprocdef; code, data: TAsmList);
     var
       alt: TAsmListType;
diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas
index b09c97306c..e5b00b75cf 100644
--- a/compiler/ncgutil.pas
+++ b/compiler/ncgutil.pas
@@ -79,8 +79,6 @@ interface
     procedure release_proc_symbol(pd:tprocdef);
     procedure gen_proc_entry_code(list:TAsmList);
     procedure gen_proc_exit_code(list:TAsmList);
-    procedure gen_stack_check_size_para(list:TAsmList);
-    procedure gen_stack_check_call(list:TAsmList);
     procedure gen_save_used_regs(list:TAsmList);
     procedure gen_restore_used_regs(list:TAsmList);
     procedure gen_load_para_value(list:TAsmList);
@@ -1467,38 +1465,6 @@ implementation
       end;
 
 
-    procedure gen_stack_check_size_para(list:TAsmList);
-      var
-        paraloc1 : tcgpara;
-        pd       : tprocdef;
-      begin
-        pd:=search_system_proc('fpc_stackcheck');
-        paraloc1.init;
-        paramanager.getintparaloc(current_asmdata.CurrAsmList,pd,1,paraloc1);
-        cg.a_load_const_cgpara(list,OS_INT,current_procinfo.calc_stackframe_size,paraloc1);
-        paramanager.freecgpara(list,paraloc1);
-        paraloc1.done;
-      end;
-
-
-    procedure gen_stack_check_call(list:TAsmList);
-      var
-        paraloc1 : tcgpara;
-        pd       : tprocdef;
-      begin
-        pd:=search_system_proc('fpc_stackcheck');
-        paraloc1.init;
-        { Also alloc the register needed for the parameter }
-        paramanager.getintparaloc(current_asmdata.CurrAsmList,pd,1,paraloc1);
-        paramanager.freecgpara(list,paraloc1);
-        { Call the helper }
-        cg.allocallcpuregisters(list);
-        cg.a_call_name(list,'FPC_STACKCHECK',false);
-        cg.deallocallcpuregisters(list);
-        paraloc1.done;
-      end;
-
-
     procedure gen_save_used_regs(list:TAsmList);
       begin
         { Pure assembler routines need to save the registers themselves }
diff --git a/compiler/psub.pas b/compiler/psub.pas
index a22f9e9305..5233a31c27 100644
--- a/compiler/psub.pas
+++ b/compiler/psub.pas
@@ -1556,7 +1556,7 @@ implementation
                (procdef.proctypeoption<>potype_proginit) then
               begin
                 current_filepos:=entrypos;
-                gen_stack_check_call(templist);
+                hlcg.gen_stack_check_call(templist);
                 aktproccode.insertlistafter(stackcheck_asmnode.currenttai,templist)
               end;
 
@@ -1627,7 +1627,7 @@ implementation
                (procdef.proctypeoption<>potype_proginit) then
               begin
                 current_filepos:=entrypos;
-                gen_stack_check_size_para(templist);
+                hlcg.gen_stack_check_size_para(templist);
                 aktproccode.insertlistafter(stackcheck_asmnode.currenttai,templist)
               end;
             { Add entry code (stack allocation) after header }