// 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 sm5xx.c ; ./a.out > sm5xx.h
	{"adx", "add immediate value to ACC, skip next on carry"},
	{"atf", "output ACC to F"},
	{"dta", "transfer 1/100s counter to ACC"},
	{"idiv", "reset divider and 1s counter"},
	{"inis", "reset 1/100s counter (10ms)"},
	{"keta", "input KE to ACC"},
	{"lb", "load BM/BL with 4-bit immediate value (partial)"},
	{"lbl", "load BL"},
	{"lblx", "load BL with 4 bit immediate value"},
	{"lbmx", "load BM with 4 bit immediate value"},
	{"nop", "do nothing"},
	{"rds", "reset display enable"},
	{"rtn", "return"},
	{"rtn0", "return 0"},
	{"rtn1", "return 1"},
	{"rtns", "return from subroutine"},
	{"sds", "set display enable"},
	{"tg", "skip next if gamma flag is set, reset it after"},
	{"trs", "indirect subroutine call"},
  {NULL, NULL}
};
typedef int (*GperfForeachCallback)(void *user, const char *k, const char *v);
int gperf_sm5xx_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_sm5xx_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_sm5xx(x,y) gperf_sm5xx_hash(x)
const unsigned int gperf_sm5xx_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_sm5xx = {
  .name = "sm5xx",
  .get = &gperf_sm5xx_get,
  .hash = &gperf_sm5xx_hash,
  .foreach = &gperf_sm5xx_foreach
};

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