Author Topic: PlugIn system for Oxygen basic  (Read 12752 times)

0 Members and 1 Guest are viewing this topic.

Emil_halim

  • Guest
PlugIn system for Oxygen basic
« on: March 22, 2013, 12:28:04 AM »
Hi Charles ,

I just want to know somethings , you include the source code of Oxygen , is this for developers so they make a changes or what.

BTW BCX has a plugin system called a preprocessor  and activated bu $PP switch , it is actually a dll that will
be loaded when switch is on and in main Parser bcx read the line / word then passes it to a PreProcess Function in the dll , the function will modify the line / word  and return it back to BCX to handle it as usual.   

the advantage is that developer can extend Oxygen without touching Oxygen at all.

so what do you think?

 Emil .   

Charles Pegge

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #1 on: March 22, 2013, 02:41:47 AM »
Hi Emil,

I provide the OxygenBasic source code as a resource :)

You can create your own compiler with language extension, or a completely new language using the oxygen DLL, by translating source code into an Oxygen format. So no need to break into O2 source, which is likely to go through many more transformations over the next few years.

Oxygen has a lot of parsing tools, locked inside. I plan to expose some of these for compiler pre-parsing of source code.

Charles

Emil_halim

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #2 on: March 22, 2013, 09:53:08 AM »

okay ,

Here is my first attempt to make HighLevelAsm with Oxygen.

it is actually a PerProcessor tool that handle the hieh level asm then it calls gxo2 to compile it.

Here is an Example

Code: [Select]
indexbase 0
$ filename "test3c.exe"
#include "..\..\inc\RTL32.inc"

zstring a[]="ABCDE"
zstring b[]="12345"

Sub H_strcpy(zstring dst,src)
 #HLAsm {
     uses edx ebx
     Eax = dst
     Edx = src
     .repeat
          CL = char[Edx]
          char[Eax] = CL
          Eax++
          Edx++
          CL = char[Edx]     
     .until  CL != 0
  }
End Sub

H_strcpy(&a,&b)
print a

as you can see the switch for preprocesse is  #HLAsm inclused between {  } .

any comment are welcome , will post the too later.

Aurel

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #3 on: March 22, 2013, 01:54:36 PM »
Emil..
May i ask you stupid question about this HLA .
/because i love ask stupid questions.. ;D/
what is the main point - speed or optimization or both ?
And if - in which type of programs ?

JRS

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #4 on: March 22, 2013, 02:53:01 PM »
Quote
what is the main point - speed or optimization or both ?
  Neither.

As the name suggests, High Level ASM unless you enjoy Low Level ASM and BrainFuck is your high level language of choice.


Charles Pegge

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #5 on: March 22, 2013, 03:13:12 PM »
O2 now uses an intermediate language to express abstract assembly code instructions, rather like Java byte code. This is then translated into Assembly code instructions. It is not quite the same thing as a high level assembler, but it serves an important role in aiding production of device-independent Asm, and some optimisation as well.

Simple example (with some artistic licence  :) ):

Code: OxygenBasic
  1. /*
  2.   BASIC
  3. */
  4.  
  5. sys a,b
  6. float c
  7.  
  8. a=b+c
  9.  
  10. /*
  11.  
  12.   ABSTRACT INSTRUCTIONS
  13.  
  14.   (user friendly translation)
  15.  
  16.   static   int       a
  17.   static   int       b
  18.   static   float     c
  19.   load     int       b
  20.   convert  float,int
  21.   add      float     c
  22.   convert  int,float
  23.   store    int       a
  24.  
  25. */
  26.  
  27.  
  28. /*
  29.  
  30.   X86 ASSEMBLY CODE
  31.  
  32.   mov eax,[ebx+0x1004]
  33.   'CONVERT CPU TO FPU
  34.  push eax
  35.   fild dword [esp]
  36.   add esp,4
  37.   fadd dword [ebx+0x1008]
  38.   'CONVERT FPU TO CPU
  39.  sub esp,4
  40.   fistp dword [esp]
  41.   pop eax
  42.   mov [ebx+0x1000],eax
  43.  
  44. */
  45.  

Charles
« Last Edit: March 22, 2013, 03:18:42 PM by Charles Pegge »

