John's Mutant / News: Recent posts

Version 1.4 of MinimalBASIC compiler released

Version 1.4 of MinimalBASIC compiler released

This release is all about documentation, but includes a few bug fixes. The C code has much more comprehensive comments now, and even the assembly code in the runtime library gained a few too.

Bug Fixes

  • A user must not specify -o twice; this is now enforced (found with clang static analyzer).
  • The realloc() will already free the old pointer memory if necessary; fix code that was incorrectly re-free()-ing it (found with clang static analyzer).
  • Fix bug in error handling for put_array_data() (found with sparse static analyzer).
  • Fix bug where if the program has no floating point literals but uses the same string literal several times, the string literal constants were not merged, which was the result of a cut and paste typo.
  • Fix run_tests for the case where no ecma55/peephole exist on the path but they do exist locally.
  • Fix TAB() function so it properly sets the print zone.
  • Fix scanner so if spaces occur between an array name and the left parenthesis it still knows the variable is an array and not a scalar.
Posted by Gatewood Ham 1 day ago

Version 1.3 of MinimalBASIC compiler released

Version 1.3 of MinimalBASIC compiler released

Bug Fixes

  • Fix many, many typos in NBS test string literals.
  • Fix NBS test 41 and its expected output.
  • Add error path missing free() statements.

Code Generation Improvements

  • Implement constant merging.
  • Implement DATA item merging.
  • Remove dead code (mymemset).
  • Move numeric and string variables to .bss segment.
Posted by Gatewood Ham 2014-07-17

Version 1.2 of MinimalBASIC compiler released

Version 1.2 of MinimalBASIC compiler released

Bug Fixes

  • Fix wrong code generation for error reporting when a function parameter is uninitialized.
  • Update optimizer so that it can ignore leading whitespace and trailing comments.

Code Generation Improvements

  • Convert ON..GOTO to use a proper jump table.
  • Xeon Phi claims it is x86-64 but lacks CMOV and SSE! Added code to explicitely check for CMOV, SSE2, SSE3, and SSSE3 support to the prologue code.
  • When pushing literal values, add those to the comments in the generated assembly to
    make it easier to read the generated assembly and follow the logic of the original BASIC program.
  • Emit an .ident and .end as the last two lines of the assembly output.
  • Explicitely mark all macro parameters are required.
  • Make the for loop macros verify values are OK before using them, fix error message handling.... read more
Posted by Gatewood Ham 2014-07-15

Version 1.1 of MinimalBASIC compiler released

Fix self-test code for symbol_table. Omit generating code for READ, INPUT, SQR
support when not needed. Improve FOR loop code generation, converting it to
use macros. Fix bugs in symbol table where DATA statement numeric constants
were stored as floats instead of doubles when not using -s. Improve array
bounds checking to work with only one test per index. Enforce a maximum array
size of 10000 instead of just failing when a larger dimension is specified.

Posted by Gatewood Ham 2014-06-27

BASICK-1.0 finally released

I am happy to announce that I finally finished the lua version of the BASICK interpreter and have released BASICK-1.0. This project contains a simple integer BASIC interpreter (no strings, floats, files, or graphics) that has a syntax similar to old-style ROM BASIC implementations. What is special is that you get 4 versions of the interpreter. These are written in Python3.3.x, PHP5.5.x, ruby2.x, and lua5.2.x. The lua version was very difficult to debug and unpleasant to work on, but at last it is done.

Posted by Gatewood Ham 2014-05-08

Version 1.0 of MinimalBASIC compiler released

I am happy to announce that version 1.0 of the ECMA-55 MinimalBASIC compiler has been released.

Posted by Gatewood Ham 2014-04-09

peephole optimizer updated

In MinimalBASIC-20140408.tar.xz, the peephole optimizer now removes superfluous sequences of 'pushsaddr' immediately followed by 'popsaddr %rdi'.

Posted by Gatewood Ham 2014-04-08

Release Candidate, take 2

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.

Posted by Gatewood Ham 2014-04-04

Release Candidate

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.

Posted by Gatewood Ham 2014-04-02

coredumps fixed, 32 and 64 bit now are in sync

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.

Posted by Gatewood Ham 2014-03-31

Automated testing implemented, some INPUT issues fixed

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.

Posted by Gatewood Ham 2014-03-30

ON..GOTO expression code fixed

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.

Posted by Gatewood Ham 2014-03-28

Fully 64bit

The arithmetic operations now all default to 64bit doubles.

Posted by Gatewood Ham 2014-03-13

Minimal BASIC enters Beta Testing

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.

Posted by Gatewood Ham 2014-02-27

Minimal BASIC INPUT subsystem completed

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.

Posted by Gatewood Ham 2014-02-26

Minimal BASIC Progress

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

Posted by Gatewood Ham 2014-02-16

Numeric output for MinimalBASIC

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

Posted by Gatewood Ham 2014-02-10

Another round of MinimalBASIC exception fixes

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.

Posted by Gatewood Ham 2014-02-04

Minimal BASIC Exception handling Improvements

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.

Posted by Gatewood Ham 2014-01-26

Minimal BASIC User-defined functions work

I'm happy to report that user-defined functions now work.

Posted by Gatewood Ham 2014-01-23

Minimal BASIC DATA/READ working

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!

Posted by Gatewood Ham 2014-01-22

Minimal BASIC is coming

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!

Posted by Gatewood Ham 2014-01-18

mutant 2.19 released

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).

Posted by Gatewood Ham 2013-11-03

mutant 2.18 released

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[68] 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.

Posted by Gatewood Ham 2013-10-30

mutant-2.18a21 released

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.

Posted by Gatewood Ham 2013-10-24