Page 1 of 1

PureBasic 6: EnableC like EnableASM

Posted: Fri May 21, 2021 5:59 am
by IceSoft

Code: Select all

Value.l = 10  ; Declare our own variable

EnableC
 #include "myHeaderFile.h"

  Value++;
DisableC

MessageRequester("C Example", "Should be 11: " + Value)
Like the example as ASM:

Code: Select all

Value.l = 10  ; Declare our own variable

EnableASM
  MOV Value, 20 ; Directly use the ASM keywords with PureBasic variable !
  INC Value
DisableASM

MessageRequester("ASM Example", "Should be 21: " + Value)

Re: PureBasic 6: EnableC like EnableASM

Posted: Fri May 21, 2021 6:23 am
by Keya
That would be soooo sweet! :) best of both worlds

Re: PureBasic 6: EnableC like EnableASM

Posted: Sun May 23, 2021 8:20 am
by Saki
I think in itself that it is aimed to realize this so.
It is the logical conclusion.
Unfortunately, I do not know if this is so easy to implement.
The possibilities of this construction are very wide.

Re: PureBasic 6: EnableC like EnableASM

Posted: Fri May 28, 2021 7:37 pm
by Aleks_Longard
IceSoft
I want this instruction too...

Re: PureBasic 6: EnableC like EnableASM

Posted: Sat May 29, 2021 10:24 am
by juergenkulow
Hello IceSoft,
PB_C is a delightful, elaborate task.
But at the moment is on offer:

Code: Select all

F:\PureBasic6Alpha\Compilers>gcc --version
gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
F:\PureBasic6Alpha\Compilers>cc1 -version
GNU C17 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) version 8.1.0 (x86_64-w64-mingw32)
        compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
F:\PureBasic6Alpha\Compilers>As -v
GNU assembler version 2.30 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.30
What is the value of a multilingual Unicode programming language?

Re: PureBasic 6: EnableC like EnableASM

Posted: Sat May 29, 2021 1:24 pm
by Saki
Well, the offer of C codes is almost immeasurably large and there are really very clever little codes.
One can therefore also turn the question around :
What would be the disadvantages if it were supported ?

Actually, it would have only advantages.
Assembler is also supported by PB, which is nothing different in itself.
And C is much easier to understand than assembler.

Re: PureBasic 6: EnableC like EnableASM

Posted: Wed Jun 02, 2021 1:41 am
by juergenkulow

Code: Select all

; EnableC idea with C Preprocesser #include "file.c"
Value.l = 10  ; Declare our own variable
! #include "H:\C2_21\IncValue.c" 
; In IncValue.c is only one line: v_value++; 
; without exclamation mark every line but With v_, p_, f_, or l_ Prefix for PB things and in lower case.   
; #include is with quotation marks and full file path. 
SetClipboardText("C Example"+#CRLF$+"Should be 11:" + Value +" :D")
MessageRequester("C Example", "Should be 11: " + Value)
; But for the asm-world, you must do: 
! asm volatile ( "xor %r9,%r9"); 
; C Example
; Should be 11:11 :D
;00000001400011B1 | 4D:31C9                  | XOr r9,r9                               | r9:EntryPoint
Delete: CompilerIf #PB_Processor_C<>#PB_Compiler_Processor

H:\C2_21\IncValue.c:

Code: Select all

v_value++; // PB variable with v_ Prefix and in lower case.