HP3000-L Archives

March 1999, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Roy Buzdor <[log in to unmask]>
Reply To:
Roy Buzdor <[log in to unmask]>
Date:
Wed, 3 Mar 1999 10:23:56 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (69 lines)
Ted Ashton wrote:
>
> Thus it was written in the epistle of Frank McConnell,
> >
> > At least for SPL on the classic (meaning I have no idea
> > how this works when Splash! and/or PA-RISC 3000s are
> > involved), when you call an intrinsic that expects a
> > word pointer but give it a byte pointer, the compiler
> > inserts an arithmetic shift right (ASR) to convert the
> > byte pointer to a word pointer (and should give you a
> > warning to tell you that it's been so helpful).  ASR
> > preserves the sign bit, so if the value of the byte
> > pointer is negative, so will be the value of the word
> > pointer.
>
> Ok, I'm confused.  At least the code seems to have tried
> to do the right thing with FREAD.  It *is* passing a word
> address or what is trying to be a word address.  I'm sorry
> for miswriting in my original post.  However this ASR vs.
> LSR thing has got me confused.  In the SPL manual (the
> December, 1976 version, p 4-3), it claims, "All addresses
> are signed, one-word integers and are treated as such in
> expressions."  However, when @WORK was negative, passing
> @WORK & ASR(1) to FREAD gave me a bounds violation, but
> passing @WORK & LSR(1) gave me good results.  From that,
> it seems that addresses are *unsigned*.

All addresses ARE "signed" in the sense that they can have
a "1" in the top bit, BUT only byte addresses should actually
have that bit there.  iirc, a negative address means that it
is in a different place on your stack (DL - DB) which a
normal program does not have access to.  If it is a BYTE
address, it is always a positive address (can be > 32K) and
it is divided by 2 to get the word address, which then should
always be less than 32K, and is accessible.

The problem comes between arithmetic shift and logical shift.
An arithmetic shift preserves the sign (so that -4/2 = -2,
not 32766) where as a logical shift moves the bits, and puts
a zero in at the top.

When you take a byte address > 32K, it is interpreted as a
negative number, and when you do an arithmetic shift, it
preserves that sign bit, such that it still looks like a
negative number (-4/2 = -2) and while that IS a valid address,
it is not one that can be accessed in a normal program.

--

Buz          (8

+--------------------------------------------------------------+
|  Knowledge is proud that it has learn'd so much;             |
|  Wisdom is humble that it knows no more.                     |
|    -- William Cooper: _The Task VI_                          |
+---------------------------------------+----------------------+
| This is official written notice:      | My real address is:  |
|   Please remove me from your mailing  |   lnuslad dot dzvg41 |
|   list.                               |    at eds dot com    |
+---------------------------------------+----------------------+
.
.
.
.
.
.
.
.

ATOM RSS1 RSS2