[TUHS] pdp11 UNIX memory allocation.

Brantley Coile brantleycoile at me.com
Wed Jan 7 20:06:29 AEST 2015


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 <wkt at tuhs.org> 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: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150107/7c83f212/attachment.html>


More information about the TUHS mailing list