[5.60 X86] PBCompiler /COMMENTED

Just starting out? Need help? Post your questions and find answers here.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

[5.60 X86] PBCompiler /COMMENTED

Post 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)

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: [5.60 X86] PBCompiler /COMMENTED

Post 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.
Post Reply