;#define FIXARGC
;/* stuff that should make it into the library? */
;printmsg(str, arg)
;char * str;
_printmsg:
	jsr	enterfun2
;int arg;
;{
;  tprintf(str, arg);
	jsr	pushwysp4
	jsr	pushwysp4
;}
	ldy	#2
	jsr	_tprintf
;#define NOARGC;
;/* check for break key, abort if user pressed it */
;extern char BRK;
	jmp	exitfun
;#asm
;_BRK =	$11
_BRK =	$11
;#endasm
;chkbrk()
;{
;  if (BRK == 0)		/* break key not pressed? */
_chkbrk:
	jsr	enterfun0
	ldx	#0
	lda	_BRK
	jsr	pushax
;	{
	ldax	#0
	jsr	toseqax
;	closeall();		/* close all open files */
;;; falsejump
	lbeq	L2
;	BRK = -1;
	jsr	_closeall
;	printmsg("Aborted!\n", 0);
	ldax	#-1
	sta	_BRK
	ldax	#L1+0
	jsr	pushax
	jsr	push0
;	exit(0);
	jsr	_printmsg
	jsr	push0
;	}
	jsr	_exit
;}
;/* check for stack overflow */
;extern int _himem;
L2:
	jmp	exitfun
L1:
	.byte	65,98,111,114,116,101,100,33,-101,0
;chkstk()
;{
;  int dummy;
_chkstk:
	jsr	enterfun0
;  if (((int)&dummy - _himem) < 16)
	jsr	decsp2
	ldy	#0
	jsr	plocysp
	lda	__himem
	ldx	__himem+1
	jsr	subtos
	jsr	pushax
;	{
	ldax	#16
	jsr	tosltax
;	PError("!!", "Stack overflow");
;;; falsejump
	lbeq	L4
	ldax	#L3+0
	jsr	pushax
	ldax	#L3+3
	jsr	pushax
;	fatal("Giving up");
	jsr	_PError
	ldax	#L3+18
	jsr	pushax
;	}
	jsr	_fatal
;}
L4:
	jsr	incsp2
	jmp	exitfun
L3:
	.byte	33,33,0,83,116,97,99,107,32,111,118,101,114,102,108,111
	.byte	119,0,71,105,118,105,110,103,32,117,112,0
	.globl	_fatal
	.globl	_PError
	.globl	_chkstk
	.globl	__himem
	.globl	_exit
	.globl	_closeall
	.globl	_chkbrk
	.globl	_BRK
	.globl	_tprintf
	.globl	_printmsg
