From mboxrd@z Thu Jan 1 00:00:00 1970 From: brantleycoile@me.com (Brantley Coile) Date: Wed, 07 Jan 2015 05:06:29 -0500 Subject: [TUHS] pdp11 UNIX memory allocation. In-Reply-To: <20150107063935.GA27943@www.oztivo.net> References: <54AC4394.3050302@update.uu.se> <1420576433.410248.210385277.513EF8EC@webmail.messagingengine.com> <5E62DDAA-0055-46FB-8077-92DB856DEEE0@ronnatalie.com> <2509FDBD-67C4-4552-BB58-01281049DCB6@ronnatalie.com> <20150107063935.GA27943@www.oztivo.net> Message-ID: It indeed executes the magic number. The comment at the end of sysexec says it executes the code at $core, which has the twelve word header still in it. Notice that the magic number is two less than the later formats; 0405 instead of 0407. This most likely means that the header was still in the address space in later versions even after another two words were added to the header. Brantley Sent from my iPad > On Jan 7, 2015, at 1:39 AM, Warren Toomey wrote: > >> 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 > _______________________________________________ > TUHS mailing list > TUHS at minnie.tuhs.org > https://minnie.tuhs.org/mailman/listinfo/tuhs -------------- next part -------------- An HTML attachment was scrubbed... URL: