/*
 File:    CFuncs.c
 Purpose: Communication with Wimp debugging utility (RISC User Vol4 No.3)
*/


/************************************************************************/
/*                                                                      */
/* Ensure that these #includes are included in the program              */
/*                                                                      */
/************************************************************************/

#include <string.h>
#include <stdio.h>
#include "os.h"

/************************************************************************/
/*                                                                      */
/* Ensure that this function (or its prototype) is included before any  */
/* function that calls it (e.g. debugvv).                               */
/*                                                                      */
/************************************************************************/

void debug(int no, char *mess)
{
  char string[20]="db$mess";
  char null[20]="XX";
  int len,R0,R1;
  R0=(int) string;
  R1=(int) null;
  os_swi6(0x24,R0,R1,0,0,0,0);
  len=strlen(string);
  string[len]=no+48;
  string[len+1]='\0';
  R0=(int) string;
  R1=(int) mess;
  os_swi6(0x24,R0,R1,0,0,0,0);
}

/************************************************************************/
/*                                                                      */
/* If the following function is used, ensure that it (or its prototype) */
/* is included before any function that calls it.                       */
/*                                                                      */
/************************************************************************/

void debugvv(int no, char *var,int val)
{
  char temp[100];
  sprintf(temp,"%-14.14s %10d",var,val);
  debug(no,temp);
}

/* end of CFuncs */
