From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- unix/mc68000/zsvjmp.ISI | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 unix/mc68000/zsvjmp.ISI (limited to 'unix/mc68000/zsvjmp.ISI') diff --git a/unix/mc68000/zsvjmp.ISI b/unix/mc68000/zsvjmp.ISI new file mode 100644 index 00000000..0e7de609 --- /dev/null +++ b/unix/mc68000/zsvjmp.ISI @@ -0,0 +1,52 @@ +/* + * ZSVJMP, ZDOJMP -- Set up a jump (non-local goto) by saving the processor + * registers in the buffer jmpbuf. A subsequent call to ZDOJMP restores + * the registers, effecting a call in the context of the procedure which + * originally called ZSVJMP, but with the new status code. These are Fortran + * callable procedures. + * + * (ISI/UNIX version for the MC68000) + */ + + .text + .globl _zsvjmp_ + .globl _zdojmp_ + + /* The following has nothing to do with ZSVJMP, and is included here + * only because this assembler module is loaded with every process. + * This code sets the value of the symbol MEM (the Mem common) to zero, + * setting the origin for IRAF pointers to zero rather than some + * arbitrary value, and ensuring that the MEM common is aligned for + * all datatypes as well as page aligned. A further advantage is that + * references to NULL pointers will cause a memory violation. + */ + + .globl _mem_ + .set _mem_, 0 + + .set JMPBUF, 4 + .set STATUS, 8 + .set REGMASK, 0xfcfc /* D2-D7,A2-A5,A6,A7=sp */ + +_zsvjmp_: + movl sp@(JMPBUF),a0 /* set A0 to point to jmpbuf */ + movl sp@(STATUS),a1 /* A1 = status variable */ + movl a1,a0@ /* JB[1] = addr of status variable */ + clrl a1@ /* status = 0 */ + movl sp@+,a1 /* A1 = return address */ + movl a1,a0@(4) /* JB[3] = return address for longjmp */ + moveml #REGMASK,a0@(8) /* save register */ + jmp a1@ /* return from subroutine */ + +_zdojmp_: + movl sp@(STATUS),a0 + movl a0@,d0 /* D0 = status value */ + bne L1 /* branch if not equal to zero */ + moveq #1,d0 /* status must be nonzero */ +L1: + movl sp@(JMPBUF),a0 /* set A0 to point to jmpbuf */ + movl a0@,a1 /* get addr of zsvjmp status variable */ + movl d0,a1@ /* set the status value */ + moveml a0@(8),#REGMASK /* restore registers */ + movl a0@(4),a1 /* get return address of zsvjmp */ + jmp a1@ /* return from zsvjmp */ -- cgit