In SX Microcontrollers, SX/B Compiler and SX-Key Tool, hammerhead74000 wrote: :idea: 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: 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 [i]think[/i] I've satisfied the lawyers! :freaked: ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=136983 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)