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

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Re: PlugIn system for Oxygen basic
« Reply #15 on: March 23, 2013, 06:50:40 AM »
First of all ,
i ask Charles not you ,and why you respond anyway ???
Second ..
i am here because oxygenBasic - not script basic.
And what is your contribution- nothing ...Only you have the benefit of someone else's code

John

  • Hero Member
  • *****
  • Posts: 2803
Re: PlugIn system for Oxygen basic
« Reply #16 on: March 23, 2013, 07:05:14 AM »
This is a forum you idiot. If you want to address an individual, send them a PM. Is your life so bad that you believe everyone has to suffer along with you? You have trashed everyone you communicate with at some point or another. Were you a spoiled brat when you were a kid as well?

Emil_halim

  • Full Member
  • ***
  • Posts: 235
Re: PlugIn system for Oxygen basic
« Reply #17 on: March 23, 2013, 08:30:45 AM »
hay guys

 please , can you stop this now , here we are for certain case , teach help each us , and ofcourse  respect others.

   
 

Emil_halim

  • Full Member
  • ***
  • Posts: 235
Re: PlugIn system for Oxygen basic
« Reply #18 on: March 23, 2013, 08:42:06 AM »

Charles , nice intermediate language you are making , i think this will be more better
Quote
change that

convert  float,int

to  this

convert  float to int

Quote
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.

exactly true , that is what High Level asm service for

Aurel , consider the following example , it is abs function for integer fast and readable
Quote
def  AbsI
   %1
   #HLAsm {
           eax=%1
           cdq
           xor eax,edx
           eax-=edx
  }   
end def


Jone ,
  what is BF language , i never heard about it ?


Emil_halim

  • Full Member
  • ***
  • Posts: 235
Re: PlugIn system for Oxygen basic
« Reply #19 on: March 23, 2013, 09:22:08 AM »
Hi Charles ,

one feature that was in SphinxC-- i want to see it in OxyGen. consider the following Exm.
Code: [Select]
int fastcall strlen2(EAX)
{    
    EBX=EAX;
    while(DSBYTE[EAX] !=0 )
     {
        EAX++;
     }
    EAX -= EBX;  
}  

the fastcall in sphixc-- means that the parameters is a registers so when compiler found a call to that function , it load the registers with the value then call the function it self.

So what is your opinion ?  
  

Charles Pegge

  • Author
  • *****
  • Posts: 3282
    • Oxygen Basic
Re: PlugIn system for Oxygen basic
« Reply #20 on: March 23, 2013, 01:38:55 PM »
Hi Emil,

OIL (OxygenBasic Intermediate Code) is in an imaginary state at present, so there is plenty of scope for thinking about syntax.  As a compiling layer, though it is very real, specifying all operations, type conversions, call types, function headers, footers etc. There are about 40 instructions so far. But I am not sure how a programmer would benefit from using this layer. Could be an entry- point for other languages.

Oxygen has a fair amount of Macro-muscle and also a simple block structure to promote high-level assembly:
Macros are often better than attempting fast-calls. You don't have the overhead of function prologs and epilogs.

Here is a byte copy example:
with the improved addr instruction it should work with a wide range of types:

macro bytecopy(dest,src,c)
scope
let n=c 'allow functions
addr ecx,src
push ecx
addr ecx,dest
mov edi,ecx
pop esi
mov ecx,n
(
 dec ecx
 jl exit
 mov al,[esi]
 mov [edi],al
 inc esi
 inc edi
 repeat
)
end scope
end macro

'test

string a=space 12
string b="abcde"
bytecopy(a,b,len b)
print a



Charles




Charles Pegge

  • Author
  • *****
  • Posts: 3282
    • Oxygen Basic
Re: PlugIn system for Oxygen basic
« Reply #21 on: March 26, 2013, 02:28:56 AM »
Another kind of macro which can be used to stretch syntax is def .. end def

This is a bit like a DOS macro, using %1..%9 for parameter substitution, and %% as escape.

Here is a real example where I need to generate 16 Entry points. (These are proxy callbacks for ScriptBasic)

Each function adds an extra indexing parameter to the call, then passes it onto to function CallBackRelay.



  sys ToCallBackRelay=@CallBackRelay
  jmp fwd ncallbacks

  def CallBackChannel
  ===================
  o2 !10   'alignment to 16 byte boundaries
  f%1:
  pop eax  'pop return address from stack
  push %1  'extra param
  push eax 'put return address back onto stack
  jmp ToCallBackRelay
  end def

  '
  CallBackChannel 1
  CallBackChannel 2
  CallBackChannel 3
  CallBackChannel 4
  CallBackChannel 5
  CallBackChannel 6
  CallBackChannel 7
  CallBackChannel 8
  CallBackChannel 9
  CallBackChannel 10
  CallBackChannel 11
  CallBackChannel 12
  CallBackChannel 13
  CallBackChannel 14
  CallBackChannel 15
  CallBackChannel 16

  'itr assuming all cdecl

  ncallbacks:
  ===========
  
  sys CallBackTable[16]={@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8,
                  @f9,@f10,@f11,@f12,@f13,@f14,@f15,@f16
}
« Last Edit: March 26, 2013, 02:38:41 AM by Charles Pegge »

Peter

  • Full Member
  • ***
  • Posts: 146
Re: PlugIn system for Oxygen basic
« Reply #22 on: March 26, 2013, 03:34:08 AM »
It get worse than Java/Python/C/C++.  :'(
Where is the simplicity ?

