; setjmp.s - from the mintlib

	.text
	.even
	.globl _setjmp
_setjmp:
	move.l	4(sp),a0		; address of jmp_buf[]
	move.l	(sp),(a0)		; save return address
	movem.l	d2-d7/a2-a7,4(a0)	; save registers d2-d7/a2-a7
	clr.l	d0			; return value is 0
	rts

	.globl _longjmp
	.globl ___mint

_longjmp:
	tst.w	___mint			; see if MiNT is active
	beq	NOMINT			; no -- do not call sigreturn
	move.w	#$11a,-(sp)		; Psigreturn() system call
	trap	#1			; (ignored if not in a sig handler)
	addq.w	#2,sp
NOMINT:
	move.l	4(sp),a0		; address of jmp_buf[]
	move.w	8(sp),d0		; value to return
	bne	L1			; may not be 0
	move.l	#1,d0
L1:
	movem.l	4(a0),d2-d7/a2-a7	; restore saved reggies
	move.l	(a0),(sp)		; and the saved return address
	rts
