Re: new QBASIC-compatible compiler

by (Login MCalkins)
Moderator

Yeah, I like contemplating these things even if I can't actually do them.

section directives tell the assembler to put the following output in a particular section (such as .text for code, .data for read/write data, .rdata for read only data, .bss for uninitialized (zeroed, in the case of win32) data, etc.), optionally with alignment specified.

The current Nasm documentation is a good info source on that.

C compilers on x86 add underscore prefixes to variable and function names. So for example, a variable named n is actually _n in the assembly code. Likewise, the function printf is actually _printf. Also, __stdcall, that is, WINAPI, functions might be additionally decorated, so that WriteConsoleA, for example, might be _WriteConsoleA@20, as it takes 20 bytes worth of parameters on the stack. (Unlike __cdecl functions, __stdcall functions clear the stack themselves. So WriteConsoleA will always be passed, and will always clear 20 bytes (on Win32).) (Note, however, that the DLLs export undecorated function names.) C++ compilers have their own name decoration, I believe for function overloading purposes. A C++ compiler can omit that, and just use plain C decoration by using extern(C) or something like that. For example, I think QB64's int QBMAIN(void *) becomes _Z6QBMAINPv.

I meant row major or column major, referring to the order in which multidimensional arrays are laid out. C uses row major, and QBASIC uses column major.

http://en.wikipedia.org/wiki/Row-major_order

>The target platforms to date are Intel x86, Motorola 68K and a format which can execute directly on the GUI I'm also working on.

On x86, what specifically? 16 bit? 32? 64? DOS, Windows, OS/2, Linux, FreeBSD?

>I do, however, have a working optimizing expression evaluator which can turn something like (8 * 3) + timerCount ^ 2 + ((4 * points) * 100) AND 5 into a handful of assembly lines with all the operations done in the correct order. After the optimizing kicks in, the resulting assembly code can not only solve the equation, but it can do so using only about three registers.

Cool. :-)

Regards,
Michael

P.S. one other thing to think about would be alignment within TYPE structures. For example:

TYPE t
a AS STRING * 1
b AS LONG
END TYPE

Would there be 3 bytes of padding between a and b? Would there be an option to specify?



    
This message has been edited by MCalkins on Mar 2, 2012 7:52 PM

Posted on Mar 2, 2012, 7:49 PM

Respond to this message   

Return to Index


Response TitleAuthor and Date
Re: new QBASIC-compatible compiler on Mar 3