JRS

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #6 on: March 22, 2013, 03:23:04 PM »
Code: OxygenBasic
  1.   (user friendly translation)
  2.  
  3.   static   int       a
  4.   static   int       b
  5.   static   float     c
  6.   load     int       b
  7.   convert  float,int
  8.   add      float     c
  9.   convert  int,float
  10.   store    int       a
  11.  

That is very cool Charles. What are you going to name this intermediate ASM helper language?

A+B might be a good name.  ;D

Charles Pegge

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #7 on: March 22, 2013, 03:31:11 PM »
OIL OxygenBasic Intermediate language  ;D

It only exists in machine-friendly form at present, but it could be made accessible.

JRS

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #8 on: March 22, 2013, 03:51:23 PM »
Quote
OIL OxygenBasic Intermediate language

You have my vote, it's a winner!

Aurel

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #9 on: March 22, 2013, 10:37:03 PM »
Quote
and BrainFuck is your high level language of choice.

and maybe you can stop eat the shit,and use your freakin SB( shit basic)... ;D

JRS

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #10 on: March 22, 2013, 11:38:33 PM »
Hey Charles, how about putting Aurel on ice for awhile until he promises to get along with others.

I don't think Charles would have put the extraordinary effort into ScriptBasic if he thought the language had no marit.

Aurel's childish comments are hurting the project and chasing away talent that is hard to find. His contributions have been buggy and blames everyone else for his failures. I feel sorry for the fool as he is missing an opportunity to learn from others much farther down the road.



« Last Edit: March 23, 2013, 12:11:38 AM by JRS »

Charles Pegge

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #11 on: March 23, 2013, 12:12:44 AM »

Gentlemen please! Be kind to each other.

To answer Aurel's original question, I would say that A high level assembler is somewhere between a normal programming language and traditional Assembler. You can get slightly better performance, and still have something that is easier to read block structure than the list format of Assembly code.

BF is a difficult language, unfriendly to both man and machine. The name itself is a warning to all who use it!

JRS

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #12 on: March 23, 2013, 12:29:25 AM »
Quote
BF is a difficult language, unfriendly to both man and machine. The name itself is a warning to all who use it!

That may be true but I solved that issue long ago with my BF2SB converter.  8)

Code: [Select]
jrs@laptop:~/sb/sb22/test$ time scriba skitri.sb
                                *    
                               * *    
                              *   *    
                             * * * *    
                            *       *    
                           * *     * *    
                          *   *   *   *    
                         * * * * * * * *    
                        *               *    
                       * *             * *    
                      *   *           *   *    
                     * * * *         * * * *    
                    *       *       *       *    
                   * *     * *     * *     * *    
                  *   *   *   *   *   *   *   *    
                 * * * * * * * * * * * * * * * *    
                *                               *    
               * *                             * *    
              *   *                           *   *    
             * * * *                         * * * *    
            *       *                       *       *    
           * *     * *                     * *     * *    
          *   *   *   *                   *   *   *   *    
         * * * * * * * *                 * * * * * * * *    
        *               *               *               *    
       * *             * *             * *             * *    
      *   *           *   *           *   *           *   *    
     * * * *         * * * *         * * * *         * * * *    
    *       *       *       *       *       *       *       *    
   * *     * *     * *     * *     * *     * *     * *     * *    
  *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *    
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *    

skitri.sb (converted by BF2SB)
Code: [Select]
SPLITA STRING(30000,48) BY "" TO memory
WHILE memory[cellptr] > 0
  memory[cellptr] -= 1
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
WEND
cellptr += 1
memory[cellptr] += 4
WHILE memory[cellptr] > 0
  cellptr -= 1
  memory[cellptr] += 8
  cellptr += 1
  memory[cellptr] -= 1
WEND
cellptr += 1
memory[cellptr] += 8
WHILE memory[cellptr] > 0
  cellptr += 1
  memory[cellptr] += 4
  cellptr -= 1
  memory[cellptr] -= 1
