Shop OBEX P1 Docs P2 Docs Learn Events
Self compiling — Parallax Forums

Self compiling

Dr_AculaDr_Acula Posts: 5,484
edited 2013-02-04 09:31 in Propeller 1
Over on the propeller thread Rayman has been posting some very interesting ideas regarding text editors and file systems for flash. This has me thinking - if we can built text editors, how close are we to a self compiling system?

So - to write a program we need a text editor. There are a few 'almost finished' ones out there, written in Spin. And there is always Wordstar in a CP/M emulation.

But looking for a Spin compiler led me to this fascinating site http://code.google.com/p/open-source-spin-compiler/wiki/CurrentState

Ok, this is in vs2008 but the source code C files looks mostly (apart from the .sln file) like something the GCC compiler could handle.
//////////////////////////////////////////////////////////////
//                                                          //
// Propeller Spin/PASM Compiler                             //
// (c)2012 Parallax Inc. DBA Parallax Semiconductor.        //
// Adapted from Chip Gracey's x86 asm code by Roy Eltham    //
// See end of file for terms of use.                        //
//                                                          //
//////////////////////////////////////////////////////////////
//
// DistillObjects.cpp
//
// called Object Distiller in the asm code
//

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Utilities.h"
#include "PropellerCompilerInternal.h"
#include "SymbolEngine.h"
#include "Elementizer.h"
#include "ErrorStrings.h"

bool DistillSetup_Enter(unsigned short value)
{
    if (g_pCompilerData->dis_ptr == distiller_limit)
    {
        g_pCompilerData->error = true;
        g_pCompilerData->error_msg = g_pErrorStrings[error_odo];
        return false;
    }
    g_pCompilerData->dis[g_pCompilerData->dis_ptr++] = value;
    return true;
}


So - take any of the hardware solutions that can handle XMM and hence large C files - could this spin compiler run on GCC?

If so - keep things simple and think of a command line program that takes one text file and outputs another. Keep it really simple and in 8.3 format and so it is MYPROG.SPI and it outputs MYPROG.BIN (or .exe or whatever extension). Looking at the core of this program, I think this is what it does.

Maybe leave off the command line options for the moment? Or maybe leave them as the 'full' option and it outputs all the error listings to ERROR.TXT or to the screen. Then it is something that can run under a command line operating system like Kyedos.

If this project can itself run on the propeller, then one can think about a port of Kyedos from Spin to C. Kyedos does not support command line options -a -b -c etc, mainly because it is fairly short on code space as it is written in Spin. But rewritten in GCC in XMM mode, there is more code space, so one could add features like command line options.

I wonder if there are any bits that still need to be coded to create a self hosting, self compiling propeller computer?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-30 20:58
    Sphinx already is a self-hosting, self-compiling Propeller computer system. The editor works although it's not very good. It compiles and links itself and the shell program and all of the utilities including the editor, but I wouldn't use the editor to do much. I've made minor changes to the code and recompiled everything and it works. The desktop compilers (Propeller Tool and BSTC) do a better job of compiling, but the Sphinx compiler is adequate.
  • Heater.Heater. Posts: 21,230
    edited 2013-01-31 01:30
    Dr_A,

    open-source-spin-compiler is the Spin compiler in C created by Roy Etham by reverse enginneering Chips original Spin compiler that was written an x86 assembler. It compiles and builds on Linux, Mac etc just fine. It is supplied with SimpleIDE where it is installed as just a command called "spin". It even compiles and runs on ARM boards like the Raspberry Pi.

    Given that it is just an everyday C program I see no reason it could not be compiled by prop-gcc to run on the Prop. How much memory you might need to run it on the Prop I have no idea.
  • RaymanRayman Posts: 14,665
    edited 2013-02-04 09:31
    I should have read this before starting my last thread...
Sign In or Register to comment.