* RunBack.asm * * Written 3/11/87 * * Copyright (c) 1986 by C.Heath of Microsmiths Inc. * This program may be freely distributed, but only in it's original * unmodified state. If you wish to distribute a modified version either * commercially or otherwise, please contact: * * Microsmiths, Inc * PO Box 561 * Cambridge, MA 02140 * (617)354-1224 * bix: cheath Compuserve: 74216,2117 * * This is the equivalent of Rob Peck's RunBackground program, with * an addition of a command line Stack option, "-Snnnn". See the readme * file included with this ARC file for details. * ****** Equates and publics *************************************** INCLUDE "exec/types.i" INCLUDE "libraries/dos.i" INCLUDE "libraries/dosextens.i" MIN_LIB set $1f ; Library minimum rev level! ; ADOS "stack" command MIN_STACK set 1600 ; Minimum stack allowed by the ; ADOS "stack" command *** NOTE: This was assembled with Manx V3.30E, but should be compatible *** with MCC with minor changes. xlib macro public _LVO\1 endm entry .begin public .begin .begin xlib OpenLibrary xlib CloseLibrary xlib FindTask xlib Output xlib Write xlib Lock xlib Examine xlib UnLock xlib CurrentDir xlib ParentDir xlib Open xlib Close xlib Delay xlib Execute ****** The Program *************************************** * Registers: * D6 is starting SP * D5 is execution delay * D4 is Save SP value * * A5 is p->CmdLineSwished * A4 is CLIStruct for Process Base * A3 is p_cmdname Start: move.l sp,D6 ; Save stack pointer move.l A0,A2 ; Register A2 is cmdline henceforth clr.b 0(A2,D0.w) ; Make sure she be null terminado move.l 4,A6 ; ExecBase in A6 until DOSBase suba.l A1,A1 jsr _LVOFindTask(A6) move.l D0,A4 ; Process base move.l pr_CLI(A4),D0 beq.s BadExit ; Not a CLI process. Punt asl.l #2,D0 move.l D0,A4 ; A4 points at CLIStruct henceforth move.l cli_DefaultStack(A4),D4 ; D4 is Default Stack_a_Roo lea DOSName(pc),A1 ; Open DOS.library moveq.l #MIN_LIB,d0 jsr _LVOOpenLibrary(A6) move.l D0,A6 or.l D0,D0 bne.s ok_start ; Continue if library OK, * fall in to BadExit code if DOS library couldn't open ************************************************************************ * * BadExit is where to go if there is an error opening the DOS library * This should only happen if things are really sick * ************************************************************************ BadExit: moveq #20,D0 rts ************************************************************************ * * ok_start * Proceed with normal code, check the input string. * ************************************************************************ ok_start: moveq #0,D5 ; Default delay value * * Process the input command string * skpspc: move.b (A2)+,D1 ; Skip spaces beq.s show_how ; Null string - give help! cmp.b #$20,D1 beq.s skpspc cmp.b #$0a,D1 beq.s show_how ; Help! Help!!! cmp.b #'?',D1 beq.s show_how ; Also a "?" asks for help! cmp.b #'-',D1 beq.s parse_opt ; Parse delay or stack option * Here, A2 points at the command+1, D1 is first char do_command: * 256 is normally max cmdline size. * But we add "run " 1$: move.b (A0)+,(A5)+ bne.s 1$ subq #1,A5 ; Back up a char! move.l A5,A3 ; Save pointer to cmd_name move.b #' ',D0 cmp.b #'"',D1 bne.s do_cmd ; Check for Quoted string move D1,D0 ; Save terminator character! addq #1,A3 ; ADVANCE NAME PTR!!!! do_cmd: move.b D1,(A5)+ ; Save the first char move.b (A2),D1 beq.s have_cmd ; EOS - leave A2-> EOS! cmp.b #$0a,D1 beq.s have_cmd ; Ditto. addq #1,A2 cmp.b D0,D1 bne.s do_cmd ; Loop till terminator * Here, the command has been copied. Add in "] [-Snnnn] []',$0a dc.b ' where optional loaddelay is 0-9 seconds,',$0a dc.b ' and Snnnn is an optional Stack size to set',$0a,0 Erst: dc.b 'RUN >NIL: nilnam: dc.b 'NIL:',0 CantStart: dc.b "RunBack: Error starting background task!',$0a dc.b "You must have the program 'Run' in your C: directory",$0a,0 CantFind: dc.b "Can't find ",0 OKStart: dc.b 'Started background task' LFStr: dc.b $0a,0 END