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.
>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.
P.S. one other thing to think about would be alignment within TYPE structures. For example:
a AS STRING * 1
b AS LONG
Would there be 3 bytes of padding between a and b? Would there be an option to specify?
|Response Title||Author and Date|
|Re: new QBASIC-compatible compiler||on Mar 3|