The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Hello World compiled in v1/v2
@ 2014-07-13 20:38 Mark Longridge
  2014-07-13 21:05 ` Dave Horsfall
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Longridge @ 2014-07-13 20:38 UTC (permalink / raw)


Hi folks,

Yes I have managed to compile Hello World on v1/v2.

the cp command seems different from all other versions, I'm not sure I
understand it so I used the mv command instead which worked as
expected.

I had to "as crt0.s" and put crt0.o in /usr/lib and then it compiled
without issue.

Is the kernel in /etc? I saw a core file in /etc that looked like it
would be about the right size. No unix file in the root directory
which surprised me.

At least I know what crt0.s does now. I guess a port of unirubik to
v1/v2 is in the cards (maybe).

Mark



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] Hello World compiled in v1/v2
  2014-07-13 20:38 [TUHS] Hello World compiled in v1/v2 Mark Longridge
@ 2014-07-13 21:05 ` Dave Horsfall
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Horsfall @ 2014-07-13 21:05 UTC (permalink / raw)


On Sun, 13 Jul 2014, Mark Longridge wrote:

> Yes I have managed to compile Hello World on v1/v2.

Congrats!

> the cp command seems different from all other versions, I'm not sure I 
> understand it so I used the mv command instead which worked as expected.

I'm intrigued; in what way is it different?

[...]

> At least I know what crt0.s does now. I guess a port of unirubik to
> v1/v2 is in the cards (maybe).

crt0.s -> C Run Time (support).  It jiggers the stack pointer in some 
obscure manner which I never did quite grok.

-- Dave



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] Hello World compiled in v1/v2
@ 2014-07-13 23:21 Noel Chiappa
  0 siblings, 0 replies; 3+ messages in thread
From: Noel Chiappa @ 2014-07-13 23:21 UTC (permalink / raw)


    > From: Dave Horsfall <dave at horsfall.org>

    > crt0.s -> C Run Time (support). It jiggers the stack pointer in some
    > obscure manner

It's the initial startup; it sets up the arguments into the canonical C form,
and then calls main(). (It does not do the initial stack frame, a canonical
call to CSV from inside main() will do that.) Here are the exact details:

On an exec(), once the exec() returns, the arguments are available at the
very top of memory: the arguments themselves are at the top, as a sequence of
zero-terminated byte strings. Below them is an array of word pointers to the
arguments, with a -1 in the last entry. (I.e. if there are N arguments, the
array of pointers has N+1 entries, with the last being -1.) Below that is a
word containing the size of that array (i.e. N+1).

The Stack Pointer register points to that count word; all other registers
(including the PC) are cleared.

All CRT0.s does is move that argument count word down one location on the
stack, adjust the SP to point to it, and put a pointer to the argument
pointer table in the now-free word (between the argument count, and the first
element of the argument pointer table). Hence the canonical C main() argument
list of:

	int	argc;
	int	**argv;

If/when main() returns, it takes the return value (passed in r0) and calls
exit() with it. (If using the stdio library, that exit() flushes the buffers
and closes all open files.) Should _that_ return, it does a 'sys exit'.

There are two variant forms: fcrt0.s arranges for the floating point
emulation to be loaded, and hooked up; mcrt0.s (much more complicated)
arranges for process monitoring to be done.

	Noel



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-13 23:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-13 20:38 [TUHS] Hello World compiled in v1/v2 Mark Longridge
2014-07-13 21:05 ` Dave Horsfall
2014-07-13 23:21 Noel Chiappa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).