Date: Mon, 26 Apr 93 12:27:03 EDT From: sebo@nmr.lpc.ethz.ch (Serge Boentges) To: Multiple recipients of list Subject: mini_gcc/gcc_mini now with minlib! Hi folks, A version of the mini_startup.h file for use with the mini_gcc is now available on cher.media.mit.edu in /pub/miniboard/gcc/ mini_startup.h . The distribution file from Coactive A. is available on netcom.com, called /pub/coactive/gcc-6811-alpha.tar.Z Maybe Fred Martin is even going to copy a version onto cher.media.mit.edu. There also will be an instruction file for changing/patching the C.A. GNU port to run with Fred's minilib, which is included in the mini_startup.h, on cher... in /pub/miniboard/gcc. For the moment, I include a copy for the very eager beavers on the net. The minilib contained in mini_startup.h will allow you, to write C-code for your MB containing function calls of the sort: if ( a > 5) motor (15,4) /* motor 4 is switched on at full speed if a >5 */ For a detailed description see either comments in mini_startup.h header or read description in Mini Board 2.0 Technical Reference by Fred Martin. Caveat!!! The parameter list is in the reverse order of what is decribed in Fred's manual. This made porting MUCH simpler. -----%<---------------------------------------------------------------------------- How to install the mini_gcc in steps! -------------------------------------- Here are some additional hints for installing the mini_gcc, a small modfication of the Coactive Aestethics GNU port for the 68hc11, on a SPARC Sun platform. I never tried this for a PC! The compiler, with the modifications given below, will be able to generate code using the the miniboard library functions of Fred Martin. The implementation of the library function is included in the header file "mini_startup.h", which has to be included in any C-program for the miniboard. The function implementation is included in mini_startup.h as inline-assembler instructions. The Coactive Aestethics GNU port doesn't currently feature a linker, therefore no object library can be used. How to go about the installation: 1) Get the distribution tar-file: /pub/coactive/gcc-6811-alpha.tar.Z from netcom.com (maybe some other sites also carry it, but that the only one I know.) 2) Follow carefully the instructions given in README.6811 . (Also read the README.ADDENDUM. The changes described to be made in "varasm.c" are crucial, if you want to use the minilib startup file) They are very detailed an there are only two small things, which need to be changed for the use with the miniboard: a) If you don't want the compiler to be intalled in /usr/local but somewhere else, say /hobby/miniboard, type: ./configure --host=sparc-sun-sunos4.1 --target=m6811-local \ --prefix=/hobby/miniboard instead of just ./configure --host=next --target=m6811-local Somewhere in the gcc code, some absolut pathes are included; if you don't use the prefix option from start to give the installation directory, your gcc will not find all the ancillary programs it needs. I tried to move the files by hand and that just will not work. b) If you want to interface the generated assembler code with Fred's minilib, some additional patching is needed. Fred's routines, e.g. motor( motor#, speed), assume, that all funtion arguments are passed on the stack. The C.A. compiler however passes all but the first argument on the stack and the latter in register D ( pseudo register used by C.A. that is). To fix this, needs a single change in the file m6811-local.h (include in the distribution set): 602,603c605,612 < #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ < (((CUM) == 0) ? gen_rtx(REG, MODE, HARD_D_REGNUM) : 0) --- > > /* > ** First word is NOT passed using the D register > * Naive attempt to fix this by sebo > */ > #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0 > > Though naive, it works perfectly well, I tried it! Of course, you will need to recompile the compiler from scratch. Use `make clean' to remove all object files and all prevoius compiler versions. By now, your compiler should be compiled and generate perfect assembler code with the correct calling conventions for the minilib function calls. To use the minilib, you have to include the mini_startupfile.h. This file contains all the assembler instructions to implement such functions as "motor( 1,12)" as inline assembler instructions (Remember, that the Coactive Aestethics GNU compiler version comes without a linker, so you can not use an object library) Try the following sample program: a) copy the program to a file light_show.c ---%<--------------------------------------------------- #include "mini_startup.h" extern motor(); extern off(); extern mssleep(); main() { while(1){ /* stay in an endless loop, don't send the CPU */ /* to limbo after termination. Actually the C.A. */ /* generates assembler code, which gos into an endless */ /* loop on return from main(), but this puts us on the */ /* safe side, especial if go to add wheels and laser */ /* guns to your robot ..... */ motor( 15, 1); /* switch on motor 1, speed 15 */ msleep( 500); /* sleep for 500 msec, time to realize the motor LED is on */ off(1); /* obvious, I think */ motor( -2, 1); /* reverse direction m# 1, speed -2, the 2. LED comes on dimly */ msleep( 500); off(1); /* redo for all 4 motor ports */ motor( 1, 2); /* Hmmm, the daring might add a for loop, that's what C is all */ msleep( 500); /* about, right? */ off(2); motor( -9, 2); msleep( 500); off(2); motor( 15, 3); msleep( 500); off(3); motor( -15, 3); msleep( 500); off(3); motor( 15, 4); msleep( 500); off(4); motor( -15, 4); msleep( 500); off(4); } } -----%<---------------------------------------------------------------- b) type: mini_gcc -S light_show.c this creates an ASCII assembler file light_show.s c) use the assembler as11 (from Motorola) to translate light_show.s into light_show.s19 ( Don't mind the warnings, it works anyway) d) use your favorite dlm20 to download light_show.s19 to your miniboard. The program should turn on all the lights on your motor board one after this other like a running light forever (or at least as long as the battery lives). If you use the modified as.c file given in this directory, you can call the assembler in one single compile step: |1> mini_gcc -c myfile.c |2> mv myfile.o myfile.s19 I hacked the as.c code for the 6811 from Motorola to make it accept an input line like: as -o /tmp/output.file inputfile - This is the way, the mini_gcc will call the assembler. The hack is very crude, I hope, I willfix it one day, but for now it works. To Do List: ---------- a) Include all the preprocessor switches from Fred Martin's original file, so one can use the shaft encoder etc. This is not hard to do, but I'm getting hell of short in time for my Nuclear Magnetic Resonance thesis! (This means, robotics is strictly my hobby. Sorry folks.) b) Include the serial stuff. Rember, that there is only about 2048 bytes of EEPROM, and the current version is allready eating ~700 bytes. One should think about breaking the library into smaller files containing just one single function at a time, so you can include only those functions you need. For example : a) program header (define symbolic names, prepare pseudo regs in RAM, set interrupts, etc.) b) interrupt handler for updating sensor reading etc. c) engine routine d) sensor routines etc. ... This is the way, the original stuff actually was organized! Hmm, doesn't look to hard on second thought, you just have to be carefull, to get a) and b) allways in the right order. c) Get a SERVO CONTROL FUNCTION. I still don't have this assembler manuals. There is an assembler routine availabel on cher.media.mit.edu in /pub/incoming, which in principle does the trick, but insists on messing aroung with all the motor ports and generates interupts of its own, which are very critical in timing. Looks a bit tricky to me..... P.S. All the brains in the startupfile are Fred Martin's, not mine! I only adapted his assembler code to fit the calling convention of mini_gcc. +-----------------------------------------------------------------------------+ | Serge Boentges | Bitnet: sebo@nmr.lpc.ethz.ch | | Institut fuer physikalische Chemie | | | Eidgenoessische Technische Hochschule| "Learn from yesterday, | | ETH-Zentrum | live for today, | | CH-8092 Zuerich | look to tomorrow, | | Phone: +41/1/256-4372 | rest this afternoon." | | Fax: +41/1/252-3402 | --Snoopy | +-----------------------------------------------------------------------------+