John's Mutant / News: Recent posts

Version 1.75 of MinimalBASIC compiler released

Version 1.75 of MinimalBASIC compiler released

Bug Fixes:

  • Fix error in calculating operand_stack_size when using 64bit floating point stack.
  • Fix three bad lines in P012.BAS reported by Jorge Giner Cordero, and fix other typos I noticed while merging his fixes.
  • Fix typo in P014.BAS reported by Jorge Giner Cordero.
  • Fix typo in P043.BAS reported by Jorge Giner Cordero.... read more
Posted by Gatewood Ham 2014-10-09

Version 1.7 of MinimalBASIC compiler released

Version 1.7 of MinimalBASIC compiler released

Initial SSE4 support is now working!

Bug Fixes:

  • Fix another TAB() corner case. Last fix added this:
    but it needs to be this since columns are 1-based:


  • Added P215, P216 and P217tests for floating point conversion based on some
    tests by Rick Regan (Exploring Binary) that caused PHP (CVE-2010-4645)
    and Java (CVE-2010-4476) trouble once upon a time.
  • Unifiy SIGNIFICANCE_WIDTH and EXRAD_WIDTH definitions for all files so
    if it is changed in globals.c, both the compile-time code and runtime
    code will use the same rules.
  • Added P218 test for the TAB() fix.
  • Add -4 switch for SSE4.1 support. Modify binary math operator macros to
    use PINSR[QD] and PEXTR[QD] when SSE4.1 support is requested.
  • Update ABS(), INPUT and READ code generation to use SSE4 for -4 switch.
  • Update UDF parameter processing to use a macro like other arithmetic
    expression code.
  • Add -A switch for AVX support. For now, nothing is actually using this.
Posted by Gatewood Ham 2014-09-21

Version 1.6 of MinimalBASIC compiler released

Version 1.6 of MinimalBASIC compiler released

Bug Fixes:

  • Fix a TAB() corner case. Given the following source:
    PRINT ,,,,TAB(1);"HI"
    You should get a newline, then HI starting in the first column on the line
    after that. The problem was nextzone procedure was not updating the
    obuf_next position correctly.
  • Fix bug where .LSTART_BSS was not force-aligned correctly which caused the
    uninitialized variable read checking to fail for scalar numeric variables.... read more
Posted by Gatewood Ham 2014-09-12

Version 1.5 of MinimalBASIC compiler released

Version 1.5 of MinimalBASIC compiler released

Bug Fixes:

  • A program that is otherwise syntactically valid but contains a READ statement and does not contain any DATA statements was not being rejected as invalid by the compiler.


  • Comments added for fields in emitted DATA statement blocks.
Posted by Gatewood Ham 2014-08-30

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 2014-08-26

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