For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > January 2008 > Register state entering PDP-11 code









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Register state entering PDP-11 code
jgharston

2008-01-22, 4:34 am

When PDP-11 Unix enters a loaded program it enters with
r0-r5 and pc set to zero, and sp pointing to the arguments.
Are there any circumstances where a PDP-11 program
is entered with registers set to anything else? I'd like
give my PDP-11 emulator an option to enter programs
with a register set to a magic number to indicate to
knowing programs that they are running on the emulator
and so may access emulator-specific functions.

--
JGH - mdfs.net
Rob Brown

2008-01-22, 7:27 pm

On Tue, 22 Jan 2008, jgharston wrote:

> When PDP-11 Unix enters a loaded program it enters with
> r0-r5 and pc set to zero, and sp pointing to the arguments.
> Are there any circumstances where a PDP-11 program
> is entered with registers set to anything else?


This must be OS specific, as it is the OS that sets up the registers
when it starts a program. For example, when a program starts in RSX,
the registers are set entirely differently:

R0: transfer address
R1,R2: task name
R3,R4: program ident
R5: relative block number of header
SP: top of stack
PC: transfer address


--

Rob Brown b r o w n a t g m c l d o t c o m
G. Michaels Consulting Ltd. (780)438-9343 (voice)
Edmonton (780)437-3367 (FAX)
http://gmcl.com/

jgharston

2008-01-23, 7:19 pm

Rob Brown wrote:
> On Tue, 22 Jan 2008, jgharston wrote:
>
> This must be OS specific, as it is the OS that sets up the registers


It is OS-specific, it's Unix-specific. In the source for exec() in
sys1.c
the following code appears:
3186: for(cp = ®loc[0]; cp < ®loc[6];)
3187: u.u_ar0[*cp++] = 0;
3188: u.u_ar0[R7] = 0;

which sets r0-r5 and r7 to zero.

> when it starts a program. For example, when a program starts in RSX,
> the registers are set entirely differently:


That's useful. A program can tell if it's been run under RSX
or UNIX as R1-R5=0 onn UNIX and <>0 on RSX.

I think I shall use R5 to pass my magic number on my
emulator, keeping R0-R4=0 to indicate UNIX.

--
JGH
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com