[comp.sys.amiga.tech] LoadSeg

chk@dretor.dciem.dnd.ca (C. Harald Koch) (05/02/89)

In article <8905012052.AA25549@postgres.Berkeley.EDU> dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) writes:
> [... lots of stuff about LoadSeg() ...]
>
>	(8) re-write LoadSeg() in C ... This is extremely simple to do, and
>	    implement all of the above of course.
>
>	* If you don't want to do this, I would be happy to!

So why don't you write it all anyway, and release it as a "replacement
LoadSeg() function"? Amiga will probably then incorporate it (like your
pipe) and in the mean time the Amiga programmers of the world will heap even
more praise upon you!

	-chk
-- 
C. Harald Koch		NTT Systems, Inc., Toronto, ON Canada
chk@gpu.utcs.toronto.edu, chk@zorac.dciem.dnd.ca, chk@chkent.UUCP
"If you'll excuse me a minute, I'm going to have a cup of coffee."
- broadcast from Apollo 11's LEM, "Eagle", to Johnson Space Center, Houston
  July 20, 1969, 7:27 P.M.

jesup@cbmvax.UUCP (Randell Jesup) (05/04/89)

In article <1688@dciem.dciem.dnd.ca> chk@dretor.dciem.dnd.ca (C. Harald Koch) writes:
>In article <8905012052.AA25549@postgres.Berkeley.EDU> dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) writes:
>> [... lots of stuff about LoadSeg() ...]
>>
>>	(8) re-write LoadSeg() in C ... This is extremely simple to do, and
>>	    implement all of the above of course.
>>
>So why don't you write it all anyway, and release it as a "replacement
>LoadSeg() function"? Amiga will probably then incorporate it (like your
>pipe) and in the mean time the Amiga programmers of the world will heap even
>more praise upon you!

	To avoid people spending time in redundant pursuits, LoadSeg already
has been rewritten by Commodore, in optimized assembler.

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup

dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) (05/07/89)

:In article <8905012052.AA25549@postgres.Berkeley.EDU> dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) writes:
:> [... lots of stuff about LoadSeg() ...]
:>
:>	(8) re-write LoadSeg() in C ... This is extremely simple to do, and
:>	    implement all of the above of course.
:>
:>	* If you don't want to do this, I would be happy to!
:
:So why don't you write it all anyway, and release it as a "replacement
:LoadSeg() function"? Amiga will probably then incorporate it (like your
:pipe) and in the mean time the Amiga programmers of the world will heap even
:more praise upon you!
:
:	-chk

	It would have to implemented system-standard to be of any use at
all.  I would only do it if it became part of the release.  But since,
as Bryce pointed out, most of it has been rewritten already, than Commodore
ought to do the rest.

				-Matt

valentin@cbmvax.commodore.com (Valentin Pepelea) (04/07/90)

In article <15113@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>
>I'm having trouble with the LoadSeg() function call.  Whenever I call it,
>it loads the specified segment except for one thing: the first word is
>written over with what seems to be garbage.  At the start of one program,
>for example, I have the code 0x6040 0x487a, a bsr instruction, I thing.
>When I try to execute the code, however, I get a 0x4afc 0x487a.  The garbage
>word is always 0x4afc.  Does this number look familiar to anyone?  Does it
>have some mystical meaning in AmigaDOS?  Has anyone had a similar problem?
>Help!
>
>pfalstad@phoenix.princeton.edu

When asking such questions, please include the part of the source code in
question. One thing you must remember here is that some pointers provided
to the LoadSeg() function are BCPL pointers, called BPTR's. If these pointers
do not point to long-word aligned buffers, then the first word of your buffer
risks getting overwritten.

Valentin
-- 
The Goddess of democracy? "The tyrants     Name:    Valentin Pepelea
may distroy a statue,  but they cannot     Phone:   (215) 431-9327
kill a god."                               UseNet:  cbmvax!valentin@uunet.uu.net
             - Ancient Chinese Proverb     Claimer: I not Commodore spokesman be

pfalstad@phoenix.Princeton.EDU (Paul John Falstad) (04/08/90)

In article <10663@cbmvax.commodore.com> thomas@cbmvax (Linda Thomas) writes:
>In article <15113@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>> 
>> I'm having trouble with the LoadSeg() function call.  Whenever I call it,
>> it loads the specified segment except for one thing: the first word is
>> written over with what seems to be garbage.
>> 
>
>LoadSeg() does not return a pointer to the code.  It returns a BPTR to a
>SegList.  From C you can get a pointer to the first segment by:
> [stuff deleted]
>Linda Thomas, Commodore Amiga Test Engineering
>UUCP  ...{uunet,rutgers}!cbmvax!thomas or thomas@cbmvax.commodore.com


Yes, I know, that's not the problem.  I call LoadSeg() and use the BPTR
to get a pointer to the first seg in the seglist.  The contents of the
seglist are fine, except for the first word.  I converted all the BPTR's
to CPTR's, etc.

I seem to have fixed this problem by putting a WaitBlit() after the
LoadSeg().  I know it sounds utterly ridiculous, but it seems to work.
If I have further problems, I'll post a code fragment.  Thank you.

pfalstad@phoenix.princeton.edu

pfalstad@phoenix.Princeton.EDU (Paul John Falstad) (04/08/90)

In article <15188@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>In article <10663@cbmvax.commodore.com> thomas@cbmvax (Linda Thomas) writes:
>>In article <15113@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>>> 
>>> I'm having trouble with the LoadSeg() function call.  Whenever I call it,
>I seem to have fixed this problem by putting a WaitBlit() after the
>LoadSeg().  I know it sounds utterly ridiculous, but it seems to work.

I've somewhat figured it out.  When I run the code with the debugger,
it doesn't work.  When I run it without the debugger, it works.  >:-(
The debugger is Manx 5.0a db.

Just never mind.  If all else fails, I'll write my own version of LoadSeg().
I had to write my own version of CreateProc() anyway (I'm working on an
Amiga version of fork() ).

pfalstad@phoenix.princeton.edu

mks@cbmvax.commodore.com (Michael Sinz - CATS) (04/09/90)

In article <15204@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>In article <15188@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>>In article <10663@cbmvax.commodore.com> thomas@cbmvax (Linda Thomas) writes:
>>>In article <15113@phoenix.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul John Falstad) writes:
>>>> 
>>>> I'm having trouble with the LoadSeg() function call.  Whenever I call it,
>>I seem to have fixed this problem by putting a WaitBlit() after the
>>LoadSeg().  I know it sounds utterly ridiculous, but it seems to work.
>
>I've somewhat figured it out.  When I run the code with the debugger,
>it doesn't work.  When I run it without the debugger, it works.  >:-(
>The debugger is Manx 5.0a db.

Ahh, you should have said that "db" was running.  The MANX db SetFunction()s
the LoadSeg() call so that it can patch the first instruction of the
newly loaded file in case it needs to stop it right after the LoadSeg()
This is how db catches the next loaded program.

>Just never mind.  If all else fails, I'll write my own version of LoadSeg().
>I had to write my own version of CreateProc() anyway (I'm working on an
>Amiga version of fork() ).
>
>pfalstad@phoenix.princeton.edu

/----------------------------------------------------------------------\
|      /// Michael Sinz -- CATS/Amiga Software Engineer                |
|     ///  PHONE 215-431-9422  UUCP ( uunet | rutgers ) !cbmvax!mks    |
|    ///                                                               |
|\\\///          "I don't think so," said Ren'e Descartes.             |
| \XX/                    Just then, he vanished.                      |
\----------------------------------------------------------------------/