IIRC, there was once a change in IBM hardware that changed alignment rules,
but old code would still execute apparently without problems. When I
enquired how this was done, I was told the system got an alignment error
interrupt (ie moving a 32bit entity on a 16bit boundary), did a byte move
instead, and returned to the next instruction as though nothing unusual had
occurred.....
jp
----- Original Message -----
From: "Ken Hirsch" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Wednesday, November 19, 2003 7:22 AM
Subject: Re: [HP3000-L] Traps hp3000 <> linux/unix
> I'm having a hard time figuring out a situation where resuming execution
> would be a good idea. Could you explain what you're trying to do?
>
> Ken
>
> ----- Original Message -----
> From: "Keven Miller" <[log in to unmask]>
> To: <[log in to unmask]>
> Sent: Tuesday, November 18, 2003 3:07 PM
> Subject: Re: [HP3000-L] Traps hp3000 <> linux/unix
>
>
> > Below, I am sharing my alignment test program, C1C.
> > Under MPE, I compile with CCOPTS = -Aa -C +e +w1
> > On HPUX 11i, using gcc 3.2.1,
> > gcc -g -fshort-enums -Wl,-z -Wl,+s -Wl,-n -o c1 c1.c
> >
> > On MPE, using xcodetrap, I can trap the alignment error, and return to
the
> > program
> > code to continue running.
> >
> > But on unix, I can trap the alignment error, but am not able to continue
> > with the program.
> >
> >
> > MPE appears to return execution to the instruction after the one that
> issued
> > the trap.
> >
> > But on hpux, if I un-comment the re-setting of the signal trap in the
> > sigtrap procedure,
> > it appears to re-execute the same instuction that trapped the first
time,
> > and now loops on the
> > trap.
> >
> >
> > /*----------------------------------------------------------------*/
> > #pragma list off
> > #include <stdio.h>
> > #include <signal.h>
> >
> > #ifdef __mpexl
> > # define GCC_ALIGN(x)
> > # define I16H(x) (i16h*) x
> > # define I32H(x) (i32h*) x
> > # define I16B(x) (i16b*) x
> > # define I32B(x) (i32b*) x
> > #else
> > # define GCC_ALIGN(x) __attribute__ ((aligned (x)))
> > # define I16H(x) ((i16h_t*)x)->value
> > # define I32H(x) ((i32h_t*)x)->value
> > # define I16B(x) ((i16b_t*)x)->value
> > # define I32B(x) ((i32b_t*)x)->value
> > #endif
> >
> > typedef short i16;
> > typedef int i32;
> >
> > #pragma HP_ALIGN MPE_16 PUSH
> >
> > typedef short i16h GCC_ALIGN(2);
> > typedef int i32h GCC_ALIGN(2);
> >
> > #pragma HP_ALIGN NOPADDING
> >
> > typedef short i16b GCC_ALIGN(1);
> > typedef int i32b GCC_ALIGN(1);
> >
> > #pragma HP_ALIGN POP
> >
> > typedef struct { i16h value; } i16h_t;
> > typedef struct { i32h value; } i32h_t;
> > typedef struct { i16b value; } i16b_t;
> > typedef struct { i32b value; } i32b_t;
> >
> > /*----------------------------------------------------------------*/
> > #ifdef __mpexl
> > typedef struct {
> > unsigned int inst;
> > unsigned int offset;
> > unsigned int space;
> > int err;
> > } codetrap_t;
> >
> > void cdetrap ( codetrap_t* trap )
> > {
> > printf ( "Trap %d ", trap->err );
> > }
> > #else
> >
> > void sigtrap ( int sig )
> > {
> > printf ( "Trap %d \n", sig );
> > /* signal ( SIGBUS, sigtrap );*/ /* reset signal trap*/
> > }
> > #endif
> > /*----------------------------------------------------------------*/
> > int main ()
> > {
> > int x, inc;
> > char data [50];
> > char *cp;
> > i16b *sp;
> > i32b *ip;
> > i16h *shp;
> > i32h *ihp;
> >
> > setvbuf ( stdout, 0, _IOLBF, 0 );
> > #ifdef __mpexl
> > XCODETRAP ( cdetrap, &x );
> > #else
> > signal ( SIGBUS, sigtrap );
> > #endif
> >
> > for ( x = 0; x < sizeof (data); ++x )
> > data [x] = x + ' ';
> >
> > inc = 5;
> >
> > printf ( "Chars at %d\n", inc );
> > cp = data;
> > while ( cp < &data[sizeof(data)] )
> > {
> > printf ( "%8.8x: %5.5s\n", cp, cp );
> > cp = &cp[inc];
> > }
> >
> > printf ( "Shorts B\n" );
> > cp = data;
> > sp = (i16b*)(cp);
> > while ( cp < &data[sizeof(data)] )
> > {
> > printf ( "%8.8x: %2.2s %d\n", cp, cp, I16B(sp) );
> > cp = &cp[inc];
> > sp = (i16b*)(cp);
> > }
> >
> > printf ( "Shorts H\n" );
> > cp = data;
> > shp = (i16h*)(cp);
> > while ( cp < &data[sizeof(data)] )
> > {
> > printf ( "%8.8x: %2.2s %d\n", cp, cp,
> > #ifdef __mpexl
> > *shp );
> > #else
> > ( ((int)cp & 1) ? 0 : I16H(shp)) );
> > #endif
> > cp = &cp[inc];
> > shp = (i16h*)(cp);
> > }
> >
> > printf ( "Integers B\n" );
> > cp = data;
> > ip = (i32b*)(cp);
> > while ( cp < &data[sizeof(data)] )
> > {
> > printf ( "%8.8x: %4.4s %d\n", cp, cp, I32B(ip) );
> > cp = &cp[inc];
> > ip = (i32b*)(cp);
> > }
> >
> > printf ( "Integers H\n" );
> > cp = data;
> > ihp = (i32h*)(cp);
> > while ( cp < &data[sizeof(data)] )
> > {
> > printf ( "%8.8x: %4.4s %d\n", cp, cp,
> > #ifdef __mpexl
> > *ihp );
> > #else
> > ( ((int)cp & 1) ? 0 : I32H(ihp)) );
> > #endif
> > cp = &cp[inc];
> > ihp = (i32h*)(cp);
> > }
> > }
> >
> > * To join/leave the list, search archives, change list settings, *
> > * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|