I am happy to announce that version 1.0 of the ECMA-55 MinimalBASIC compiler has been released.
In MinimalBASIC-20140408.tar.xz, the peephole optimizer now removes superfluous sequences of 'pushsaddr' immediately followed by 'popsaddr %rdi'.
Optional wide 132 column output mode now implemented. In the process, a few more small bugs showed up and are fixed. Wide mode shows 16 significant digits in float display instead of just 7, and uses 3 digit exponents instead of 2. A cosmetic typo in NBS test 27 is fixed. A cosmetic bug in NBS test 203 that only shows up with wide mode is fixed. Assembly code for print subsystem has been updated to use defined constants instead of magic numbers, and have better stack usage.
MinimalBASIC-20140402.tar.xz is a release candidate for the 1.0 release. All known bugs are again fixed, batch INPUT works, the test harness has been improved to show percentages of PASS/FAIL/Unknown and reasons are shown when a test does not PASS. A simple standalone peephole optimizer that works on the generated assembly code has been added to remove the back-to-back 'pushxmm0 '/'popxmm 0' sequences that tend to get generated occasionally by the expression handling, and the compile scripts and test harness are updated to use it. 207 of the 208 NBS tests pass using the test harness. Test #131 is designed to generate different output every run since it tests RANDOMIZE, so it cannot be automatically verified. I have manually verified it works.
Now both the 32 and 64 bit modes have identical tests passing, and the coredumps in the 64bit read of unquoted but valid numeric values into string variables is fixed. Batch INPUT is the only (known) problem remaining.
There is now a check target in the Makefile to run the NBS test suite. Thanks to Emmanuel Roche, I now have the entire NBS Minimal BASIC test suite. One glaring problem that the test suite automation made clear was the batch input using file redirection does not work. Also, two files that work fine with 32bit mode coredump in 64bit mode (test 93 and 95), which shows READ/DATA still needs some work. The latest snapshot does include all of this, as well as fixes for 64bit INPUT of numeric values, a bug in SGN() for 32 bit, a failure to notice EOF on INPUT, and more.
Testing revealed a bug in ON..GOTO expression handling code generation (was still using 32bit method even in 64bit mode). Also, the -s option to ecma55 was not working. These problems have been fixed.
The arithmetic operations now all default to 64bit doubles.
All features for Minimal BASIC have been implemented. All the NBS tests I have are passing. I shook out a few remaining bugs in handling of spaces, READ/DATA, and INPUT and no known bugs exist at this time. The emphasis of the project will now switch to more rigorous testing to verify the feature for which I cannot get the NBS tests sources.
The new INPUT subsystem has been written, and after some hard work all KNOWN bugs are gone, and the NBS tests for INPUT that I have all pass. If you have a copy of NBS MinimalBASIC test #109, I'd love a copy - that's the one INPUT test I don't have.
All known numeric formatting problems are fixed. I have entered all the NBS tests that I could find, and many of them pass now. The last remaining major feature is complete support for INPUT according to the ECMA55 standard, and work will begin on that next. Note that there is a bug in EXP() for negative value that I still haven't managed to fix yet. Otherwise, most genuine Minimal BASIC programs that do not use INPUT should work now.... read more
I have switched to using David M. Gay's dtoa and g_fmt routines and this has helped a lot towards getting NBS tests 9 and 10 to pass. I still haven't fixed output for things like .000022 (I get 2.2E-5) but decided to go ahead and commit what I have since it's a big improvement. The code I used before wasn't "wrong" but I just was not able to make it output in the admittedly peculiar way I need for this project.... read more
I learned that the exception flags in the MXCSR are 'sticky' and must be reset if you want to continue after detecting an exception. The binary_add, binary_subtract, binary_multiply, and binary_divide macros have been updated for this. I also learned that 0/0 does NOT give a divide by zero exception, but instead gives an Invalid Exception so I had to update binary_divide for that.
I have fixed the code generation so that a divide by zero or an arithmetic overflow on binary add, subtract, divide, or multiply will print an execption, then substitute the appropriately signed infinity and continue as required by section 8.6 of ECMA-55.
I'm happy to report that user-defined functions now work.
Well, after several days of difficult debugging, I got READ working. Minimal BASIC requires that any data can be read into a string variable, and that any string that can be converted to anumber can be read into a numeric variable, and it took me a while to get that right. Enjoy!
I have been hard at work on implementing an ECMA-55 Minimal BASIC compiler for Linux on AMD64 systems, and I have put a source file archive up at last. It is not completed yet, but progress has been steady. Flow control is done, and print zones finally work. Notably absent are INPUT and READ statements, but at least you can try out some simple programs. The compiler is written in C and the output is AT&T format assembly code for the GNU as assembly (from binutils). Enjoy!
The highlight of this release is that all known 64bit ABI violations have been fixed. In addition, string literal support in the SHOW statement has been implemented. Also, the code generation does not emit library functions that were never called. Finally, a nasty bug in the 64bit itoa function where stack space for locals was not reserved so the stack was getting corrupted and mysterious crashes would occur but only if you used an integer that was large (which wrote on more of the stack).
I am happy to announce that mutant version 2.18 has been released. This contains an all-new symbol table module that can properly handle nested scopes. It also contains a huge number of fixes to the code generation for both 16bit DOS and 64bit linux. The parser has been updated to ensure that the last line of a function body is a RETURN statement. I have tried to verify the 16bit DOS code uses only 808 instructions. I have tried to ensure the 64bit linux code obeys the AMD64 ABI rules for large code model programs, with the one exception that I still don't have the stack alignment guarantees implemented.
I have released a snapshot of the current working code for mutant. It's still quite rough and buggy, but both the DOS and 64bit code generation is much improved. I have uploaded the mutant-2.18a21.tar.xz snapshot for people who would like to see the new code without having to use mercurial.
Just when you thought you had it all, BASICK is released. This is an unstructured BASIC interpreter for the 1980's style BASIC that I used when I first learned to program. The Python-3.3.x, PHP-5.4.x, and Ruby-1.9.x versions work for the demonstration programs. The lua version is not yet finished. The only statements missing to be 1.0 are FOR/NEXT/STEP and READ/DATA. This BASIC has no support for strings or floats at all, but does support one-dimensional zero-based integer indexed arrays. Have fun!
Now it is tested on non-linux platforms, and a bad bug in the scanner's newline handling is fixed. Also, for non-linux people, a .ZIP file is now available.
Mutant is the replacement for the old Burapha Compiler Kit. Instead of using an interpreted intermediate language, mutant generates NASM 2.X output that uses system calls directly without the need for any other libraries. Mutant -2.13 can emit code for 16bit DOS, x86 Linux, or x86_64 Linux. This GPLv2 software is used to teach my students about compilers.
The phase2 code has been added to cvs; this is
a python compiler for a pico logo-like language.
This includes an interpreter to directly run
the asm-style output and display graphics with
PyGTK. This version was developed during this
semester as an example for the students, and
as it stands is still quite simple and easy enough
to read for people wishing to learn about compilers and interpreters.
Ok, the first cut at the GUI part of the interpreter written in Java is in cvs. Getting the layout managers to do anything intuitive is impossible. If you have a better way [using just java; no Visual Age or Jbuilder] to get the layout to behave, I'm open to suggestions.