From: jrvalverde@cnb.csic.es (Jose R. Valverde)
Subject: [TUHS] Introduction
Date: Mon, 30 Jun 2008 11:30:28 +0200 [thread overview]
Message-ID: <20080630113028.46a50360@veda.cnb.uam.es> (raw)
In-Reply-To: <20080629102523.0219a85c.lehmann@ans-netz.de>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3562 bytes --]
On Sun, 29 Jun 2008 10:25:23 +0200
Oliver Lehmann <lehmann at ans-netz.de> wrote:
> Jose R. Valverde wrote:
>
> > Why don't you try to split the assignment into various statements
> > to reproduce the assembly and the recombine them? Like, e.g.
> >
> > 1: r2 = uap->linkname; /* ldl rr2,rr8(#4) */
> > 2: r4 = (long) r2; /* ldl rr4,rr2 */
> > 3: r4 &= 0x7F00FFFF; /* and rr4,#32512 */
> > 4: u.u_dirp.l = (caddr_t) r4; /* ldl _u+78, rr4 */
>
> hm.. this won't work because the compiler starts handing out registers
> the register-declared variables with the highest register possible so
> would start with rr10 or so.
But you would still be able to see what did generate the code (barring
register number).
>
> > u.u_dirp.l = (caddr_t) ((long) (((saddr_t) uap->linkname).l) & 0x7F00FFFF);
>
> I've changed it to:
>
> u.u_dirp.l = (caddr_t) ((long) (((saddr_t *) uap->linkname)->l) & 0x7F00FFFF);
>
> otherwise it won't compile. It compiles to:
>
> ldl rr2,rr8(#4)
> ldl rr4, at rr2
> and r4,#32512
> ldl _u+78,rr4
>
> is it because I added a * and changed . to ->?
Yes, but it also does not reflect the correct usage. linkname is not an saddr_t* but
an saddrt_t. And you want to assign directly the value of uap->linkname not what it
points to.
typedef union
{
caddr_t l;
struct
{
unsigned left;
unsigned right;
} half;
} saddr_t; /* segmented address with parts */
>
> > u.u_dirp = (saddr_t) (((long) uap->linkname) & 0x7F00FFFF);
>
> this generates:
> "sys2.c":305: operands of CAST have incompatible types
> "sys2.c":305: operands of "=" have incompatible types
>
> :(
My fault. That's a typical beginner's mistake I made there. I'm starting
to feel embarrassed of so many mistakes I'm making lately. BTW, I'm on a
deadline so most probably my mind is not 100% in place so do not take me
too seriously specially when dealing with complex abstract data types.
That is because an saddr_t is a union. You cannot assign directly to a
union (u.u_dirp), you must assign to a union member (u.u_dirp.l), but
the union member is not an saddr_t, it is a caddr_t: the correct text
would be
u.u_dirp.l = (caddr_t) (((long) uap->linkname) & 0x7F00FFFF);
which you know does not work. That is why I suggested the extra cast to
see if the compiler would be misled into using an unneeded zero-offset
assignment instruction to an auxiliary register.
u.u_dirp.l = (caddr_t) ((long) (((saddr_t) uap->linkname).l) & 0x7F00FFFF);
that should be tantamount to
u.u_dirp.l = (caddrt_t) ((long) ((caddr_t) uap->linkname) & 0x7F00FFFF);
where due to the long cast the initial caddr_t cast would be redundant
reducing to
u.u_dirp.l = (caddr_t) ((long) uap->linkname & 0x7F00FFFF);
but introducing a saddr_t cast that might fool the compiler into a
temporary assignment with a zero offset (the .l) into ldl rr4,rr2
And I still think that dividing the assignment into intermediate
instructions and looking at the assembly might shed some light into
what is going on.
>
> --
> Oliver Lehmann
> http://www.pofo.de/
> http://wishlist.ans-netz.de/
--
These opinions are mine and only mine. Hey man, I saw them first!
José R. Valverde
De nada sirve la Inteligencia Artificial cuando falta la Natural
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20080630/e747ed01/attachment.sig>
next prev parent reply other threads:[~2008-06-30 9:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 11:57 Jose R. Valverde
2008-06-04 15:11 ` Oliver Lehmann
2008-06-04 15:16 ` Oliver Lehmann
2008-06-05 15:07 ` Jose R. Valverde
2008-06-05 17:59 ` Oliver Lehmann
2008-06-05 15:17 ` Jose R. Valverde
2008-06-05 17:45 ` Oliver Lehmann
2008-06-23 14:18 ` Jose R. Valverde
2008-06-23 16:11 ` Oliver Lehmann
2008-06-25 9:40 ` Jose R. Valverde
2008-06-25 10:25 ` Jose R. Valverde
2008-06-26 14:52 ` Oliver Lehmann
2008-06-27 12:24 ` Jose R. Valverde
2008-06-29 8:25 ` Oliver Lehmann
2008-06-30 9:30 ` Jose R. Valverde [this message]
2008-06-30 17:34 ` Oliver Lehmann
2008-07-01 14:21 ` Jose R. Valverde
2008-07-01 18:35 ` Oliver Lehmann
2008-07-03 10:12 ` Jose R. Valverde
2008-07-06 16:14 ` Oliver Lehmann
2008-07-07 9:25 ` [TUHS] SysIII/PDP-11 on SIMH (was Re: Introduction) Jose R. Valverde
2008-07-07 9:32 ` [TUHS] Introduction Jose R. Valverde
2008-07-07 14:45 ` Oliver Lehmann
2008-06-06 9:58 ` Jose R. Valverde
-- strict thread matches above, loose matches on Subject: below --
2008-06-03 4:18 Oliver Lehmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080630113028.46a50360@veda.cnb.uam.es \
--to=jrvalverde@cnb.csic.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).