Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
freeBASIC (a 32-bit QB-syntax compatible compiler) preview..
#31
Women? :*)

Big Grin
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#32
Nah, they don't exist here. But much in the same manner as a nagging women, schoolwork and social responsibilities never end Big Grin.
Reply
#33
Quote:
Code:
    a = b + c
    b = a - d
    c = a
    d = b
If you change b, then c <> a (because c = b + c). Wink
Reply
#34
My fault, i wrote the code wrong.
oship me and i will give you lots of guurrls and beeea
Reply
#35
No problem, I know what the idea behind it is. Wink

I just had to point out that mistake, sorry.
Reply
#36
Quote:And heres my simple question... Will the compiled exes be faster than they are currently?

When the DAG module begins to be used (only after the compiler compiles itself), any common sub-expression will be eliminated inside a basic block, for example, there are loads of reloads when accessing arrays, that is easily "detected" when using Graphs to link the nodes.

But FB is not an optimizing compiler, speed will be enough to beat other BASIC commercial compilers like PB - that is the BASIC compiler that gens the best code (and i checked ALL them, believe me), but PB doesn't seem to do any kind of expression optimization, it does a bunch of hacks that are completely non-portable.. no wonder PB is just for Windows.


Quote:Anyways v1c im impressed with the code output for the math, very nice.

There are some simple optimizations to be added before the 1st release, like converting muls by power of 2 immediates to shifts, load after store and such.. i didn't add that yet as i was getting functions/subs to work in the last days and that took me a lot of time.


Quote:Hey, GNU can do Intel syntax? So I could use intel syntax in mingw?

Hmm, i really don't know, GCC will optimize even the inline asm block (saving or not the registers, etc), dunno if it's not dependent of AT&T syntax.. or you would have to switch back the syntax when closing the inline block, using the .att_syntax directive.


Quote:And DJGPP aint that fast in zooming the mendel!!!

Heh, not that much, GCC is awesome doing optimizations, even DJGPP using an outdated version, i guess.. bad thing about DJ is that it's does not run in flat-mode, segment overriding kills the performance on modern CPUs.


Quote:If you'd ever like to discuss language or compiler issues I'd be glad to chat.

Sure, when the first release gets done it will be fully open-source, any contributions will be welcome.

I started this project coz i was tired of seeing each year new problems appearing when trying to code anything in QB.. bad DOS emulation, hardware less and less backward compatible and so on - i guess the next release of Windows will be even less suitable for DOS coding, but i don't blame M$.. more than a decade is over, ow..

I waited for somebody to make a free and *really* QB-compatible compiler, but as that didn't happen i thought.. hell, lets try it myself, heh.. i didn't think it would be at this stage so early, lets hope it will continue this way until the first public release.


And about the name.. call it just "FB", acronyms can be anything you want ;).
Reply
#37
Pete: FB express. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#38
Check this out, simple gui program with freebasic. It took us a long time to get it to work becuase we both suck at gui coding and v1ctor thought it was the compiler that was messing up. Turns out it wasn't. Sure, looks messy. Windows guis are messy. But look at the same code in C, it's even worse. Anyways, if you really look at it carefully it's not that bad. http://freebasic.bad-logic.com/downloads/winhello.zip

Code:
''
'' winhello.bas - Windows Gui example with freebasic
''
''
defint a-z
option explicit
option private

'$include:'kernel32.bi'
'$include:'user32.bi'
'$include:'gdi32.bi'


const null              = 0
const true              = -1
const false             = 0


declare function        WinMain     ( byval hInstance as long, _
                                      byval hPrevInstance as long, _
                                      szCmdLine as string, _
                                      byval iCmdShow as integer ) as integer

dim res as integer


                                  
                                  
    ''
    '' Entry point    
    ''
    res = WinMain( GetModuleHandle( null ), null, command$, SW_NORMAL )
    end res
    
    
    


'' ::::::::
'' name: WndProc
'' desc: Processes windows messages
''
'' ::::::::
defint a-z
function WndProc ( byval hWnd as long, _
                   byval message as long, _
                   byval wParam as long, _
                   byval lParam as long ) as integer
    dim rct as RECT
    dim pnt as PAINTSTRUCT
    dim hDC as long
    
    WndProc = 0
    
    ''
    '' Process message
    ''
    select case ( message )  
        
        case WM_CREATE            
            exit function
        
        ''
        '' Windows is being repainted
        ''
        case WM_PAINT
          
            hDC = BeginPaint( hWnd, pnt )
            GetClientRect hWnd, rct
            
            DrawText hDC,"Hello Windows from FreeBasic!", -1, _
                     rct, DT_SINGLELINE or DT_CENTER or DT_VCENTER
            
            EndPaint hWnd, pnt
            
            exit function            
        
        ''
        '' Window was closed
        ''
        case WM_DESTROY
            PostQuitMessage 0            
            exit function
    end select
    
    ''
    '' Message doesn't concern us, send it to the default handler
    '' and get result
    ''
    WndProc = DefWindowProc( hWnd, message, wParam, lParam )    
    
end function




'' ::::::::
'' name: WinMain
'' desc: A win2 gui program entry point
''
'' ::::::::
defint a-z
function WinMain ( byval hInstance as long, _
                   byval hPrevInstance as long, _
                   szCmdLine as string, _
                   byval iCmdShow as integer ) as integer    
    
     dim wMsg as MSG
     dim wcls as WNDCLASS    
     dim szAppName as string
     dim hWnd as long

    
     WinMain = 0
    
     ''
     '' Setup window class
     ''
     szAppName = "HelloWin"
    
     wcls.style         = CS_HREDRAW or CS_VREDRAW
     wcls.lpfnWndProc   = procptr( WndProc() )
     wcls.cbClsExtra    = 0
     wcls.cbWndExtra    = 0
     wcls.hInstance     = hInstance
     wcls.hIcon         = LoadIcon( null, IDI_APPLICATION )
     wcls.hCursor       = LoadCursor( null, IDC_ARROW )
     wcls.hbrBackground = GetStockObject( WHITE_BRUSH )
     wcls.lpszMenuName  = null
     wcls.lpszClassName = sadd( szAppName )
    
    
     ''
     '' Register the window class    
     ''    
     if ( RegisterClass( wcls ) = false ) then
        MessageBox null, "This program requires Windows NT!", szAppName, MB_ICONERROR              
        exit function
    end if
    
    

    ''
    '' Create the window and show it
    ''
    hWnd = CreateWindowEx( 0, _
                 szAppName, _
                         "The Hello Program", _
                          WS_OVERLAPPEDWINDOW, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          CW_USEDEFAULT, _
                          null, _
                          null, _
                          hInstance, _
                          null )
                          

    ShowWindow   hWnd, iCmdShow
    UpdateWindow hWnd
    

    ''
    '' Process windows messages
    ''
    while ( GetMessage( wMsg, null, 0, 0 ) <> false )    
        TranslateMessage wMsg
        DispatchMessage  wMsg
    wend
    
    
    ''
    '' Program has ended
    ''
    WinMain = wMsg.wParam

end function
oship me and i will give you lots of guurrls and beeea
Reply
#39
Man we need templates for FB.

So I would assume you can do something like this?

Code:
pixelWidth=surface.ddpfPixelFormat.dwRGBBitCount\8
offset= x*pixelWidth + y*surface.lPitch
Poke(((BYTE *)surface.lpSurface)+offset, &colour, pixelWidth)

Woot!!! DX here I come!!!!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#40
It's nice.
Have a question though, will there be FB version for dos too? That would be awesome
url]http://fbide.sourceforge.net/[/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)