Return-Path: robot-board@oberon.com Received: by media.mit.edu (5.57/DA1.0.4.amt) id AA04237; Fri, 18 Feb 94 12:11:32 -0500 Received: from ([127.0.0.1]) by oberon.com (4.1/SMI-4.1_Armado.MX) id AA14056; Fri, 18 Feb 94 12:08:58 EST Date: Fri, 18 Feb 94 12:08:58 EST Message-Id: <9402181642@bernard> Errors-To: gkulosa@oberon.com Reply-To: froula@bernard.cig.mot.com Originator: robot-board@oberon.com Sender: gkulosa@oberon.com Precedence: bulk From: froula@bernard.cig.mot.com (Don Froula) To: Multiple recipients of list Subject: minilib without C X-Listprocessor-Version: 6.0b -- ListProcessor by Anastasios Kotsikonas I'm sure someone has thought of this before, but I thought I'd mention the idea. The minilib.s library functions, that were written for use with C compilers, can also be used quite nicely as a basis for stand-alone assembly programs. The basic changes needed are: 1.) Rename the minilib.s file to minilib.asm 2.) Remove or comment out the two lines containing SECT assembler directives. The Motorola assembler will choke on these. 3.) Remove the lines containing the instructions: JSR _main exit bra exit 4.) Substitute your own code loop in place of these lines, right after the line containing the CLI (interrupt enable) instruction. All library function parameters are passed on the stack as 16 bit integers. To call a library function, push the values on the stack, then JSR to the label of the desired function. Remember, the parameters are still on the stack after the function returns to your code. Be sure to restore the stack pointer, or you'll run out of stack ram in a hurry! Also, functions that take more than one argument must be pushed onto the stack in reverse of the "C" argument order. For example, the C function call "motor(1,8)" will turn on motor 1 in the forward direction at half speed (level "8"). To do this in your minilib assembly loop: LDX #8 *Motor speed and direction (SECOND parameter in C code) PSHX *Push motor speed and direction to stack LDX #1 *Motor number (FIRST parameter in C code) PSHX *Push motor number to stack JSR _motor *Call the function PULX *Remove both numbers from the stack after call returns PULX For functions with no arguments, just JSR to the function. Assembly labels for the functions are all "_", so the label for "int analog(int port)" is "_analog". Functions that return integers return them as an 8 bit value in the B accumulator. I got my first application running in less than 30 minutes!