/*
 *  This file is part of ixemul.library for the Amiga.
 *  Copyright (C) 1994 Rafael W. Luebbert
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  $Id: debugstub.s,v 1.1 1994/06/19 15:09:38 rluebbert Exp $
 *
 *  $Log: debugstub.s,v $
# Revision 1.1  1994/06/19  15:09:38  rluebbert
# Initial revision
#
 */

#if defined(__pos__) || defined(FOR_LIBC)
#ifndef __pos__
#define __pos__
#define __AMIGA_TYPES__
#endif

#define _KERNEL
#include <ixemul.h>

#ifdef FOR_LIBC

#include "a4.h"

#undef SysBase
extern void *SysBase;
#define gb_ExecBase SysBase
static void pos_kprintf(const char *format, ...)
#else
void KPrintF(const char *format, ...)
#endif
{
  pOS_VKPrintf(format, (ULONG *)(&format + 1));
}
#endif

#if !defined(__pos__) || defined(FOR_LIBC)
asm("
	.globl	_KPrintF

KPutChar:
	movel	a6,sp@-
	movel	4:W,a6
	jsr	a6@(-516:W)
	movel	sp@+,a6
	rts

KDoFmt:
	movel	a6,sp@-
	movel	4:W,a6
	jsr	a6@(-522:W)
	movel	sp@+,a6
	rts

_KPrintF:
"
#ifdef FOR_LIBC
"
        movel   "A4(_ix_os)",d0
        cmpil   #0x704F5300,d0
        beqs    _pos_kprintf
"
#endif
"	lea	sp@(4),a1
	movel	a1@+,a0
	movel	a2,sp@-
	lea	KPutChar,a2
	jbsr	KDoFmt
	movel	sp@+,a2
	rts
");

#endif
