/* runtime.c
   L. Stewart November 8, 1982  1:56 PM
   Swinehart, July 17, 1982  4:21 PM, rudimentary CallSwat
   C runtime library
   L. Stewart November 8, 1982  5:15 PM, CallSwat now CallDebugger
 */

#include <Env.h>
#include <Lark.h>
#include <Context.h>

extern SetTmr();
extern int TmrExp();
extern int FetchW();
extern CallDebugger();

/* compare two strings without regard to case */
int EqStr(s1, s2)
  char *s1, *s2;
  {
  while (*s1 != 0) if (LC(*s1++) != LC(*s2++)) return(false);
  if (*s2 != 0) return (false);
  return(true);
  };

int IsDigit(c)
  char c;
  {
  if (c >= '0' && c <= '9') return(true);
  else return(false);
  };

int LC(c)
  char c;
  {
  if (c >= 'A' && c <= 'Z') c = c - 'A' + 'a';
  return (c);
  };

int UC(c)
  char c;
  {
  if (c >= 'a' && c <= 'z') c = c - 'a' + 'A';
  return (c);
  };

CallSwat(code)
  int code;
  {
  CallDebugger(code);
  };

Timer(t)
  int t[];
  {
  t[1] = FetchW(clkhi);
  t[0] = FetchW(clklo);
  if (t[1] != FetchW(clkhi)) Timer(t);
  };

Dismiss(ms)
  int ms;
  {
  int tmr;
  SetTmr(ms, &tmr);
  while (!TmrExp(&tmr)) Block();
  };