Dear m68k enthusiasts,
I am the maintainer of the "iraf" package [1]. Although most of the code
is portable, it needs one piece of assembler code for each platform that
provides a (sort of) setjmp for FORTRAN.
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.
As IRAF is a 40-year old package, there was already some assembler that
was used ~35 years ago [2]:
-------------------------------8<-----------------------------------
.text
.globl _zsvjmp_
JMPBUF = 4
STATUS = 8
_zsvjmp_: |# CALL ZSVJMP (JMPBUF, STATUS)
movl sp@(JMPBUF),a0 |# set A0 to point to jmp_buf
movl sp@(STATUS),a1 |# A1 = status variable
movl a1,a0@ |# JB[0] = addr of status variable
clrl a1@ |# return zero status
addql #4,sp@(JMPBUF) |# skip first cell of jmp_buf
jmp _setjmp |# let setjmp do the rest.
-------------------------------8<-----------------------------------
However, just including this does not work because assembler syntax
changed [3].
I created a small repository [4] that contains the assembler I collected
so far as well as two test programs.
As I am not familiar with m68 assembler I have no idea how to adopt the
assembler code. Maybe someone could help me here? Preferably under the
IRAF license [5], so that it can be included upstream later.
One way that worked for other platforms was to compute the C snipped
above (having the sigsetjmp function name by something else) with an
optimizing compiler.
There is no request from the users to have this ported to m68k, and I
doubt that ever will. My main motivation to get it ported is to check
the package for hidden problems on "unusual" architectures.
Best regards
Ole
[1] https://tracker.debian.org/pkg/iraf
[2]
https://github.com/iraf-community/iraf/blob/v2.16.1/unix/as.mc68020/zsvjmp.s
[3]
https://buildd.debian.org/status/fetch.php?pkg=iraf&arch=m68k&ver=2.18.1%7Erc1-3%7E2&stamp=1726682343&raw=0
[4] https://github.com/olebole/zsvjmp
[5] https://iraf-community.github.io/COPYRIGHT.html