diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /unix/as.linuxppc | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'unix/as.linuxppc')
-rw-r--r-- | unix/as.linuxppc/README | 68 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrb.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrc.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrd.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclri.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrl.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrr.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/aclrs.c | 16 | ||||
-rw-r--r-- | unix/as.linuxppc/amovc.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/amovd.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/amovi.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/amovl.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/amovr.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/amovs.c | 17 | ||||
-rw-r--r-- | unix/as.linuxppc/bytmov.c | 23 | ||||
-rw-r--r-- | unix/as.linuxppc/ieee.gx | 420 | ||||
-rw-r--r-- | unix/as.linuxppc/ieeed.x | 355 | ||||
-rw-r--r-- | unix/as.linuxppc/ieeer.x | 385 | ||||
-rw-r--r-- | unix/as.linuxppc/zsvjmp.s | 112 | ||||
-rw-r--r-- | unix/as.linuxppc/zz.c | 10 | ||||
-rw-r--r-- | unix/as.linuxppc/zzdebug.c | 48 |
21 files changed, 1635 insertions, 0 deletions
diff --git a/unix/as.linuxppc/README b/unix/as.linuxppc/README new file mode 100644 index 00000000..d19b2a3e --- /dev/null +++ b/unix/as.linuxppc/README @@ -0,0 +1,68 @@ +# LinuxPPC Assembler - LinuxPPC 2000, Aug 2000 + + .file "zz.c" +# zsvjmp_(buf,status) +# int *buf; +# int *status; +# { +# *status = 0; +# buf[0] = *status; +# setjmp (&buf[1]); +# } + +gcc2_compiled.: + .section ".text" + .align 2 + .globl zsvjmp_ + .type zsvjmp_,@function + + # Addressing: 12(31) means effective address (EA) is r31+12 + # lwz 9,12(31) means move value at EA to r9 + + # REGISTERS: r1 = stack pointer, r31 = frame pointer, r3+ = args + # Function always saves r1, r31 on stack. Sets up frame with + # required auto storage. Saves LR as well if any functions will + # be called. + +zsvjmp_: + # -- Push old r1 on stack; start new stack frame at r1 + stwu 1,-32(1) # Store word with update (push on stack) + # EA = r1-32; (r1) -> (EA), EA -> r1 + + # -- Save LR, r31 in stack frame + mflr 0 # Move from Link Register: LR -> r0 + stw 31,28(1) # Store word: r31 -> r1+28 + stw 0,36(1) # Store word: r0 -> r1+36 + + # -- Save r3 (arg1), r4 (arg2) on stack + mr 31,1 # Move register: r1 -> r31 + stw 3,8(31) # r3 -> r31+8 + stw 4,12(31) # r4 -> r31+12 + + # -- *status = 0; + lwz 9,12(31) # Load word and zero: (r31+12) -> r9 + li 0,0 # Load zero: 0 -> r0 + stw 0,0(9) # Store: r0 -> r9+0 + + # -- buf[0] = *status; + lwz 9,8(31) # buf -> r9 + lwz 11,12(31) # status -> r11 + lwz 0,0(11) # *status -> r0 + stw 0,0(9) # r0 -> buf[0] + + # -- setjmp (&buf[1]); + lwz 9,8(31) # buf -> r9 + addi 0,9,4 # Add immediate; r9+4 -> r0 + mr 3,0 # R3 is first arg + crxor 6,6,6 # Condition reg XOR: xor(b6,b6) -> b6 + bl setjmp # Branch to setjmp; addr(.L2) -> LR +.L2: + lwz 11,0(1) # load old r1 into r11 + lwz 0,4(11) # load old LR into r0 + mtlr 0 # restore return addr to LR + lwz 31,-4(11) # restore old r31 + mr 1,11 # restore old r1 + blr # Branch unconditionally (to LR addr) +.Lfe1: + .size zsvjmp_,.Lfe1-zsvjmp_ + .ident "GCC: (GNU) 2.95.2 19991024 (release/franzo)" diff --git a/unix/as.linuxppc/aclrb.c b/unix/as.linuxppc/aclrb.c new file mode 100644 index 00000000..8c03c7a1 --- /dev/null +++ b/unix/as.linuxppc/aclrb.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRB -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRB (a, n) +XCHAR *a; +XINT *n; +{ + memset ((char *)a, 0, *n); +} diff --git a/unix/as.linuxppc/aclrc.c b/unix/as.linuxppc/aclrc.c new file mode 100644 index 00000000..04e0e19b --- /dev/null +++ b/unix/as.linuxppc/aclrc.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRC -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRC (a, n) +XCHAR *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/aclrd.c b/unix/as.linuxppc/aclrd.c new file mode 100644 index 00000000..0cf06b01 --- /dev/null +++ b/unix/as.linuxppc/aclrd.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRD -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRD (a, n) +XDOUBLE *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/aclri.c b/unix/as.linuxppc/aclri.c new file mode 100644 index 00000000..7d5b8ada --- /dev/null +++ b/unix/as.linuxppc/aclri.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRI -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRI (a, n) +XINT *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/aclrl.c b/unix/as.linuxppc/aclrl.c new file mode 100644 index 00000000..91f2a0ef --- /dev/null +++ b/unix/as.linuxppc/aclrl.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRL -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRL (a, n) +XLONG *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/aclrr.c b/unix/as.linuxppc/aclrr.c new file mode 100644 index 00000000..0426aa73 --- /dev/null +++ b/unix/as.linuxppc/aclrr.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRR -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRR (a, n) +XREAL *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/aclrs.c b/unix/as.linuxppc/aclrs.c new file mode 100644 index 00000000..b4ff02a4 --- /dev/null +++ b/unix/as.linuxppc/aclrs.c @@ -0,0 +1,16 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* ACLRS -- Clear a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +ACLRS (a, n) +XSHORT *a; +XINT *n; +{ + memset ((char *)a, 0, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovc.c b/unix/as.linuxppc/amovc.c new file mode 100644 index 00000000..ecba2573 --- /dev/null +++ b/unix/as.linuxppc/amovc.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVC -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVC (a, b, n) +XCHAR *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovd.c b/unix/as.linuxppc/amovd.c new file mode 100644 index 00000000..0cfa8906 --- /dev/null +++ b/unix/as.linuxppc/amovd.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVD -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVD (a, b, n) +XDOUBLE *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovi.c b/unix/as.linuxppc/amovi.c new file mode 100644 index 00000000..91bc2060 --- /dev/null +++ b/unix/as.linuxppc/amovi.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVI -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVI (a, b, n) +XINT *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovl.c b/unix/as.linuxppc/amovl.c new file mode 100644 index 00000000..815fd651 --- /dev/null +++ b/unix/as.linuxppc/amovl.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVL -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVL (a, b, n) +XLONG *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovr.c b/unix/as.linuxppc/amovr.c new file mode 100644 index 00000000..94522ea6 --- /dev/null +++ b/unix/as.linuxppc/amovr.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVR -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVR (a, b, n) +XREAL *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/amovs.c b/unix/as.linuxppc/amovs.c new file mode 100644 index 00000000..8aa12ae7 --- /dev/null +++ b/unix/as.linuxppc/amovs.c @@ -0,0 +1,17 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* AMOVS -- Copy a block of memory. + * [Specially optimized for Sun/IRAF]. + */ +AMOVS (a, b, n) +XSHORT *a, *b; +XINT *n; +{ + if (a != b) + memmove ((char *)b, (char *)a, *n * sizeof(*a)); +} diff --git a/unix/as.linuxppc/bytmov.c b/unix/as.linuxppc/bytmov.c new file mode 100644 index 00000000..aa43f6d1 --- /dev/null +++ b/unix/as.linuxppc/bytmov.c @@ -0,0 +1,23 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#define import_spp +#define import_knames +#include <iraf.h> + +/* BYTMOV -- Byte move from array "a" to array "b". The move must be + * nondestructive, allowing a byte array to be shifted left or right a + * few bytes, hence comparison of the addresses of the arrays is necessary + * to determine if they overlap. + * [Specially optimized version for Sun/IRAF]. + */ +BYTMOV (a, aoff, b, boff, nbytes) +XCHAR *a; /* input byte array */ +XINT *aoff; /* first byte in A to be moved */ +XCHAR *b; /* output byte array */ +XINT *boff; /* first byte in B to be written */ +XINT *nbytes; /* number of bytes to move */ +{ + if ((a + *aoff) != (b + *boff)) + memmove ((char *)b + (*boff-1), (char *)a + (*aoff-1), *nbytes); +} diff --git a/unix/as.linuxppc/ieee.gx b/unix/as.linuxppc/ieee.gx new file mode 100644 index 00000000..61a7caf0 --- /dev/null +++ b/unix/as.linuxppc/ieee.gx @@ -0,0 +1,420 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <mach.h> + +.help IEEE +.nf ------------------------------------------------------------------------ +Low level primitives for IEEE to native floating point datatype conversions. +See also the MII package, which provides a higher level interface, and the +IEEE related definitions in <mach.h>. + + ieepak[rd] (datum) # scalar conversions + ieeupk[rd] (datum) + ieevpak[rd] (native, ieee, nelem) # vector conversions + ieevupk[rd] (ieee, native, nelem) + iee[sg]nan[rd] (NaN) # NaN handling + iee[sg]map[rd] (mapin, mapout) + ieestat[rd] (nin, nout) + ieezstat[rd] () + +The first two routines handle scalar conversions, the second two routines +vector conversions. The input and output vectors may be the same. +Unfortunately, for portability reasons, functions cannot be used, so the +scalar operators do an in-place conversion instead, and are a no-op on an +unswapped IEEE system. The routines iee[sg]nan[rd] set/get the native +floating value used to replace NaNs or overflows occuring when converting +IEEE to the native floating format (any floating value will do, e.g., zero or +INDEF). If NaN mapping is enabled, the ieestat[rd] routines may be used to +determine the number of input or output NaN conversions occuring since the +last call to ieezstat[rd]. + +The NaN mapping enable switch and statistics counters are UNDEFINED at +process startup; programs which use the IEEE conversion package should call +ieesmap[rd] to enable or disable NaN mapping, and ieezstat[rd] to initialize +the statistics counters. + +The routines in this file are the "portable" versions. The "portable" +solution it to merely copy the array, swapping the bytes if necessary - this +works on any host that uses the IEEE floating format. NaN mapping is +implemented in the portable code, but will work properly only for input +conversions; for output, the IEEE NaN value is undefined in the portable +version of the code (it is trivial to supply this value in an as$ieee.gx +version of the code). +If the local host does +not use IEEE floating, or if a significant efficiency gain can be realized +by programming in assembler or C, a host specific version of this file should +be written, placed in AS, and referenced in the MKPKG special file list. +.endhelp ------------------------------------------------------------------- + + +# Give the generic preprocessor some help. +$if (datatype == r) +define IEEE_SWAP IEEE_SWAP4 +define BSWAP bswap4 +define NSWAP 4 +define IOFF 1 +$else +define IEEE_SWAP IEEE_SWAP8 +define BSWAP bswap8 +define NSWAP 8 +define IOFF 2 # MACHDEP (normally 1, 2 on e.g. Intel) +$endif + + +# IEEVPAK -- Convert an array in the native floating point format into an +# array in IEEE floating format. The input and output arrays can be the same. + +procedure ieevpak$t (native, ieee, nelem) + +PIXEL native[ARB] #I input native floating format array +PIXEL ieee[ARB] #O output IEEE floating format array +int nelem #I number of floating point numbers + +int i +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout == NO) { + if (IEEE_SWAP == YES) + call BSWAP (native, 1, ieee, 1, nelem * NSWAP) + else + call amov$t (native, ieee, nelem) + } else { + call ieee_sigmask() + do i = 1, nelem + if (native[i] == native_NaN) { + ieee(i) = ieee_NaN + nout = nout + 1 + } else + ieee[i] = native[i] + + # Byteswap if necessary. + if (IEEE_SWAP == YES) + call BSWAP (ieee, 1, ieee, 1, nelem * NSWAP) + call ieee_sigrestore() + } +end + + +# IEEVUPK -- Convert an array in IEEE floating format into the native +# floating point format. The input and output arrays can be the same. + +procedure ieevupk$t (ieee, native, nelem) + +PIXEL ieee[ARB] #I input IEEE floating format array +PIXEL native[ARB] #O output native floating format array +int nelem #I number of floating point numbers + +int expon, i +$if (datatype == r) +real fval +int ival[1] +% equivalence (fval, ival) +$else +double fval +int ival[2] +% equivalence (fval, ival) +$endif + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + + if (IEEE_SWAP == YES) { + call BSWAP (ieee, 1, native, 1, nelem * NSWAP) + if (mapin != NO) { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = native[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } + } + call ieee_sigrestore() + } + } else { + if (mapin == NO) + call amov$t (ieee, native, nelem) + else { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = ieee[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } else + native[i] = ieee[i] + } + call ieee_sigrestore() + } + } + + +end + + +# IEEPAK -- Convert a native floating point number into IEEE format. + +procedure ieepak$t (x) + +PIXEL x #U datum to be converted + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout != NO) { + call ieee_sigmask() + if (x == native_NaN) { + x = ieee_NaN + nout = nout + 1 + } + call ieee_sigrestore() + } + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) +end + + +# IEEUPK -- Convert an IEEE format number into native floating point. + +procedure ieeupk$t (x) + +PIXEL x #U datum to be converted + +int expon +$if (datatype == r) +real fval +int ival[1] +% equivalence (fval, ival) +$else +double fval +int ival[2] +% equivalence (fval, ival) +$endif + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) + + # Check for IEEE exceptional values and map NaN to the native NaN + # value, and denormalized numbers (zero exponent) to zero. + + if (mapin != NO) { + call ieee_sigmask() + fval = x + expon = and (ival[IOFF], NaNmask) + if (expon == 0) + x = 0 + else if (expon == NaNmask) { + x = native_NaN + nin = nin + 1 + } + call ieee_sigrestore() + } +end + + +# IEESNAN -- Set the native floating point value used to replace NaNs and +# overflows when converting IEEE to native. This must be a legal (finite) +# native floating point value. + +procedure ieesnan$t (x) + +PIXEL x #I native value which will replace NaN + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + native_NaN = x + nin = 0 + nout = 0 +end + + +# IEEGNAN -- Get the NaN value. + +procedure ieegnan$t (x) + +PIXEL x #O native value which will replace NaN + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + x = native_NaN +end + + +# IEESTAT -- Return statistics on the number of NaNs encountered in input +# conversions (unpack) and output conversions (pack). + +procedure ieestat$t (o_nin, o_nout) + +int o_nin #O number of NaN seen on input +int o_nout #O number of NaN values output + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + o_nin = nin + o_nout = nout +end + + +# IEEZSTAT -- Zero the statistics counters. + +procedure ieezstat$t () + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + nin = 0 + nout = 0 +end + + +# IEEMAP -- Same as IEESMAP. Retained for backwards compatibility. + +procedure ieemap$t (inval, outval) + +int inval #I enable mapping on input +int outval #I enable mapping on output + +begin + call ieesmap$t (inval, outval) +end + + +# IEEGMAP -- Query the current values of the input and output mapping +# enables. + +procedure ieegmap$t (inval, outval) + +int inval #O get input mapping enable flag +int outval #O get output mapping enable flag + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + inval = mapin + outval = mapout +end + + +# MACHINE DEPENDENT PART. +# --------------------------- + +# IEESMAP -- Enable or disable NaN mapping. +# +# sEEE EEEE Emmm mmmm mmmm mmmm mmmm mmmm +# 3 2 1 0 +# 1098 7654 3210 9876 5432 1098 7654 3210 +# 7 f 8 0 0 0 0 0 + +procedure ieesmap$t (inval, outval) + +int inval #I enable NaN mapping for input? +int outval #I enable NaN mapping for output? + +# MACHDEP. +$if (datatype == r) +real fval +int ival[1] +$else +double fval +int ival[2] +$endif + +PIXEL native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenan$t/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +$if (datatype == r) +% equivalence (fval, ival) +% data ival(1) / '7ff7ffff'x / +$else +% equivalence (fval, ival) +% data ival(1) / '7ff7ffff'x /, ival(2) /-1/ +$endif + +begin + mapin = inval + mapout = outval + + # MACHDEP. + if (mapout == YES) + ieee_NaN = fval + + if (mapin == YES) + $if (datatype == r) + NaNmask = 7F800000X + $else + NaNmask = 7FF00000X + $endif +end + + +$if (datatype == r) + +# IEEE_SIGMASK, IEEE_SIGRESTORE -- Routines for masking IEEE exceptions. +# +# ieee_sigmask() +# ieee_sigrestore() +# +# These routines are meant to be used only internally by the routines in +# this file. iee_sigmask saves the current IEEE FPU exception mask, and +# sets a new mask which masks the invalid operand exception. This is +# necessary to permit the routines in this file to handle NaN values without +# raising the IEEE invalid operand exception. iee_sigrestore restores +# the original exception mask. These routines are meant to be called as +# pairs to temporarily block the invalid operand exception within an IEEE +# conversion routine. + +procedure ieee_sigmask() +int fpucw +common /ieesig/ fpucw +begin + call gfpucw (fpucw) + call sfpucw (or (fpucw, 80X)) +end + +procedure ieee_sigrestore() +int fpucw +common /ieesig/ fpucw +begin + call sfpucw (fpucw) +end + +$endif diff --git a/unix/as.linuxppc/ieeed.x b/unix/as.linuxppc/ieeed.x new file mode 100644 index 00000000..1670fd8d --- /dev/null +++ b/unix/as.linuxppc/ieeed.x @@ -0,0 +1,355 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <mach.h> + +.help IEEE +.nf ------------------------------------------------------------------------ +Low level primitives for IEEE to native floating point datatype conversions. +See also the MII package, which provides a higher level interface, and the +IEEE related definitions in <mach.h>. + + ieepak[rd] (datum) # scalar conversions + ieeupk[rd] (datum) + ieevpak[rd] (native, ieee, nelem) # vector conversions + ieevupk[rd] (ieee, native, nelem) + iee[sg]nan[rd] (NaN) # NaN handling + iee[sg]map[rd] (mapin, mapout) + ieestat[rd] (nin, nout) + ieezstat[rd] () + +The first two routines handle scalar conversions, the second two routines +vector conversions. The input and output vectors may be the same. +Unfortunately, for portability reasons, functions cannot be used, so the +scalar operators do an in-place conversion instead, and are a no-op on an +unswapped IEEE system. The routines iee[sg]nan[rd] set/get the native +floating value used to replace NaNs or overflows occuring when converting +IEEE to the native floating format (any floating value will do, e.g., zero or +INDEFD). If NaN mapping is enabled, the ieestat[rd] routines may be used to +determine the number of input or output NaN conversions occuring since the +last call to ieezstat[rd]. + +The NaN mapping enable switch and statistics counters are UNDEFINED at +process startup; programs which use the IEEE conversion package should call +ieesmap[rd] to enable or disable NaN mapping, and ieezstat[rd] to initialize +the statistics counters. + +The routines in this file are the "portable" versions. The "portable" +solution it to merely copy the array, swapping the bytes if necessary - this +works on any host that uses the IEEE floating format. NaN mapping is +implemented in the portable code, but will work properly only for input +conversions; for output, the IEEE NaN value is undefined in the portable +version of the code (it is trivial to supply this value in an as$ieee.gx +version of the code). +If the local host does +not use IEEE floating, or if a significant efficiency gain can be realized +by programming in assembler or C, a host specific version of this file should +be written, placed in AS, and referenced in the MKPKG special file list. +.endhelp ------------------------------------------------------------------- + + +# Give the generic preprocessor some help. +define IEEE_SWAP IEEE_SWAP8 +define BSWAP bswap8 +define NSWAP 8 +define IOFF 2 # MACHDEP (normally 1, 2 on e.g. Intel) + + +# IEEVPAK -- Convert an array in the native floating point format into an +# array in IEEE floating format. The input and output arrays can be the same. + +procedure ieevpakd (native, ieee, nelem) + +double native[ARB] #I input native floating format array +double ieee[ARB] #O output IEEE floating format array +int nelem #I number of floating point numbers + +int i +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout == NO) { + if (IEEE_SWAP == YES) + call BSWAP (native, 1, ieee, 1, nelem * NSWAP) + else + call amovd (native, ieee, nelem) + } else { + call ieee_sigmask() + do i = 1, nelem + if (native[i] == native_NaN) { + ieee(i) = ieee_NaN + nout = nout + 1 + } else + ieee[i] = native[i] + + # Byteswap if necessary. + if (IEEE_SWAP == YES) + call BSWAP (ieee, 1, ieee, 1, nelem * NSWAP) + call ieee_sigrestore() + } +end + + +# IEEVUPK -- Convert an array in IEEE floating format into the native +# floating point format. The input and output arrays can be the same. + +procedure ieevupkd (ieee, native, nelem) + +double ieee[ARB] #I input IEEE floating format array +double native[ARB] #O output native floating format array +int nelem #I number of floating point numbers + +int expon, i +double fval +int ival[2] +% equivalence (fval, ival) + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + + if (IEEE_SWAP == YES) { + call BSWAP (ieee, 1, native, 1, nelem * NSWAP) + if (mapin != NO) { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = native[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } + } + call ieee_sigrestore() + } + } else { + if (mapin == NO) + call amovd (ieee, native, nelem) + else { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = ieee[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } else + native[i] = ieee[i] + } + call ieee_sigrestore() + } + } + + +end + + +# IEEPAK -- Convert a native floating point number into IEEE format. + +procedure ieepakd (x) + +double x #U datum to be converted + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout != NO) { + call ieee_sigmask() + if (x == native_NaN) { + x = ieee_NaN + nout = nout + 1 + } + call ieee_sigrestore() + } + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) +end + + +# IEEUPK -- Convert an IEEE format number into native floating point. + +procedure ieeupkd (x) + +double x #U datum to be converted + +int expon +double fval +int ival[2] +% equivalence (fval, ival) + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) + + # Check for IEEE exceptional values and map NaN to the native NaN + # value, and denormalized numbers (zero exponent) to zero. + + if (mapin != NO) { + call ieee_sigmask() + fval = x + expon = and (ival[IOFF], NaNmask) + if (expon == 0) + x = 0 + else if (expon == NaNmask) { + x = native_NaN + nin = nin + 1 + } + call ieee_sigrestore() + } +end + + +# IEESNAN -- Set the native floating point value used to replace NaNs and +# overflows when converting IEEE to native. This must be a legal (finite) +# native floating point value. + +procedure ieesnand (x) + +double x #I native value which will replace NaN + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + native_NaN = x + nin = 0 + nout = 0 +end + + +# IEEGNAN -- Get the NaN value. + +procedure ieegnand (x) + +double x #O native value which will replace NaN + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + x = native_NaN +end + + +# IEESTAT -- Return statistics on the number of NaNs encountered in input +# conversions (unpack) and output conversions (pack). + +procedure ieestatd (o_nin, o_nout) + +int o_nin #O number of NaN seen on input +int o_nout #O number of NaN values output + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + o_nin = nin + o_nout = nout +end + + +# IEEZSTAT -- Zero the statistics counters. + +procedure ieezstatd () + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + nin = 0 + nout = 0 +end + + +# IEEMAP -- Same as IEESMAP. Retained for backwards compatibility. + +procedure ieemapd (inval, outval) + +int inval #I enable mapping on input +int outval #I enable mapping on output + +begin + call ieesmapd (inval, outval) +end + + +# IEEGMAP -- Query the current values of the input and output mapping +# enables. + +procedure ieegmapd (inval, outval) + +int inval #O get input mapping enable flag +int outval #O get output mapping enable flag + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + inval = mapin + outval = mapout +end + + +# MACHINE DEPENDENT PART. +# --------------------------- + +# IEESMAP -- Enable or disable NaN mapping. +# +# sEEE EEEE Emmm mmmm mmmm mmmm mmmm mmmm +# 3 2 1 0 +# 1098 7654 3210 9876 5432 1098 7654 3210 +# 7 f 8 0 0 0 0 0 + +procedure ieesmapd (inval, outval) + +int inval #I enable NaN mapping for input? +int outval #I enable NaN mapping for output? + +# MACHDEP. +double fval +int ival[2] + +double native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenand/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +% equivalence (fval, ival) +% data ival(1) / '7ff7ffff'x /, ival(2) /-1/ + +begin + mapin = inval + mapout = outval + + # MACHDEP. + if (mapout == YES) + ieee_NaN = fval + + if (mapin == YES) + NaNmask = 7FF00000X +end + + diff --git a/unix/as.linuxppc/ieeer.x b/unix/as.linuxppc/ieeer.x new file mode 100644 index 00000000..5d308876 --- /dev/null +++ b/unix/as.linuxppc/ieeer.x @@ -0,0 +1,385 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <mach.h> + +.help IEEE +.nf ------------------------------------------------------------------------ +Low level primitives for IEEE to native floating point datatype conversions. +See also the MII package, which provides a higher level interface, and the +IEEE related definitions in <mach.h>. + + ieepak[rd] (datum) # scalar conversions + ieeupk[rd] (datum) + ieevpak[rd] (native, ieee, nelem) # vector conversions + ieevupk[rd] (ieee, native, nelem) + iee[sg]nan[rd] (NaN) # NaN handling + iee[sg]map[rd] (mapin, mapout) + ieestat[rd] (nin, nout) + ieezstat[rd] () + +The first two routines handle scalar conversions, the second two routines +vector conversions. The input and output vectors may be the same. +Unfortunately, for portability reasons, functions cannot be used, so the +scalar operators do an in-place conversion instead, and are a no-op on an +unswapped IEEE system. The routines iee[sg]nan[rd] set/get the native +floating value used to replace NaNs or overflows occuring when converting +IEEE to the native floating format (any floating value will do, e.g., zero or +INDEFR). If NaN mapping is enabled, the ieestat[rd] routines may be used to +determine the number of input or output NaN conversions occuring since the +last call to ieezstat[rd]. + +The NaN mapping enable switch and statistics counters are UNDEFINED at +process startup; programs which use the IEEE conversion package should call +ieesmap[rd] to enable or disable NaN mapping, and ieezstat[rd] to initialize +the statistics counters. + +The routines in this file are the "portable" versions. The "portable" +solution it to merely copy the array, swapping the bytes if necessary - this +works on any host that uses the IEEE floating format. NaN mapping is +implemented in the portable code, but will work properly only for input +conversions; for output, the IEEE NaN value is undefined in the portable +version of the code (it is trivial to supply this value in an as$ieee.gx +version of the code). +If the local host does +not use IEEE floating, or if a significant efficiency gain can be realized +by programming in assembler or C, a host specific version of this file should +be written, placed in AS, and referenced in the MKPKG special file list. +.endhelp ------------------------------------------------------------------- + + +# Give the generic preprocessor some help. +define IEEE_SWAP IEEE_SWAP4 +define BSWAP bswap4 +define NSWAP 4 +define IOFF 1 + + +# IEEVPAK -- Convert an array in the native floating point format into an +# array in IEEE floating format. The input and output arrays can be the same. + +procedure ieevpakr (native, ieee, nelem) + +real native[ARB] #I input native floating format array +real ieee[ARB] #O output IEEE floating format array +int nelem #I number of floating point numbers + +int i +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout == NO) { + if (IEEE_SWAP == YES) + call BSWAP (native, 1, ieee, 1, nelem * NSWAP) + else + call amovr (native, ieee, nelem) + } else { + call ieee_sigmask() + do i = 1, nelem + if (native[i] == native_NaN) { + ieee(i) = ieee_NaN + nout = nout + 1 + } else + ieee[i] = native[i] + + # Byteswap if necessary. + if (IEEE_SWAP == YES) + call BSWAP (ieee, 1, ieee, 1, nelem * NSWAP) + call ieee_sigrestore() + } +end + + +# IEEVUPK -- Convert an array in IEEE floating format into the native +# floating point format. The input and output arrays can be the same. + +procedure ieevupkr (ieee, native, nelem) + +real ieee[ARB] #I input IEEE floating format array +real native[ARB] #O output native floating format array +int nelem #I number of floating point numbers + +int expon, i +real fval +int ival[1] +% equivalence (fval, ival) + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + + if (IEEE_SWAP == YES) { + call BSWAP (ieee, 1, native, 1, nelem * NSWAP) + if (mapin != NO) { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = native[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } + } + call ieee_sigrestore() + } + } else { + if (mapin == NO) + call amovr (ieee, native, nelem) + else { + # Check for IEEE exceptional values and map NaN to the native + # NaN value, and denormalized numbers (zero exponent) to zero. + + call ieee_sigmask() + do i = 1, nelem { + fval = ieee[i] + expon = and (ival[IOFF], NaNmask) + if (expon == 0) { + native[i] = 0 + } else if (expon == NaNmask) { + native[i] = native_NaN + nin = nin + 1 + } else + native[i] = ieee[i] + } + call ieee_sigrestore() + } + } + + +end + + +# IEEPAK -- Convert a native floating point number into IEEE format. + +procedure ieepakr (x) + +real x #U datum to be converted + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (mapout != NO) { + call ieee_sigmask() + if (x == native_NaN) { + x = ieee_NaN + nout = nout + 1 + } + call ieee_sigrestore() + } + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) +end + + +# IEEUPK -- Convert an IEEE format number into native floating point. + +procedure ieeupkr (x) + +real x #U datum to be converted + +int expon +real fval +int ival[1] +% equivalence (fval, ival) + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + if (IEEE_SWAP == YES) + call BSWAP (x, 1, x, 1, NSWAP) + + # Check for IEEE exceptional values and map NaN to the native NaN + # value, and denormalized numbers (zero exponent) to zero. + + if (mapin != NO) { + call ieee_sigmask() + fval = x + expon = and (ival[IOFF], NaNmask) + if (expon == 0) + x = 0 + else if (expon == NaNmask) { + x = native_NaN + nin = nin + 1 + } + call ieee_sigrestore() + } +end + + +# IEESNAN -- Set the native floating point value used to replace NaNs and +# overflows when converting IEEE to native. This must be a legal (finite) +# native floating point value. + +procedure ieesnanr (x) + +real x #I native value which will replace NaN + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + native_NaN = x + nin = 0 + nout = 0 +end + + +# IEEGNAN -- Get the NaN value. + +procedure ieegnanr (x) + +real x #O native value which will replace NaN + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + x = native_NaN +end + + +# IEESTAT -- Return statistics on the number of NaNs encountered in input +# conversions (unpack) and output conversions (pack). + +procedure ieestatr (o_nin, o_nout) + +int o_nin #O number of NaN seen on input +int o_nout #O number of NaN values output + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + o_nin = nin + o_nout = nout +end + + +# IEEZSTAT -- Zero the statistics counters. + +procedure ieezstatr () + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + nin = 0 + nout = 0 +end + + +# IEEMAP -- Same as IEESMAP. Retained for backwards compatibility. + +procedure ieemapr (inval, outval) + +int inval #I enable mapping on input +int outval #I enable mapping on output + +begin + call ieesmapr (inval, outval) +end + + +# IEEGMAP -- Query the current values of the input and output mapping +# enables. + +procedure ieegmapr (inval, outval) + +int inval #O get input mapping enable flag +int outval #O get output mapping enable flag + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +begin + inval = mapin + outval = mapout +end + + +# MACHINE DEPENDENT PART. +# --------------------------- + +# IEESMAP -- Enable or disable NaN mapping. +# +# sEEE EEEE Emmm mmmm mmmm mmmm mmmm mmmm +# 3 2 1 0 +# 1098 7654 3210 9876 5432 1098 7654 3210 +# 7 f 8 0 0 0 0 0 + +procedure ieesmapr (inval, outval) + +int inval #I enable NaN mapping for input? +int outval #I enable NaN mapping for output? + +# MACHDEP. +real fval +int ival[1] + +real native_NaN, ieee_NaN +int mapin, mapout, nin, nout, NaNmask +common /ieenanr/ native_NaN, ieee_NaN, NaNmask, mapin, mapout, nin, nout + +% equivalence (fval, ival) +% data ival(1) / '7ff7ffff'x / + +begin + mapin = inval + mapout = outval + + # MACHDEP. + if (mapout == YES) + ieee_NaN = fval + + if (mapin == YES) + NaNmask = 7F800000X +end + + + +# IEEE_SIGMASK, IEEE_SIGRESTORE -- Routines for masking IEEE exceptions. +# +# ieee_sigmask() +# ieee_sigrestore() +# +# These routines are meant to be used only internally by the routines in +# this file. iee_sigmask saves the current IEEE FPU exception mask, and +# sets a new mask which masks the invalid operand exception. This is +# necessary to permit the routines in this file to handle NaN values without +# raising the IEEE invalid operand exception. iee_sigrestore restores +# the original exception mask. These routines are meant to be called as +# pairs to temporarily block the invalid operand exception within an IEEE +# conversion routine. + +procedure ieee_sigmask() +int fpucw +common /ieesig/ fpucw +begin + call gfpucw (fpucw) + call sfpucw (or (fpucw, 80X)) +end + +procedure ieee_sigrestore() +int fpucw +common /ieesig/ fpucw +begin + call sfpucw (fpucw) +end + diff --git a/unix/as.linuxppc/zsvjmp.s b/unix/as.linuxppc/zsvjmp.s new file mode 100644 index 00000000..c6a4fdd6 --- /dev/null +++ b/unix/as.linuxppc/zsvjmp.s @@ -0,0 +1,112 @@ +# ZSVJMP.S -- LinuxPPC version, August 2000. + + .file "zsvjmp.s" + .ident "NOAO/IRAF 21Aug2000 DCT" + .section ".text" + .align 2 + + # ZSVJMP -- SPP callable SETJMP. + + .globl zsvjmp_ + .type zsvjmp_,@function +zsvjmp_: + # R3 = buf, R4 = &status + li 11,0 # r11 = 0 + stw 11,0(4) # set *status to zero + stw 4,0(3) # store &status in buf[0] + addi 3,3,4 # reference buf[1] for sigsetjmp + li 4,0 # zero signal mask for sigsetjmp + b __sigsetjmp +.Lfe1: + .size zsvjmp_,.Lfe1-zsvjmp_ + + # Set the address of the MEM common to zero. + .globl mem_ + mem_ = 0 + + + # GFPUCW -- Get the FPU control register. + .align 2 + .globl gfpucw_ + .type gfpucw_,@function +gfpucw_: + stwu 1, -32(1) + stw 31, 28(1) + mr 31, 1 + stw 3, 8(31) + mffs 0 + stfd 0, 16(31) + lwz 0, 20(31) + mr 9, 0 + lwz 9, 8(31) + stw 0, 0(9) +.L3: + lwz 11, 0(1) + lwz 31, -4(11) + mr 1, 11 + blr +.Lfe2: + .size gfpucw_, .Lfe2-gfpucw_ + + + # SFPUCW -- Set the FPU control register. + + .align 2 + .globl sfpucw_ + .type sfpucw_,@function +sfpucw_: + stwu 1, -32(1) + stw 31, 28(1) + mr 31, 1 + stw 3, 8(31) + lis 0, 0xfff8 + stw 0, 16(31) + lwz 9, 8(31) + lwz 0, 0(9) + stw 0, 20(31) + lfd 0, 16(31) + mtfsf 255, 0 +.L4: + lwz 11, 0(1) + lwz 31, -4(11) + mr 1, 11 + blr +.Lfe3: + .size sfpucw_, .Lfe3-sfpucw_ + + + # CFPUCW -- Clear the exception flags in the FPU control register. + # So far I have not been able to find a way to make this work, at + # least with the current version of LinuxPPC. All of the instructions + # below fail, raising another SIGFPE if an exception condition is + # already present. ANY instruction involving the FPU will raise + # SIGFPE once the exception condition exists. Also, LinuxPPC + # sigaction does not block SIGFPE in the called exception handler, + # contrary to the manpage. It appears that the exception handling + # in the kernel needs to clear the exception condition but is not + # doing so. Supervisor level instructions appear to be required to + # clear the exception condition, so this has to be done in the kernel + # before the user level signal handler is called. + + .align 2 + .globl cfpucw_ + .type cfpucw_,@function +cfpucw_: + stwu 1, -32(1) + stw 31, 28(1) + mr 31, 1 + #mcrfs 0, 0 + #mtfsfi 0, 0 + #mtfsfi 3, 0 + #mtfsfi 3, 0 + #mtfsfi 5, 0 + #mtfsfb0 3 + #mtfsfb0 5 + #mtfsfb0 7 +.L5: + lwz 11, 0(1) + lwz 31, -4(11) + mr 1, 11 + blr +.Lfe4: + .size sfpucw_, .Lfe4-cfpucw_ diff --git a/unix/as.linuxppc/zz.c b/unix/as.linuxppc/zz.c new file mode 100644 index 00000000..68aa838b --- /dev/null +++ b/unix/as.linuxppc/zz.c @@ -0,0 +1,10 @@ +/* Compile with gcc -S to get demo assembler code. + */ +zsvjmp_(buf,status) +int *buf; +int *status; +{ + *status = 0; + buf[0] = *status; + setjmp (&buf[1]); +} diff --git a/unix/as.linuxppc/zzdebug.c b/unix/as.linuxppc/zzdebug.c new file mode 100644 index 00000000..81247e78 --- /dev/null +++ b/unix/as.linuxppc/zzdebug.c @@ -0,0 +1,48 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#include <stdio.h> +#define import_spp +#define import_kernel +#define import_knames +#include <iraf.h> + +/* + * ZZDEBUG -- Test program for ZSVJMP/ZDOJMP. Will return "exit status 1" + * if it runs successfully. + */ + + +int jmpbuf[LEN_JUMPBUF]; +int status; + +main() +{ + zsvjmp_((char *)jmpbuf, &status); + if (status) { + printf ("exit status %d\n", status); + exit (status); + } + + a(1); + exit (0); +} + + +a(status) +int status; +{ + ZDOJMP(jmpbuf, &status); +} + + +/* ZDOJMP -- Restore the saved processor context (non-local goto). See also + * as$zsvjmp.s, where most of the work is done. + */ +ZDOJMP (jmpbuf, status) +XINT *jmpbuf; +XINT *status; +{ + *((int *)jmpbuf[0]) = *status; + longjmp (&jmpbuf[1], *status); +} |