Shop OBEX P1 Docs P2 Docs Learn Events
Something to play with... — Parallax Forums

Something to play with...

hammerhead74000hammerhead74000 Posts: 58
edited 2006-07-26 13:58 in General Discussion
idea.gif
OK - here's an in-progress look at what I'm working on for a tool-chain. Included here are very early versions of the low-level assembler, and the compiler.



The assembler (llasm) only assembles single-word instructions, and has no macro support. However, it does support assemble-time expressions, symbol redefinition, and forward references (denoted by the @ operator prepended to a label). Also, the mnemonics are a bit different - instructions like mov w,--fr would have required a whole instruction-form for themselves (and thusly increased the structural complexity of the assembler, just to support that one instruction). So, what I have done is code that as dec w,fr (and done likewise for the other "arithmetic" mov instructions).



The compiler (mcc) does not adhere to any pre-existing language (like BASIC or C); but draws on both C and Pascal for inspiration. It's targeted at small micro-controllers, with specific support for the SX's "virtual peripheral" concept. Also, you can chain together multiple files on the command line, and it will integrate them into a single assembler output file (which is then fed to llasm to generate the device image).

A program module might look like this:

myProgram
{
byte myGlobal;

myFunction(byte myParam)
{
return myParam++;
};

main()
{
byte myVar;

myVar:=myFunction(1); // myVar will now be 2
};
};


There are two other kinds of things that can go in a module besides functions and globals - init routines and VDx routines. Unlike functions, these are compiled into a single sequence of opcodes, with no function-entry code (because they do not take parameters). Init routines are (like the name implies) run at reset-time; and are intended to do variable and device setup chores, before the main routine gets entered. VDx routines, however, are special - they are combined to form the interrupt handler, and comprise the compilers support for "virtual peripherals" (oh - and that stands for Virtual Device eXtension). Variables defined in the init routines are temporary; and go out of scope as soon as the init sequence is over -- but VDx variables are allocated out of their own bank of memory, and are accessible by other functions (although, the bank-switching involved does make accessing them - like globals - from functions about 10 times slower than accessing local variables declared in a function; but because the bank is switched on entry to the VDx routines, interrupt-time access is fast).

A simple timer module might look like this:

simpleTimer
{
init timer
{
ticks:=0;
};

vdx timer
{
byte ticks;
ticks++;
};
};


What's in the .zip file is the Xcode projects for mcc and llasm, as well as few test files for mcc. To facilitate portability; the paths for the test files have been coded to /SX/ -- so, just stick the SX folder that's in the .zip file onto your main HDD partition; and you should be able to compile and run both mcc and llasm (I've set up the requisite arguments to them to compile the mcc test files in the Xcode project files for mcc and llasm). You will need the latest version of Xcode on your machine to do this; however. Also, I have not yet tested compiling the current versions of the projects on a PPC machine; but compiling to a PPC target on my Intel iMac works OK, so I think it should work... (there are some library variations between platforms that I ran into earlier, so if you have trouble, please let me know).




DISCLAMER: nono.gif

This software is incomplete, and very likely has bugs in it. It is completely UNTESTED! Do not use this on any real projects. Only use it for experimentation and personal education! THERE IS NO WARRANTY OF ANY KIND! THERE IS NO WARRANTY OF MERCHANTIBILITY FOR ANY PURPOSE!

DO NOT COPY! This software is intended for Parallax Forum members ONLY, and ONLY to show these forum members what I am working on. At some point in the future, a version that can be given to others may be made available - BUT THIS IS NOT IT!

USE AT YOUR OWN RISK!



There... I think I've satisfied the lawyers! freaked.gif

Comments

  • Dave PatonDave Paton Posts: 285
    edited 2006-07-25 16:22
    Wow. This is going to be cool. Very, very, very cool I think.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    This is not a sig. This is a duck. Quack.
  • James NewtonJames Newton Posts: 329
    edited 2006-07-25 22:46
    I take it this is for Macs only? I couldn't even open the zip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • DunnseptDunnsept Posts: 115
    edited 2006-07-26 13:15
    I opened it without a problem on my XP machine, but had to save to disk first, then open thru windows exploder.
    but considering that there are files/folders in the zip that are __MACOSX you may be right wink.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    stand back! I have a slide rule and I know how to use it!
  • hammerhead74000hammerhead74000 Posts: 58
    edited 2006-07-26 13:58
    Theoretically - and I say theoretically only because I haven't tested it yet - it should compile with a different compiler just fine. It's just standard C/Lex/Yacc... so either the MS tools (VC++), a port of gcc (cygwin, mingw, etc), Borland C, or Watcom C should be able to handle it. I have deliberately avoided "gcc-isms" that would hamper this.

    The pre-processor will be built in similar fasion; and should be portable also. However, my IDE, and the SX-Key programmer plugin for it, are written in Objective-C with the Cocoa framework; and are OS X only (but, there's no reason that the language tools - pre-processor, llasm, and mcc - couldn't be easilly integrated with the existing Windows SX-Key IDE; should Parallax decide that that's a good thing to do).
Sign In or Register to comment.