[comp.sys.amiga] Help creating a Task; CreateProc

dillon@CORY.BERKELEY.EDU (Matt Dillon) (12/09/86)

extern struct Process *CreateProc();
extern void asm_go();

struct Process *proc;
long priority = 0;

proc = CreateProc("proce_sname", priority, (long)asm_go >> 2, 4096);


Here I am creating a process called "process_name" with priority 0 (normal), 
a stack of 4096 bytes, which begins at asm_go, which is some procedure.

I have to convert the address of asm_go to a BPTR (BCPL pointer).
The code actually starts at (bcplpointer << 2) + 4, as you can see by
the assembly below.

I think Manx requires one of the address registers to hold some
base pointer.  If using lattice, compile with the -v option to disable
stack checking.

asm_go() cannot be a normal C function, it must be written in assembly and
look something like:

	xref  myroutine
      	xdef  _asm_go


            CNOP  0,4			  ; make sure on longword boundry
_asm_go
            dc.l     0			  ; BCPL segment ptr (0).
            movem.l  d0-d7/a0-a6,-(sp)       ; save regs
		   ; ??? for manx load some address register?
            jsr      myroutine               ; call routine
	    movem.l  (sp)+,d0-d7/a0-a6	     ; restore regs
            rts

FOR MANX, you may have to also load an address register to get the global
base pointer.  I myself do not use Manx, so your on your own on that.

NOTE!!! To use stdio and other things, you must set up other entries in
the Process structure.  You CANNOT use exit()  from the spawned process 
since it will attempt to exit from the first process from the second.


						-Matt