here the C-Output of your definition
Code: Select all
void* r0=v_func(_S2,SYS_PopStringBasePosition());
In C there are 2 Parameters
if I remove the arg$, the output is different, and it works
Code: Select all
void* r0=v_func(SYS_PopStringBasePosition())
It seems C creates extra Parameter for the Return-String what is added to the function call!
So in the C-Backend it is done correctly what creates a Stack problem if one Parameter is missing.
PB help says for Prototype - Parameters are checked. But in reals I think the PB compiler do not check!
in the ASM Backend the function call pushes 2 String-Pointers on the Stack too!
1 for the Return String on one for the arg$. But it do not crash!
Code: Select all
; res$= func("")
PUSH qword [PB_StringBasePosition]
PUSH qword [PB_StringBasePosition]
PUSH rax
POP rcx
SUB rsp,32
CALL qword [v_func]
ADD rsp,40
LEA rcx,[v_res$]
POP rdx
CALL SYS_AllocateString4
I guess it works because the Stack is correctly managed with
SUB rsp,32 and ADD resp40
inside RetrunHelloWorld in ASM-Backend:
Stack is managed with Sub rsp, 40 and at the end with Add rsp 40
That shows, that the Stack-Correction for the Functions Parameters is not done inside the Procedure, it's done directly with the call.
That's the reason why it works in ASM. Maybe this is a workarround in the ASM Backend to prevent missing parameters.
I guess if we would disassemble the C-Exe we will find the Stack-Correction of the Procedrue Parameters inside the Procedure
what will end up in a Stack-Problem.
But generally. If you define a Parameter in a Prototype, you have to do this correctly.
Your Prototype definition for ReturnHelloWorld is wrong!
I confirm, there should be a message because PB Help says parameters are checked!