What is the difference between ASM backend vs C backend ?
What is the difference between ASM backend vs C backend ?
What is the difference between ASM backend vs C backend ?
Hi, could be curious to know what is the difference between ASM back end and C backend ?
features ? performance ? accuracy ? code size ? effort of coding ? any idea ?
since we all code in PB language and get the final .exe and run our projects , dose it matter much to make us choose one over another back end ?
since PB was compile to ASM initially an natively for a long long time , what motivate him to develop another back end ?
it clearly will have more benefits then the old one ? or else why ?
seems i miss many things , thanks if someone could enlighten me for some points.
thanks guy
Hi, could be curious to know what is the difference between ASM back end and C backend ?
features ? performance ? accuracy ? code size ? effort of coding ? any idea ?
since we all code in PB language and get the final .exe and run our projects , dose it matter much to make us choose one over another back end ?
since PB was compile to ASM initially an natively for a long long time , what motivate him to develop another back end ?
it clearly will have more benefits then the old one ? or else why ?
seems i miss many things , thanks if someone could enlighten me for some points.
thanks guy
Re: What is the difference between ASM backend vs C backend ?
C backend allows for easy porting to new and emerging platforms. C backend is also able to be optimized more and often produces faster code.
Best wishes to the PB community. Thank you for the memories. 
Re: What is the difference between ASM backend vs C backend ?
if so this two reason , doesn't it to code in C make more sense ?Kuron wrote: Fri Nov 10, 2023 7:22 am C backend allows for easy porting to new and emerging platforms. C backend is also able to be optimized more and often produces faster code.
or it must have more other reasons ?
Re: What is the difference between ASM backend vs C backend ?
https://www.purebasic.fr/blog/?p=480
https://www.purebasic.fr/blog/?p=486
https://www.purebasic.fr/blog/?p=502
https://www.purebasic.fr/blog/?p=486
https://www.purebasic.fr/blog/?p=502
Best wishes to the PB community. Thank you for the memories. 
Re: What is the difference between ASM backend vs C backend ?
ok, like so the three post above , C is the way to the future .Kuron wrote: Fri Nov 10, 2023 7:48 am https://www.purebasic.fr/blog/?p=480
https://www.purebasic.fr/blog/?p=486
https://www.purebasic.fr/blog/?p=502
we then see that the ASM backend will be drop soon or later.
look like learning C is a lot easier then learning asm for regular programmer .
dose it better if we code in pure C language directly instead of coding in PB and output to C and port to other platform ?
Re: What is the difference between ASM backend vs C backend ?
In my experience, the C backend produces less (sometimes none) anti-virus false-positives compared to compiling with ASM. My take on this is that the malware written by PureBasic in the past (PureLocker) was done with the ASM backend, so certain code pattern triggers are now forever tied to it.
My main app is still ASM because it uses inline assembler that I need, but all my new apps use the C backend to avoid triggering false-positives now.
My main app is still ASM because it uses inline assembler that I need, but all my new apps use the C backend to avoid triggering false-positives now.
Re: What is the difference between ASM backend vs C backend ?
I would generally agree, but Ethan Winer (who was quite the BASIC and ASM guru) said "C has all of the difficulty of dealing with assembly language, but none of the benefits."moricode wrote: Fri Nov 10, 2023 8:11 am look like learning C is a lot easier then learning asm for regular programmer .
Personally, I will always code in PB, and use ASM backend for testing, and use C backend for releases. This is what Fred recommended to me.
Best wishes to the PB community. Thank you for the memories. 
Re: What is the difference between ASM backend vs C backend ?
how about if you don't get bug in ASM backend when testing , but there is a new bug when release (using C backend)?
dose this two in equivalent in testing or release ?
Re: What is the difference between ASM backend vs C backend ?
Yes, C is portable and you can code for every platform in C if you like.
But ...
if it comes to any other 'feature' than pure logic code, like GUI, databases, web ...
You need to do your on stuff (libraries, frameworks, ...) for each platform.
It is much more comfortable to use PB
As you have written: you code in PB and get an executable
Unfortunately I still have many codes which does not work with the C backend.
But it is the future.
But ...
if it comes to any other 'feature' than pure logic code, like GUI, databases, web ...
You need to do your on stuff (libraries, frameworks, ...) for each platform.
It is much more comfortable to use PB

As you have written: you code in PB and get an executable
Unfortunately I still have many codes which does not work with the C backend.
But it is the future.
Re: What is the difference between ASM backend vs C backend ?
For me, when I say testing, I mean in-house testing. For releases, this would also include alpha and beta versions to get any of the C bugs ironed out. For me a release is alpha, demo or final, simply for people other than myself.
Best wishes to the PB community. Thank you for the memories. 
Re: What is the difference between ASM backend vs C backend ?
You shouldn't worry about the final backend, unless you are wanting to write specific ASM or C inline code (which is not that often). The C backend offer faster final code when optimization is on if your program relies on CPU heavy algorithm.
-
- Enthusiast
- Posts: 396
- Joined: Sat Feb 12, 2022 7:15 pm
Re: What is the difference between ASM backend vs C backend ?
Can I create from scratch a app for C Backend as PB normal but without PB in which speed mean to that ? Better Can I mix with PB and C backend codes and to exchange between to variables or function ?
Re: What is the difference between ASM backend vs C backend ?
Inline C is possible.
Example ...
Example ...
Code: Select all
Procedure bswap32(value.l)
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
!return __builtin_bswap32(v_value);
CompilerElse
!mov eax, dword [p.v_value]
!bswap eax
ProcedureReturn
CompilerEndIf
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Enthusiast
- Posts: 396
- Joined: Sat Feb 12, 2022 7:15 pm
Re: What is the difference between ASM backend vs C backend ?
Nice !mk-soft wrote: Fri Nov 10, 2023 1:28 pm Inline C is possible.
Example ...Code: Select all
Procedure bswap32(value.l) CompilerIf #PB_Compiler_Backend = #PB_Backend_C !return __builtin_bswap32(v_value); CompilerElse !mov eax, dword [p.v_value] !bswap eax ProcedureReturn CompilerEndIf EndProcedure
Ok I try this code for testing to Lua in Purebasic but there is missing some header :
Code: Select all
CompilerIf Not Defined(PB_Compiler_Backend,#PB_Constant)
CompilerError "Please use PureBasic Version 6.02 LTS"
CompilerElseIf #PB_Compiler_Backend<>#PB_Backend_C
CompilerError "Please use Compiler-Option C Backend."
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
ImportC "lua5.4.6.lib" : EndImport
!#include "C:\Lua\lua-5.4.6\lua.h";
CompilerEndIf
Global lua
!g_lua = luaL_newstate();
!luaL_openlibs(g_lua);
*code = UTF8("print('Hello, World from Lua')")
!if (luaL_loadstring(g_lua, p_code) == LUA_OK (0)) {
! if (lua_pcall(g_lua, 0, 0, 0) == LUA_OK) {
! lua_pop(g_lua, lua_gettop(g_lua));
! }
! }
FreeMemory(*code)
!lua_close(g_lua);
-
- Enthusiast
- Posts: 581
- Joined: Wed Sep 25, 2019 10:18 am
Re: What is the difference between ASM backend vs C backend ?
Code: Select all
124 | if (luaL_loadstring(g_lua, p_code) == LUA_OK (0)) {
| ^^^
Code: Select all
$ /tmp/lua.out
Hello, World from Lua