WEND
cellptr += 2
memory[cellptr] += 2
cellptr += 3
memory[cellptr] += 1
cellptr += 3
memory[cellptr] += 1
cellptr -= 10
WHILE memory[cellptr] > 0
  memory[cellptr] -= 1
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    cellptr += 1
    memory[cellptr] += 1
    cellptr -= 1
  WEND
  cellptr += 1
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    cellptr -= 1
    memory[cellptr] += 1
    cellptr += 3
    IF memory[cellptr] = 10 THEN
      PRINTNL
    ELSE
      PRINT CHR(memory[cellptr])
    END IF
    cellptr -= 2
  WEND
  cellptr += 3
  WHILE memory[cellptr] > 0
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr += 1
      memory[cellptr] += 8
      WHILE memory[cellptr] > 0
        cellptr += 1
        memory[cellptr] += 4
        cellptr -= 1
        memory[cellptr] -= 1
      WEND
      cellptr += 1
      IF memory[cellptr] = 10 THEN
        PRINTNL
      ELSE
        PRINT CHR(memory[cellptr])
      END IF
      cellptr -= 2
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 1
        cellptr -= 1
      WEND
      memory[cellptr] += 1
      cellptr += 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 10
        cellptr -= 2
        memory[cellptr] += 1
        cellptr += 1
      WEND
      cellptr += 1
      IF memory[cellptr] = 10 THEN
        PRINTNL
      ELSE
        PRINT CHR(memory[cellptr])
      END IF
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
      WEND
      cellptr += 1
    WEND
  WEND
  memory[cellptr] += 1
  cellptr -= 3
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr += 1
      memory[cellptr] += 1
      cellptr -= 1
    WEND
    memory[cellptr] += 1
    cellptr += 1
    WHILE memory[cellptr] > 0
      memory[cellptr] -= 1
      cellptr -= 1
      memory[cellptr] += 1
      cellptr += 3
      memory[cellptr] -= 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr += 1
        memory[cellptr] += 1
        cellptr -= 1
      WEND
      memory[cellptr] += 2
      cellptr += 1
      WHILE memory[cellptr] > 0
        memory[cellptr] -= 1
        cellptr -= 1
        memory[cellptr] -= 1
        cellptr += 1
      WEND
      cellptr -= 3
    WEND
    cellptr -= 4
  WEND
  memory[cellptr] += 10
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
  memory[cellptr] += 3
  IF memory[cellptr] = 10 THEN
    PRINTNL
  ELSE
    PRINT CHR(memory[cellptr])
  END IF
  WHILE memory[cellptr] > 0
    memory[cellptr] -= 1
  WEND
  cellptr -= 1
WEND
memory[cellptr] += 5


My current laptop compared to the old P4 makes a big difference.

real   0m0.067s
user   0m0.056s
sys   0m0.012s
jrs@laptop:~/sb/sb22/test$
« Last Edit: March 23, 2013, 12:51:28 AM by JRS »

Peter

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #13 on: March 23, 2013, 02:24:53 AM »
Hi, Charles,

Could it be that there is  a bug in your last OxygenBasic Dll !
Code: [Select]
include "sw.inc"
Window 320,240,1

SetText 0, 0, GetWidth() /2, 0
SetText 0,20, GetHeight()/2, 0

SetText 0,40, GetWidth() *2, 0
SetText 0,60, GetHeight()*2, 0

SetText 0, 80, GetWidth() -20, 0
SetText 0,100, GetHeight()-20, 0

SetText 0,120, GetWidth() +20, 0
SetText 0,140, GetHeight()+20, 0

WaitKey
Quit

Sirpinsky:
Code: [Select]
indexbase 0
include "sw.inc"

Window 256,256,1
SetFont 12,24,bold,"courier"
SetCaption "Sirpinsky shake"

int numSteps=10000
float ax = 10, cy = 10
float ay = 256 - 10
float bx = 256 - 10
float by = 256 - 10
float cx = 256  / 2
float px = ax, py = ay
 
While Key(27)=0
Cls RGB 12,230,40
For n=0 To numSteps
DrawPoint px, py, 2, 2, RGB 0,0,255
Select Case Rnd(0,2)
       Case 0
          px = (px + ax) / 2
          py = (py + ay) / 2
       Case 1
          px = (px + bx) / 2
          py = (py + by) / 2
       Case 2
          px = (px + cx) / 2
          py = (py + cy) / 2
End Select          
Next
Sync
Wait 45
Wend
Quit

X
« Last Edit: March 23, 2013, 06:23:09 AM by peter »

Peter

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #14 on: March 23, 2013, 04:10:20 AM »
Quote
Gentlemen please! Be kind to each other.

Please, more respect, we have children here!