![]() |
|
How to run own code - Printable Version +- PowerBASIC Users Meeting Point (http://pump.richheimer.de) +-- Forum: Special Interest Groups (http://pump.richheimer.de/forumdisplay.php?fid=23) +--- Forum: JKB (32/64 bit Compiler) (http://pump.richheimer.de/forumdisplay.php?fid=24) +--- Thread: How to run own code (/showthread.php?tid=121) |
How to run own code - Juergen Kuehlwein - 12.04.2026 My IDE makes extensive use of hot keys, type CTRL + H for a list of key combinations In the IDE´s folder there is a file (list of available features.txt) listing all currently supported statements. Most statements are compatible to PB syntax I´m not absolutely sure, if my implementation of macros works correct under all circumstances, the same applies to math functions and all kinds of expressions, especially with new data types like QWORD and SBYTE. I am sure there will be bugs, issues and problems i didn´t find yet! Compiling the same code for 32 and 64 bit requires a special data type, which represents 32 bit in 32 bit and 64 bit in 64 bit: XWORD (unsigned) and XLONG (signed). Therefore all include files (i used José´s) must be prepared for this. Currently not all but about 2/3 have been translated and can be found in \Basic\Include_new. 64 bit code is much more picky about alignment, 64 bit code refuses to work, if structure alignment is not correct. This produces hard to find errors, and i´m not sure if all structures have been translated properly for 64 bit. Inline assembler works as usual, i build ebp/rbp based stackframes and you can use PUSH and POP as usual, but in 64 bit code the stack pointer (rsp) must be 16 byte aligned before calls, otherwise you will experience all kinds of crashes. You may replace e/r by x for registers in order to write code, which compiles in 32 and 64 bit. Internally xax becomes eax in 32 bit and rax in 64 bit, this applies to all standard 32 bit registers (eax, ebx, ecx, edx, esi, edi, ebp, esp), obviously you cannot use r8 - r15 in 32 bit code. In 32 bit code the constant %x32_code and in 64 bit code %x64_code are predefined, so you can build conditional compiling blocks like: #ifdef %x64_code ... 64 bit code goes here (must be compilable) #else ... 32 bit code goes here (must be compilable) #endif While PowerBASIC allows for (variable)names like "cx" or "si", which are valid register names, my implementation currently doesn´t. So you must use different names. ATM there are some more words (in addition to language keywords), which are forbidden. You will get an error message in such cases. My object and COM implementation may need improvement, the focus was on being able to use COM services, which seems to work.Writing COM servers is possible but with some restrictions. Inheritance and multiple interfaces are not handled absolutely correct, i fear. There is nothing like #TLIB and "ME." (an object calling itself) doesn´t work yet. I want better error reporting, in many places you will get a simple "syntax error". It is possible to have more specific messages and i plan to do that, but it is not on top of my priority list. There are many ways of improving and optimizing my code, but for the moment the most important thing is making the "core" things stable. Then will be the time to add more features, currently it supports, what i would call the "core" features of a BASIC language. Feel free to ask for "core" features i might have missed. But i won´t add more or less "special" things, before the core can be considered actually stable. At the current point of development i must thoroughly test, what i have in order to avoid changes in the core functionality later on. Code generation must cover different scenarios, the currently supported feature set covers all these scenarios in (hopefully) all it´s aspects. So it should be suited for testing and finding bugs i missed. Further development will then be a variation or implementation of the existing core of code. E.g when passing arguments, such an argument can be: a literal, a constant, a variable, an array (as a whole, or as one single element), a structure (as a whole, or as one member of it), nested structures, a pointer, a resolved pointer, procedure returns, intrinsic functions (results from key words) and combinations and expressions of all of this. An argument can be passed "byref", "byval" and "bycopy". So there is a variety of possibilities, which must be taken care of. The most simple code for own tests would be: Code Select Code: #COMPILER JKB 32 #COMPILE EXE FUNCTION MAIN ... END FUNCTION Now you can fill in the body of MAIN (for convenience PBMAIN is also possible) with declarations of variables and code using the syntax known form PB. You can add subs and functions as usual. You may add "#INCLUDE "Win32Api.inc" for access to predefined constants and the Windows API. About 2/3 of José´s include files are already adapted to work in 64 bit Windows. There might still be issues though "F9" will start the code generation and if this was successful, start the compiled executable. AV will often not be you friend here! You may add resources by "#RESOURCE "<resourcefilename>.res", but even adding a version control block and a manifest does not ensure smooth testing. When there are syntax errors inside the BASIC code, these errors are shown in the IDE. In case of no error so far, the generated assembler code is passed to an assembler and linker, errors are shown in the IDE. Finally the created executable is run. For debuging you can inspect final or intermediate results with "MSGBOX", use "STR$" or "HEX$" for numeric results, or you can make use of "ODS" or "ODX", which show debug output in a special viewer, which doesn´t block code flow like a message box. Basically everything listed in features is allowed as syntax element. Expressions and block constructs have a maximum nesting level of 64. The generated assembler code still has potential for optimizing, but (as already mentioned) first i want to get it working and then i want to make it smaller, faster, whatever... The IDE will create a bunch of extra files mostly for debugging purposes, these will not be visible anymore in a final state. Please don´t post in this thread, use the "Discussions" thread. More explanations will follow as needed. |