[comp.sys.amiga.tech] THOSE DAMNED BPTR'S

mark.newton@f805.n680.fido.oz.au (Mark Newton) (11/07/90)

I believe there was something about this posted a couple of months ago, but I
can't find it. <sigh>
 
I want to write a function that does something like Execute() or system(),
partly as a learning experience, but mostly to give a bit more flexability than
those two functions.
 
I was under the impression that I could use LoadSeg() to load the code for the
new process, initialize a (struct Process) so that it's pr_SegList was pointing
to the LoadSeg()'ed code, set the initial PC to the start of the code and call
CreateProc().  Ok so far? Ok.
 
LoadSeg() returns a long, and the pr_SegList is a BPTR.  I haven't got the
autodocs (I have got 1.3 Libraries and Devices), but I assume that the return
address from LoadSeg() is the starting address in memory of the segment.  How
can I convert this to a BPTR?
 
Thanx muchly,
    -mark
--- TBBS v2.1/NM
 * Origin: ADAM, 2,100 MEGS R/W 32 line TBBS call us 08-370-5775 (680/805)

jesup@cbmvax.commodore.com (Randell Jesup) (11/12/90)

In article <18556@ultima.socs.uts.edu.au> mark.newton@f805.n680.fido.oz.au (Mark Newton) writes:
>I was under the impression that I could use LoadSeg() to load the code for the
>new process, initialize a (struct Process) so that it's pr_SegList was pointing
>to the LoadSeg()'ed code, set the initial PC to the start of the code and call
>CreateProc().  Ok so far? Ok.

	Not OK.  Read the documentation on CreateProc.  Note that it takes
a seglist (as returned by LoadSeg), NOT a Process structure.  Anyone allocating
their own process structures will be hung by their toenails. :-)

>LoadSeg() returns a long, and the pr_SegList is a BPTR.  I haven't got the
>autodocs (I have got 1.3 Libraries and Devices), but I assume that the return
>address from LoadSeg() is the starting address in memory of the segment.  How
>can I convert this to a BPTR?

	LoadSeg returns a BPTR.  Note that Dos is documented in the the
Bantam AmigaDos book, not the RKMs (due to an old contract).  The Autodocs
(including Dos) are available from CATS.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"

static@phoenix.pub.uu.oz.au (geoff c wing) (11/12/90)

In <18556@ultima.socs.uts.edu.au> mark.newton@f805.n680.fido.oz.au (Mark Newton) writes:
>I want to write a function that does something like Execute() or system(),
>partly as a learning experience, but mostly to give a bit more flexability than
>those two functions.
> 
>I was under the impression that I could use LoadSeg() to load the code for the
>new process, initialize a (struct Process) so that it's pr_SegList was pointing
>to the LoadSeg()'ed code, set the initial PC to the start of the code and call
>CreateProc().  Ok so far? Ok.
> 
>LoadSeg() returns a long, and the pr_SegList is a BPTR.  I haven't got the
>autodocs (I have got 1.3 Libraries and Devices), but I assume that the return
>address from LoadSeg() is the starting address in memory of the segment.  How
>can I convert this to a BPTR?
> 
>Thanx muchly,
>    -mark
>--- TBBS v2.1/NM
> * Origin: ADAM, 2,100 MEGS R/W 32 line TBBS call us 08-370-5775 (680/805)

LoadSeg returns a BCPL pointer(BPTR) to the first segment. Now you can just
call CreateProc with the appropriate information, which will run the program 
under a NEW process it has just initialized. You don't have to go to the effort
of initializing that process yourself, but you can, of course, change it after
it's started.
BTW, CreateProc returns a BCPL pointer to the MsgPort of the process data 
structure. You should get "Advanced System Programmer's Guide for the Amiga" 
(book 7) by Abacus. It documents calls to the standard libraries.

BPTR : actual address divided by four 
BSTR : byte containing length of string followed by actual string
-- 
	+---------------------------------+       _  _ _ _  __
	|	     Geoff		//|   /\  |\/|  |  / _   /\
	| static@phoenix.pub.uu.oz.au \X/ |  //\\ |  | _|_ \__| //\\
	+---------------------------------+

smp@myamiga.UUCP (Steve Palm) (11/13/90)

 RJ>         LoadSeg returns a BPTR.  Note that Dos is documented in the the
 RJ> Bantam AmigaDos book, not the RKMs (due to an old contract).  The Autodocs
 RJ> (including Dos) are available from CATS.
 
 I was wondering why dos.library wasn't documented.  I was rather upset, since
 that was part of my reason for purchasing the set.  What would I need to do to
 get the autodoc set (including dos.library) from CATS?
 


--  
     ///  AMIGA: | Steve Palm, Sysop of FidoNet node 1:11/16
    ///  FOR THE | UUCP: {gatech,ames,rutgers}!ncar!asuvax!stjhmc!myamiga!smp
\\\///  CREATIVE | INTERNET: [not yet available]
 \XX/     MIND   |_________________________________________________________ 

ken@cbmvax.commodore.com (Ken Farinsky - CATS) (11/14/90)

In article <114.273F7E66@myamiga.UUCP> smp@myamiga.UUCP (Steve Palm) writes:
>
> I was wondering why dos.library wasn't documented.

Dos.library is documented in the book "The AmigaDos Manual", published
by Bantam Books.  For contractual reasons, this is the only place that
the information is currently available.

>     ///  AMIGA: | Steve Palm, Sysop of FidoNet node 1:11/16
-- 
--
Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines
uucp: ken@cbmvax.commodore.com   or  ...{uunet,rutgers}!cbmvax!ken
bix:  kfarinsky

jesup@cbmvax.commodore.com (Randell Jesup) (11/15/90)

In article <1990Nov12.131651.5394@phoenix.pub.uu.oz.au> static@phoenix.pub.uu.oz.au (geoff c wing) writes:
>BTW, CreateProc returns a BCPL pointer to the MsgPort of the process data 
>structure. You should get "Advanced System Programmer's Guide for the Amiga" 
>(book 7) by Abacus. It documents calls to the standard libraries.

	No, CreateProc returns a struct MsgPort * (pointer to the pr_MsgPort
of the new process), NOT a BPTR to it.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"