Help needed for small assembler script for the iraf package
Dear riscv specialists,
triggered by the recent announcement of the riscv64, I would like to get
my "IRAF" package [1] working on that platform. IRAF is a quite old (>30
years) package for astrophysics that still serves as a reference.
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.
The code for the amd64 platform is
-------------------------------8<-----------------------------------
.file "zsvjmp.s"
.text
.global zsvjmp_
.type zsvjmp_, %function
zsvjmp_:
// %rsi ... &status %rdi ... &jumpbuf
movq %rsi, (%rdi) // store &status in jmpbuf[0]
movl $0, (%rsi) // zero the value of status
addq $8, %rdi // change point to &jmpbuf[1]
movl $0, %esi // change arg2 to zero
jmp __sigsetjmp@PLT // let sigsetjmp do the rest
----------------------8<-----------------------------------
The "zdojmp" counterpart is a portable C function.
I created a small repository [2] that contains the assembler I collected
so far as well as two test programs. The function of the Fortran test
program is still not so important since IRAF uses its own Fortran
calling interface.
However, I have no idea how to write the same for the 64-bit platform
riscv64. Maybe someone could help me here? Preferably under the IRAF
license [3], so that it can be included upstream later.
Thank you for any hints!
Best regards
Ole
[1] https://tracker.debian.org/pkg/iraf
[2] https://github.com/olebole/zsvjmp
[3] https://github.com/iraf-community/iraf/blob/master/COPYRIGHT
Reply to: