Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!nosc!helios.ee.lbl.gov!lll-tis!lll-winken!uunet!mcvax!hp4nl!philmds!leo
From: leo@philmds.UUCP (Leo de Wit)
Newsgroups: comp.sys.atari.st
Subject: Re: Clearing memory [was Re: Another great quote from Mr. Good]
Message-ID: <585@philmds.UUCP>
Date: 11 Aug 88 16:54:59 GMT
References: <1103@atari.UUCP> <19880807215637.4.JRD@MOA.SCRC.Symbolics.COM> <456@midgard.UUCP>
Reply-To: leo@philmds.UUCP (Leo de Wit)
Organization: Philips I&E DTS Eindhoven
Lines: 42

In article <456@midgard.UUCP> caa@midgard.mn.org (Charles A Anderson) writes:
  [some lines deleted]...
>I thought that this meant that the relocator was extremly slow, however I
>have since been informed that the relocator is in actuality quite fast, and
>that a possible explanation is that pc relative programs do not have memory
>cleared before they are executed.  Anybody got the real story???

You hit the nail on the head. The real story is, that when the word at
0x1a of the binary is non-zero, no relocation is done; the memory clearing
is also not done (which is incorrect as far as the bss part is conceirned,
read your K&R), which you may consider a bug or a feature, and the program
file (which was opened to be read into memory) is not closed (a bug).
I posted an article some days ago about the format of ST binaries; you can
find more info there.

Your assembler obviously set the word at 0x1a when assembling
'pc-relative'.  I find the expression 'pc-relative' a bit strange in
this context; pc-relative is an addressing mode on the 68000 which can
be used only for reading. If you want to write to a location in this
way you have to load it into an address register first (or something
similar). Example:

     lea.l  flag(pc),a2
     st     (a2)

flag dc.b   0

Perhaps is meant: address register indirect with displacement. Example:

* a2 already loaded with start of a data area
     st     flag(a2)

flag equ datarea+20

This is also used by many of the C-compilers; at the start of a program
an address register is loaded with the start of a data segment (data or
bss), or preferably 32K further.  This addressing mode can address 64K;
if the segment is larger, absolute addressing is used generally (AND
relocation!).
The exact story of how registers are initialized by Pexec I'll tell in
a follow-up.

                     Leo.