Author Topic: Latest Alpha Release (Available on Web Site)  (Read 26490 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #15 on: July 21, 2011, 08:53:32 AM »

Hi efgee,

I'm hoping that by making self-compile my next priority, modularising the compiler internals in Oxygen will be easier than in FreeBasic. Adding new emitters and other enhancements should then proceed faster.

Charles

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #16 on: July 21, 2011, 09:12:24 AM »
I'm making a few changes directed towards self-compiling.

One is the cpu calling convention which passes parameters in the CPU registers instead of on the stack. This is primarily intended for internal use to get the maximum possible performance with simple procedures.

I have also corrected a potentially serious problem which showed up in one of the OOP examples. Thanks Maxim!

This was the example. I have changed the syntax slightly but the original should also perform correctly now.

examples/OOP/features/AttachObject.o2bas
Code: OxygenBasic
  1.  
  2.   /*
  3.  
  4.   How to attach an object of one class to another by reference.
  5.  
  6.   In this example a switch is attached to an electrical device.
  7.   This attachment will also work for derived classes of both BasicSwitch and Electrical
  8.  
  9.   */
  10.  
  11.   '----------------
  12.  class BasicSwitch
  13.   '================
  14.  
  15.   sys state
  16.  
  17.   method style() as string
  18.     return "plain"
  19.   end method
  20.  
  21.   method on()
  22.     state=1
  23.   end method
  24.  
  25.   method off()
  26.     state=0
  27.   end method
  28.  
  29.   end class
  30.  
  31.  
  32.   '---------------
  33.  class Electrical
  34.   '===============
  35.  
  36.   BasicSwitch * bswitch 'switch by reference
  37.  
  38.   method describe() as string
  39.     string cr,s
  40.     cr=chr(13)+chr(10)
  41.     s="Description:" cr cr
  42.     '
  43.    if @bswitch then
  44.       if bswitch.state then
  45.         s+="Switch is on" cr
  46.       else
  47.         s+="switch is off" cr
  48.       end if
  49.     else
  50.       s+="Switch has not been fitted"  
  51.     end if
  52.     return s
  53.   end method
  54.  
  55.   end class
  56.  
  57.  
  58.   'SETUP
  59.  '=====
  60.  
  61.   Electrical  device
  62.   BasicSwitch bswitch
  63.  
  64.   'we have only dimensioned these objects. Constructors have not been used.
  65.  
  66.   'TESTING:
  67.  '========
  68.  
  69.   print device.describe
  70.   @device.bswitch = @bswitch 'attach bswitch
  71.  print device.describe
  72.   device.bswitch.on
  73.   print device.describe
  74.  
  75.  
  76.  

Charles

I'm posting it here for quick download:
« Last Edit: July 23, 2011, 06:57:02 AM by Charles Pegge »

JRS

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #17 on: July 21, 2011, 12:05:33 PM »
Quote
I'm making a few changes directed towards self-compiling.

Are you saying that you can move to a self compile model in steps rather that going cold turkey with FreeBASIC?


Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #18 on: July 21, 2011, 02:43:13 PM »
Most of the code will self-compile, but I want to get it as close to 100% as possible and it is easier to make these adjustments and test them on a working system.

Charles

JRS

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #19 on: July 21, 2011, 06:06:14 PM »
Once you get to a self compile stage, will the O2 source look more Basic and less ASM?

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #20 on: July 21, 2011, 09:33:55 PM »

That's an interesting question John. Some kind of Assembler will always be needed in critical areas, even if it is an abstract assembler like Java ByteCode or Common Intermediate Language.

If Oxygen produced 100% efficient Assembler from Basic there would be no need but we are not at that stage yet :), and I feel some coding is actually clearer when expressed directly in Assembler rather than Basic notation, especially logic.

Charles

Maxim

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #21 on: July 21, 2011, 10:26:04 PM »
Thanks Charles, works fine.

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #22 on: July 23, 2011, 07:11:53 AM »
As I proceed with the self-compile project , I will post updates here whenever I need to change anything.

There was one problem using the RTL32.inc (Run time library for independent execution), making low level calls using a macro. This has now been fixed.

Charles
« Last Edit: July 23, 2011, 01:13:53 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #23 on: July 23, 2011, 01:19:29 PM »
Missing right brackets with procedure calls now trigger a compile error. Thanks Peter!

In Assembler mode (asm .. end asm) hex literal &h123 is now supported as well as  the 0x123 and 123h formats.

Charles
« Last Edit: July 24, 2011, 05:02:48 AM by Charles Pegge »

JRS

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #24 on: July 23, 2011, 07:21:22 PM »
I'm trying to get my arms around this self compile process. Are you saying that no other compiler tools (assembler/linker) will be needed to generate an executable? If that is the case, I should be able to use ScriptBasic to compile a O2 program.


Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #25 on: July 23, 2011, 07:52:54 PM »

Hi John,

Oxygen can self compile because it has its own built-in assembler and linker. It requires no other utilities to create an executable image or binary file.

ScriptBasic could also be used to compile O2 or indeed ScriptBasic programs and produce binaries in the same way. But it would be quite slow because it is an interpreter.

Charles

JRS

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #26 on: July 23, 2011, 08:37:49 PM »
Quote
But it would be quite slow because it is an interpreter.

Define slow?

I can live with SB taking a second to compile a program when a compiled version may do it in a 1/10 of the time. What I would gain using an interpretive environment for debugging and readability would far surpass any inconvenience from having to a blink once before having something to run. If there happened to be some function of the compiler that is CPU intensive, I could create a SB extension module (shared object) written in O2 or C.

Quote
Basic and Macros are converted to Assembly code.
Prologs, epilogs, PE headers and  sections are added.
Assembly code is converted to Oxygen machine script.
Oxygen machine script is converted to binary and linked.
The executable binary image is then (optionally  compacted into a PE file,
or executed directly in memory

o2Sema-->o2fini-->o2Assm-->o2Link-->(makeEXE/DLL)

If I were to use O2 as a framework for a SB compiler, I would compile the pcode SB generates to execute. No need to LEX, error check and is in the most efficient form to compile.

« Last Edit: July 23, 2011, 11:36:48 PM by JRS »

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #27 on: July 24, 2011, 04:57:38 AM »

Yes John, I agree 10x slower is tolerable, at least on programs up to 20000 lines.

The development time-scales are probably the biggest obstacle. It has taken about 10000 man-hours to develop Oxygen so far and I have a notional budget of 1000 hours for the self-compile stage alone. So be warned that anything to do with compiler making will take a large portion of lifespan :)

I am always looking for short cuts but so far, they elude me!

Charles

Charles Pegge

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #28 on: July 24, 2011, 05:05:14 AM »
This release provides a line number when an Assembler error message is given.

Charles
« Last Edit: July 25, 2011, 08:12:49 AM by Charles Pegge »

JRS

  • Guest
Re: Latest Alpha Release (Available on Web Site)
« Reply #29 on: July 24, 2011, 08:14:31 AM »
I guess all I'm saying is that using SB may make multi-platform development easier.