Esempio n. 1
0
int check_for_directive(struct _asm_context *asm_context, char *token)
{
  if (strcasecmp(token, "org") == 0)
  {
    if (parse_org(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "align") == 0)
  {
    if (parse_align(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "name") == 0)
  {
    if (parse_name(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "public") == 0)
  {
    if (parse_public(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "db") == 0 ||
      strcasecmp(token, "dc8") == 0 ||
      strcasecmp(token, "ascii") == 0)
  {
    if (parse_db(asm_context, 0) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "asciiz") == 0)
  {
    if (parse_db(asm_context, 1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc") == 0)
  {
    if (parse_dc(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dq") == 0)
  {
    if (parse_dq(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dw") == 0 || strcasecmp(token, "dc16") == 0)
  {
    if (parse_dc16(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dl") == 0 || strcasecmp(token, "dc32") == 0)
  {
    if (parse_dc32(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc64") == 0)
  {
    if (parse_dc64(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds") == 0 || strcasecmp(token, "ds8") == 0)
  {
    if (parse_ds(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds16") == 0)
  {
    if (parse_ds(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds32") == 0)
  {
    if (parse_ds(asm_context,4) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resb") == 0)
  {
    if (parse_resb(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resw") == 0)
  {
    if (parse_resb(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "end") == 0)
  {
    return 2;
  }
    else
  if (strcasecmp(token, "big_endian") == 0)
  {
    asm_context->memory.endian = ENDIAN_BIG;
    return 1;
  }
    else
  if (strcasecmp(token, "little_endian") == 0)
  {
    asm_context->memory.endian = ENDIAN_LITTLE;
    return 1;
  }

  if (asm_context->parse_directive != NULL)
  {
    int ret = asm_context->parse_directive(asm_context, token);
    if (ret == 0) { return 1; }   // Found and used
    if (ret == -1) { return -1; } // Found and there was a problem
  }

  int n = 0;
  while (cpu_list[n].name != NULL)
  {
    if (strcasecmp(token, cpu_list[n].name) == 0)
    {
      configure_cpu(asm_context, n);

#if 0
      if (strcmp(token, "65816") == 0)
      {
        asm_context->parse_directive = parse_directive_65816;
      }
        else
#endif
      {
        asm_context->parse_directive = NULL;
      }

      return 1;
    }
    n++;
  }

  return 0;
}
Esempio n. 2
0
int check_for_directive(struct _asm_context *asm_context, char *token)
{
  if (strcasecmp(token, "org") == 0)
  {
    if (parse_org(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "align") == 0)
  {
    if (parse_align(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "name") == 0)
  {
    if (parse_name(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "public") == 0)
  {
    if (parse_public(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "db") == 0 ||
      strcasecmp(token, "dc8") == 0 ||
      strcasecmp(token, "ascii") == 0)
  {
    if (parse_db(asm_context, 0) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "asciiz") == 0)
  {
    if (parse_db(asm_context, 1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dc") == 0)
  {
    if (parse_dc(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dw") == 0 || strcasecmp(token, "dc16") == 0)
  {
    if (parse_dw(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "dl") == 0 || strcasecmp(token, "dc32") == 0)
  {
    if (parse_dl(asm_context) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds") == 0 || strcasecmp(token, "ds8") == 0)
  {
    if (parse_ds(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "ds16") == 0)
  {
    if (parse_ds(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resb") == 0)
  {
    if (parse_resb(asm_context,1) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "resw") == 0)
  {
    if (parse_resb(asm_context,2) != 0) return -1;
    return 1;
  }
    else
  if (strcasecmp(token, "end") == 0)
  {
    return 2;
  }
    else
  if (strcasecmp(token, "big_endian") == 0)
  {
    asm_context->memory.endian=ENDIAN_BIG;
  }
    else
  if (strcasecmp(token, "little_endian") == 0)
  {
    asm_context->memory.endian=ENDIAN_LITTLE;
  }

  int n = 0;
  while (cpu_list[n].name != NULL)
  {
    if (strcasecmp(token, cpu_list[n].name) == 0)
    {
      asm_context->cpu_type = cpu_list[n].type;
      asm_context->memory.endian = cpu_list[n].default_endian;
      asm_context->bytes_per_address = cpu_list[n].bytes_per_address;
      asm_context->is_dollar_hex = cpu_list[n].is_dollar_hex;
      asm_context->can_tick_end_string = cpu_list[n].can_tick_end_string;
      asm_context->parse_instruction = cpu_list[n].parse_instruction;
      asm_context->list_output = cpu_list[n].list_output;
      asm_context->cpu_list_index = n;
      return 1;
    }
    n++;
  }

  return 0;
}