Charles Pegge

  • Author
  • *****
  • Posts: 3282
    • Oxygen Basic
Re: PlugIn system for Oxygen basic
« Reply #23 on: March 26, 2013, 06:06:02 AM »
Giving script languages the ability to handle callbacks is one of the more complex tasks I've encountered. I  show about 1/3 of the code here. I thik the use of a macro here is justified to reduce repetitive code and potential for errors.


John

  • Hero Member
  • *****
  • Posts: 2803
Re: PlugIn system for Oxygen basic
« Reply #24 on: March 26, 2013, 06:26:39 AM »
Quote
Giving script languages the ability to handle callbacks is one of the more complex tasks I've encountered.

I have asked Peter Verhas if he could assist with finding the current executing SB object pointer. That is all I need to be able to use the existing SB API to call a SB script function and never leave the IUP main loop. (SB & IUP switch roles until the window closes)

As soon as Peter gets settled in his new place, (Zürich Switzerland) he said he would have a look and get me pointed in the right direction. You would think this would have come up long before now.


Charles Pegge

  • Author
  • *****
  • Posts: 3282
    • Oxygen Basic
Re: PlugIn system for Oxygen basic
« Reply #25 on: March 26, 2013, 06:53:38 AM »
That's good John, if the current pProgram could be added to the Execute-Object structure, that would help a lot, otherwise you need an extra script to pass control to the module to create a pProgram.

I assume you are catching specific callbacks in your IUP module. What I'm doing here is more of a generic solution, which require a few dirty tricks :)

John

  • Hero Member
  • *****
  • Posts: 2803
Re: PlugIn system for Oxygen basic
« Reply #26 on: March 26, 2013, 07:32:22 AM »
Quote
I assume you are catching specific callbacks in your IUP module.

I'm using the external IUP loop method of the API. (IupLoopStepWait) and do  an ICALL to the user defined SUB for the event from scriba. Peter recommended I continue this path and has been reluctant with my desire to do everything in the extension module. This method also requires me to use IUP's old method of defining callbacks as the new IupSetCallback() doesn't set a critical event class variable I need for the external event handler. My current method seems to work fine but I haven't crossed over to the graphics (CD) API yet and that is where callbacks get intense.

Peter

  • Full Member
  • ***
  • Posts: 146
Re: PlugIn system for Oxygen basic
« Reply #27 on: March 26, 2013, 08:09:20 AM »
I
Quote
think the use of a macro here is justified to reduce repetitive code and potential for errors.
One man, one opinion.
Thanks Charles.

Emil_halim

  • Full Member
  • ***
  • Posts: 235
Re: PlugIn system for Oxygen basic
« Reply #28 on: March 26, 2013, 08:32:00 AM »
Hi Charles,

yes , i think that def .. end def is a very powerful macro system .

I am willing to use it to convert some asm code from Masm forum.

any way , i am planning to make a new system for preporcesse the code  before Oxygen compiling it.

consider the following

you have a folder inside Oxygen folder and it's name is Layer , that folder will contain a dll files (layers).
so the main tool will search this folder and load all valid dlls and then call a process function that exists
in each dll (layer) one after one, each one will process the source code as it want then next one and so on...  finally the main tool will call gxo2 to make the final exe file.

this system allow every one to put his layer that will process the source code as he want.

for example , i will put a define layer which will process all #define  keyword just like c++ does before code go to gxo2.

any comments & suggestions are welcome.      
« Last Edit: March 26, 2013, 09:02:38 AM by Emil_halim »

Emil_halim

  • Full Member
  • ***
  • Posts: 235
Re: PlugIn system for Oxygen basic
« Reply #29 on: March 26, 2013, 01:03:15 PM »
Hi ,

here is my first try ,  it compiled oaky but there is no exe file very strange isn't it!!!!!!!!!!!!!!?????????
Code: [Select]

  $filename "Test.exe"
  #include "..\..\inc\RTL32.inc"
  #include "../../inc/MinWin.inc"
  
' find layer folder
'==================

bool FindLayerFolder ()
{
    WIN32_FIND_DATA f
    sys h = FindFirstFile("Layer", @f)
    if h and f.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY then return true
    return false  
}

' get files in layer folder
'==========================

int    LayerNo = 0
string LayName[20]

sub GetLayers()
    WIN32_FIND_DATA f
    sys h , e
    h = FindFirstFile("Layer/*.dll", @f)
    if h then
      do
         LayerNo++  
         LayName[LayerNo] = f.cFileName
         e=FindNextFile( h, @f )
         if e = 0 then exit do
      end do
      FindClose( h )    
    end if
end sub

' load all layers
'================
dword LayerHandle[20]
dword procStart[20]
dword procProcess[20]
dword procEnd[20]

sub LoadLayers()
    sys i
    for i = 1 to  LayerNo
       LayerHandle[i] = LoadLibrary( LayName[i] )
       procStart[i]   = GetProcAddress(LayerHandle[i],"StartLayer")
       call  procStart[i]
       procProcess[i] = GetProcAddress(LayerHandle[i],"ProcessLayer")
       procEnd[i]     = GetProcAddress(LayerHandle[i],"EndLayer")
    next
End sub

sys i
print FindLayerFolder

if FindLayerFolder() then
   GetLayers()
   for i = 1 to  LayerNo
       print  LayName[i]
   next
end if        
  
 

any help please.
« Last Edit: March 26, 2013, 01:10:44 PM by Emil_halim »