// SDB-CGEN V2.6.2
#include <ctype.h>
#include <stdio.h>
#include <string.h>

struct kv { const char *name; const char *value; };
static const struct kv kvs[] = {
// gcc -DMAIN=1 s1c88.c ; ./a.out > s1c88.h
	{"adc", "add with carry"},
	{"add", "add"},
	{"and", "logical and"},
	{"bit", "test bits and save to flags"},
	{"call", "call subroutine at absolute address"},
	{"carl", "call subroutine at long relative address, optional condition"},
	{"cars", "call subroutine at short relative address, optional condition"},
	{"cp", "subtract args and save to flags"},
	{"cpl", "two's complement"},
	{"dec", "decrement"},
	{"div", "divide HL by A"},
	{"djr", "decrement B and jump to short relative address if B is not zero"},
	{"ex", "swap values"},
	{"halt", "go into halt status (exited with outside interupt)"},
	{"inc", "increment"},
	{"int", "generates the specified interrupt"},
	{"jp", "indirect jump"},
	{"jrl", "jump to long relative address, optional condition"},
	{"jrs", "jump to short relative address, optional condition"},
	{"ld", "load"},
	{"mlt", "multiplies L by A and stores the result in HL"},
	{"neg", "negate"},
	{"nop", "no operation"},
	{"or", "logical or"},
	{"pack", "replace A's high nibble with B's low nibble"},
	{"pop", "pop from stack"},
	{"push", "push onto stack"},
	{"ret", "return from subroutine"},
	{"rete", "return from exception or interrupt"},
	{"rets", "return from subroutine then skip two bytes"},
	{"rl", "rotate left one bit, C takes bit 7, bit 0 takes C"},
	{"rlc", "rotate left one bit, bit 7 gives its value to C and bit 0"},
	{"rr", "rotate right one bit, C takes bit 0, bit 7 takes C"},
	{"rrc", "rotate right one bit, bit 0 gives its value to C and bit 7"},
	{"sbc", "subtract with carry"},
	{"sep", "sign expand A to BA"},
	{"sla", "arithmetic shift left one bit"},
	{"sll", "logical shift left one bit"},
	{"slp", "go into sleep mode (exit with outside interrupt)"},
	{"sra", "arithmetic shift right one bit"},
	{"srl", "logical shift right one bit"},
	{"sub", "subract"},
	{"swap", "swap high and low nibbles"},
	{"upck", "replace B's low nibble with A's high nibble"},
	{"xor", "logical exclusive or"},
  {NULL, NULL}
};
typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);
int gperf_s1c88_foreach(GperfForeachCallback cb, void *user) {
  int i = 0; while (kvs[i].name) {
  cb (user, kvs[i].name, kvs[i].value);
  i++;}
  return 0;
}
const char *gperf_s1c88_get(const char *s) {
  int i = 0; while (kvs[i].name) {
  if (!strcmp (s, kvs[i].name)) return kvs[i].value;
  i++;}
  return NULL;
}
#define sdb_hash_c_s1c88(x,y) gperf_s1c88_hash(x)
const unsigned int gperf_s1c88_hash(const char *s) {
  int sum = strlen (s);
  while (*s) { sum += *s; s++; }
  return sum;
}
struct {const char *name;void *get;void *hash;void *foreach;} gperf_s1c88 = {
  .name = "s1c88",
  .get = &gperf_s1c88_get,
  .hash = &gperf_s1c88_hash,
  .foreach = &gperf_s1c88_foreach
};

#if MAIN
int main () {
	const char *s = ((char*(*)(char*))gperf_s1c88.get)("foo");
	printf ("%s\n", s);
}
#endif
