OxygenBasic PreRelease

Started by Charles Pegge, April 16, 2026, 06:52:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

#15
I am thinking to make the MACRO Statement a compiler directive and use
#MACRO and
#END MACRO

You remind me of that with the #RETURN.
In fact these are compiler directives.
Maybe even the MACROTEMP Should be #MACROTEMP

Currently the mix from "Normal commands" that compile to Mnemonics and Compiler Directives is (in PB) still a bit mixed.
Maybe you can also think about it. "Compiler Directives start with a #".
This may also speed up Parsing.

The #RETURN i hade reserved for the #OVERRIDE Command, yet due to the Code degeneration i don't know if its still implemented.

You can do
#OVERRIDE LEN(Datatype) AS LONG
LOCAL A AS LONG

[Your own ASM-CODE]
#RETURN  A
#END OVERRIDE

And this way overwrite the builtins (here LEN) from the compiler (for this datatype) with own code.

PS: Read the Post from Stan, using Opencode and the free Resources (DeepSeek) you can speed up things a lot.

Charles Pegge

Hi Theo,

#macro and #endmacro are used by FreeBasic. They are a multiline substitute for C #define.

With regard to '#' being used only for compiler directive commands, I had to be a bit more flexible in OxygenBasic. Unlike 'C' there is no preprocessor stage that precedes main compilation. The metalanguage is woven into the Bsic language itself. This enables the metalanguage to evaluate declared variables, and anything else that is resolved at compile time.

The consequence of this strategy is that a substantial portion of Oxygen commands are implemented as macros. For instance left and right are expressed in terms of mid:


macro left(s,i) {mid(s,1,i)}

macro right(s,i) {mid(s,-(i))}


A more complex example 'new' includes further metalanguage terms.
As a result of these macros, 'New' can be used to define any primitive, UDT or Object, with or without a constructor.
def new
  %1*%2
  @%2=getmemory sizeof %1
  _new_ %1 %2 (%3)
end def

def _new 'local / static
  %1 %2
  _new_ %1 %2 (%3)
end def

def _new_
  #if def %2.___
    #if def %1_table
      ? %2 = @%1_table
    #else
      #error "%1 needs %1_table"
    #endif
  #endif
  #if def %2.constructor
    %2.constructor(%3)
  #endif
end def

Theo Gottwald

This is another point.
Generally i prefer a clear Text-Substitution Pre-Processor than handles #MACRO, #INCLUDE, #IF, #SELECT etc. and is also Looping so if you #INCLUDE a #MACRO that will #INCLUDE something again it should also be resolved.

From what i have seen that conflicts with some C-Internals so the C-Frontends have partly woven-in Preprocessrs like you do. I did not really understand why.

If i have a clear Textual Pre-Processing stage, its easie to handle, and i can process it until there are "no #'s left". Thats my current Idea how it should work.

Frank Brübach


your last oxygen update from 15-july-2026

error in rtl64.inc and rtl32.inc


word: num.lps
proc float_to_ascii
col: 10
line 817
inc/rtl64.inc

' you have forgotten.. something type like that..

'numberformat
  type numformat
    int dp   ' DECIMAL PLACES
    int trz  ' STRIP TRAILING ZEROS
    int sn   ' SCIENTIFIC NOTATION BY DEFAULT
    int sdp  ' INHIBIT ZERO BEFORE DECIMAL POINT
    int sns  ' LEADING SPACE FOR NON NEGATIVE NUMBERS
    int lps  ' LEAD PADDING SPACES
  end type


I have another general question charles :-)

how did you make a self compiling for oxygen.dll from 32 to x86-64 oxygen64.dll bit cause a lot of registers are different between these bit architecture?

oxide.o2bas I cannot compile to 64bit with uses rtl64. for example.
then I have got a lot of errors in different *.inc files

I am working at a new project from time to time with another assembler language and this will take a long time to finish this .. but learning effect is big ;)

regards, frank

Charles Pegge

Hi Frank,

Thanks for reporting the problem. RTL32 and RTL64 were pruned too much!
You can drop the RTL files into the \inc folder, and all should work.

To your other question:

Transforming from 32bit compiling to 64bit compiling is a major task. The calling convention and rules for register usage are quite different. Furthermore Microsoft and Linux use different rules. Totally unnecessary.

For native 64bit functions, OxygenBasic uses an adapted form of CDecl. And most of the generated Asm looks much the same as 32bit. Only imported and exported functions have to comply with the crazy rules.