On Wed, Jan 07, 2015 at 05:29:45PM +1100, Dave Horsfall wrote:
I heard a story that on sufficiently-early Unices, the
header was indeed
loaded, hence the "407".
Any grey-beards here like to comment?
My beard isn't grey (yet), but here's the link to the 1st Edition code
which does exec(2):
http://minnie.tuhs.org/cgi-bin/utree.pl?file=V1/u2.s
and here is the relevant code:
mov $14,u.count
mov $u.off,u.fofp
clr u.off / set offset in file to be read to zero
jsr r0,readi / read in first six words of user's file, starting
/ at $core
mov sp,r5 / put users stack address in r5
sub $core+40.,r5 / subtract $core +40, from r5 (leaves
/ number of words less 26 available for
/ program in user core
mov r5,u.count /
cmp core,$405 / br .+14 is first instruction if file is
/ standard a.out format
bne 1f / branch, if not standard format
mov core+2,r5 / put 2nd word of users program in r5; number of
/ bytes in program text
sub $14,r5 / subtract 12
cmp r5,u.count /
bgt 1f / branch if r5 greater than u.count
mov r5,u.count
jsr r0,readi / read in rest of user's program text
add core+10,u.nread / add size of user data area to u.nread
br 2f
1:
jsr r0,readi / read in rest of file
My memory of PDP-11 assembly is too rusty to interpret this. Anybody else?
Cheers, Warren