Page 1 of 1

[5.60 X86] PBCompiler /COMMENTED

Posted: Wed Oct 11, 2017 1:39 pm
by falsam
If I'm trying to create a user library with this test code, I'm having a weird behavior when I test the result with PureBasic 5.60 x86.

User library creation test code.

Code: Select all

ProcedureDLL.s Dummy()
  ProcedureReturn "bug"
EndProcedure
To create this user library, I use the tools present in the Purebasic installation folder.
- pbcompiler. exe /COMMENTED to get the ASM file
- fasm. exe to get the obj file
- LibraryMaker. exe to obtain the user library.

The user library is created.
I test the result with this code.

Code: Select all

Debug "no " + Dummy()
I should get "no bug" but in fact, I get "bug".

An extract from the ASM code

Code: Select all

; ProcedureDLL.s Dummy()
public PB_Dummy
PB_Dummy:
  PS0=4
; ProcedureReturn "bug"
  MOV    edx,_S1
  PUSH   dword [_PB_StringBasePosition]
  PUSH   edx
  CALL  _SYS_CopyString@4
  POP    eax
  ADD    eax,[PB_StringBase]
  JMP   _EndProcedure1
; EndProcedure  
_EndProcedureZero1:
  MOV    eax,[_PB_StringBasePosition]
  ADD    eax,[PB_StringBase]
  MOV    word [eax],0
_EndProcedure1:
  RET
:idea: Last line: If I replace RET by RET + 4 The result is correct "no bug".

I don't have this problem with the x64 versions of PureBasic. That's why I think it's a bug with pbcompiler. exe (x86)

Re: [5.60 X86] PBCompiler /COMMENTED

Posted: Wed Oct 11, 2017 10:55 pm
by GPI
It is not a bug. The Ret+4 is generated by tailbite because it use the ProcedureDLL for generating a userlibrary. But the asm-code generated by purebasic is designed to use in a DLL, not userlib. When you "fix it", it would crash, when you a program load the dll and what to use the dll-function.