Re: Help needed for small assembler script for the iraf package
James Cowgill <[email protected]>
| Newsgroups | gmane.linux.debian.ports.mips |
|---|---|
| Message-ID | <[email protected]> |
Hi,
On 04/01/18 10:22, Ole Streicher wrote:
> Dear MIPS specialists,
>
> I just got the "IRAF" package accepted into Debian [1]. Although the
> code is claimed to be portable, it needs a piece of assembler
> code for each platform that provides a (sort of) setjmp() to their
> Fortran variant.
>
> A "C" implementation for this looks like:
>
> #include <setjmp.h>
>
> int zsvjmp_( long *buf, long *status ) {
> *status = 0;
> ((long **)buf)[0] = status;
> return sigsetjmp ((void *)((long **)buf+1),0);
> }
>
> however this does not work, since the "sigsetjmp" call needs to be
> replaced by a jump to sigsetjmp instead.
>
> For the 32 bit platforms, I asked this already 3 years ago [2], and got
> an implementation by David Kuehling:
>
[...]
> The "zdojmp" counterpart is a portable C function.
>
> I created a small repository [3] that contains the assembler I collected
> so far as well as two test programs.
>
> However, I have no idea how to write the same for the 64-bit platform
> mips64el. Maybe someone could help me here? Preferably under the IRAF
> license [4], so that it can be included upstream later.
I think the attached code will work for all MIPS variants (32-bit and
64-bit). To do this it uses some headers from glibc and therefore needs
to be compiled using "gcc" instead of "as" (arguably userspace apps
should never use "as" directly anyway).
Thanks,
James
zsvjmp-mips.S
(text/plain, 647 B)
#include <sys/asm.h> #include <sys/regdef.h> /* * Copyright (c) 2018 James Cowgill <jcowgill AT debian TOD org> * Distributable under the same license as IRAF */ .file "zsvjmp.s" .text LEAF(zsvjmp_) SETUP_GP /* Load gp (needed for PTR_LA) */ SETUP_GP64(v0, zsvjmp_) PTR_S a1, 0(a0) /* buf[0] = status */ LONG_S zero, 0(a1) /* *status = 0 */ PTR_ADDIU a0, a0, PTRSIZE /* a0 = &buf[1], 1st arg for sigsetjmp */ move a1, zero /* a1 = 0, 2nd arg */ PTR_LA t9, __sigsetjmp /* t9 = address of sigsetjmp */ RESTORE_GP64 /* Restore gp */ jr t9 /* Tail call sigsetjmp */ END(zsvjmp_) .section .note.GNU-stack,"",@progbits
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE+Ixt5DaZ6POztUwQx/FnbeotAe8FAlpOLjsACgkQx/Fnbeot Ae9OPRAAtbZ1kintqGRwDlC34f4NoehQkAku++JEnYNhkj+cLV3T+5PcCxiXk7Pe gCC0/WCPB6kzAOLifdHmcuGt/YHW5Yax0K6oh4olL1D7M3cu2Gq0xXznBbPGz3rG q6oh1wNrwRJUjdXbtpf8/ZPW5zpnql5I90xIp5iG5gxrxQDJLx/mpT9oEY0jgtMQ 1OPkYPSKc9uji48MbMCBIatEBYw8dhrpD8MnUhl199Y8+989qN7yBfcseTQue8ph HyittIRipCrkHaDzT+RC1Fh3zvMku0QSYSLBni4CW7meCm23L2ur0mpF/yXtS+w2 i1KzW2b/FemGNDeDjiTgGW8eL8eEVVPh+iMJ7DIRART2vtl8puuk8SZ/T661BLIa heKCUwbaeHEDsd71gXx4waq8fRd8fOYsWMcvDAbWcLvj+MfVR6PRwzcX0vFcmjle XHGPX4ZYL5YfHVNno27iFe5y0KM1Diqh4hOq164m+rmOt8VnlpVznQxpke8juclc PZ25L4Wb3/XPUwwLGMk+tr3VbB1l35L5ZxuUCAzZ3k3BIcCJN4MPbi4PZmOSRQUD a0PsdUAYaq0/eySoB2ij/k/1SWYF/S2yhuSdKfp9KbCNa2YjJt4ZPfaWD01m4PXf telMjL7DSSJwRK8W9FJ3orrw0jYdvYvI/rbSC7o6+afSdhLwAS8= =YATS -----END PGP SIGNATURE-----