h19611
s 00006/00004/00065
d D 3.3 85/06/04 19:24:00 dock 3 2
c 
e
s 00007/00007/00062
d D 3.2 85/02/13 00:27:10 dan 2 1
c System V assembler syntax update
e
s 00069/00000/00000
d D 3.1 84/11/13 16:26:58 dan 1 0
c date and time created 84/11/13 16:26:58 by dan
e
u
U
t
T
I 1
D 3
/* catch3200.S -- Catch and Throw errors for NS32000
E 3
I 3

/*
 * %M%: version %I% of %H%
 *
 * catch3200.S -- Catch and Throw errors for NS32000
E 3
 * (c) 1984  American Information Systems Corporation
D 3
 *	Daniel Steinberg
 *	November, 1984
E 3
I 3
 *	Daniel Steinberg	November, 1984
E 3
 *
 *	AIS/UNIX-System V.2  code format
D 3
 *
E 3
 *
 * This module DOES NOT save/restore floating point registers!!
 */

	.file	"catch3200.S"

#include "32032.h"
#include "RAMmonsize.m"

	.text

	.globl _catch
_catch:					/* PC of catch() on stack */
	sprd	fp,tos			/* Push FP */
	save	[r3,r4,r5,r6,r7]	/* Push non-volatile registers */
	movd	@A_cataddr,tos		/* Push last catch address */
	addr	tos,@A_cataddr		/* This stack loc is new catch addr */
D 2
	movqd	0,r0			/* Set a zero return value */
E 2
I 2
	movqd	$0,r0			/* Set a zero return value */
E 2
	jump	0(28(sp))		/* Return to caller after catch() */

	.globl _uncatch
_uncatch:				/* PC of uncatch() on stack */
	movd	tos,r0			/* Save return address of uncatch() */
	lprd	sp,@A_cataddr		/* Get address of catch frame */
	movd	tos,@A_cataddr		/* Pop old catch frame addr */
	adjspb	$-(7*4)			/* Point to stack before last catch() */
	jump	r0			/* Return to caller after uncatch() */
					/*   [same as jump 0(r0)] */


	.globl _rethrow
_rethrow:				/* PC on stack */
	movd	@A_lasthrown,r0		/* Fetch the last thrown error code */
	br	T6

	.globl _throw
_throw:					/* PC and Error Value on stack */
	movd	4(sp),r0		/* Fetch thrown error parameter */
D 2
	cmpqd	0,r0			/* A thrown zero is indistinguishable */
E 2
I 2
	cmpqd	$0,r0			/* A thrown zero is indistinguishable */
E 2
	bne	T5			/*     from the original catch() call */
D 2
	movqd	-1,r0			/* If zero thrown, set -1 */
E 2
I 2
	movqd	$-1,r0			/* If zero thrown, set -1 */
E 2
T5:	movd	r0,@A_lasthrown		/* Save error code for next rethrow() */
T6:
D 2
	cmpqd	0,@A_cataddr		/* cataddr pointing to nothing? */
E 2
I 2
	cmpqd	$0,@A_cataddr		/* cataddr pointing to nothing? */
E 2
	beq	_crash			/* Yes...crash */
	lprd	sp,@A_cataddr		/* Point SP at saved catch frame */
	movd	tos,@A_cataddr		/* Pop old catch frame into cataddr */
	restore	[r3,r4,r5,r6,r7]	/* Restore saved registers */
	lprd	fp,tos			/* Restore saved FP */
D 2
	ret	0			/* Return with thrown value in R0 */
E 2
I 2
	ret	$0			/* Return with thrown value in R0 */
E 2


	.globl _crash
D 2
_crash:	bicpsrw	PSR_I		/* disable interrupts */
E 2
I 2
_crash:	bicpsrw	$PSR_I		/* disable interrupts */
E 2
	bpt			/* KEERASH */
	br	_crash		/* Loop forever */

	.globl _brkvios
_brkvios:
	bpt			/* I hope something catches this */
D 2
	ret	0		/* return to caller */
E 2
I 2
	ret	$0		/* return to caller */
E 2

E 1
