HP3000-L Archives

October 1995, Week 4

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:
Stan Sieler <[log in to unmask]>
Reply To:
Stan Sieler <[log in to unmask]>
Date:
Fri, 27 Oct 1995 17:15:05 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (106 lines)
Dan writes:
>
>   I32               CA      I16V
> dbineqv:=DBINARY(dasciieqv,length);
>
> If dbineqv is an element of a double array, the condition code of the call
> appears to sometimes get corrupted. It never seems to happen otherwise.
>
> I believe this might be because SPL may be doing pointer fixup math on the
> double array and therefore invalidating the condition code. If this is truly
> the case, then my guess is it's possible for this to happen with any
> intrinsic which returns an I32 (although I have not yet tested this).
>
> Can anyone confirm this? Is it a bug or a feature? >BD
 
It's a feature.  SPL isn't doing pointer fixup math, it's the fault of
the (presumed) loading of the index of your array.  If the index is a
variable, not a constant, then SPL emits code something like:
 
    LDX   DB 001
 
The LDX instruction, like all loads from memory, sets the condition code
to indicate something useful.  In the case of 16/32 bit loads, the condition
code is set to reflect the sign of the value (negative, zero, positive).
 
The basic problem is that most users assume that condition codes are set
only by procedures ... in fact, you can argue that procedures never set
the condition code at all!  Instead, the exiting of a procedure (via the
EXIT instruction) *restores* the condition code to the value that it had
at the instant the PCAL instruction was executed.  The poor little EXIT
instruction has no idea that the programmers of DBINARY, FOPEN, or any
other intrinsic that sets the condition code, actually went out of their
way to change the saved value of the condition code in the stack marker!
 
So, here's a solution to your problem:
 
   double
      temp'd;
 
   temp'd := dbinary (...);
   if <> then
      ...
   dbineqv := temp'd;
 
 
Here's an example test program:
 
   begin
 
   double array
      matrix         (0 : 9);
 
   integer
      inx,
      len;
 
   logical array
      buf            (0 : 39);
 
   byte array
      buf'           (*) = buf;
 
   intrinsic
      dascii,
      dbinary,
      print;
 
   len := move buf' := "123";
 
   $control innerlist
 
   inx := 2;
 
   matrix (inx) := dbinary (buf', len);         ! "incorrect" example
 
    <<------------------------------------------------
                     00015    DZRO, NOP             000700     01.05
                     00016    LOAD  DB 004          041004     02.65
                     00017    LOAD  DB 002          041002     02.65
                     00020    PCAL,000              000000     14.90
                     00021    LDX   DB 001          131001     02.65
                              ^^^^^^^^^^^^^
                     00022    STD   DB 000,I,X      167000     04.40
    ------------------------------------------------->>
 
   $control nolist            ! can't say:  $control noinnerlist  :(
 
   if < then
      print (buf, - move buf' := "got ccL", 0)
   else if > then
      print (buf, - move buf' := "got ccG", 0)
   else
      begin
      len := move buf' := "ok, got: ";
      len := len + dascii (matrix (2), 10, buf' (len));
      print (buf, -len, 0);
      end;
 
   end.
 
 
 
--
Stan Sieler                                          [log in to unmask]
                                     http://www.allegro.com/sieler.html

ATOM RSS1 RSS2