Exemple #1
0
void test_float(const char *source, float *answer, int length, int endian)
{
  struct _asm_context asm_context = { 0 };
  int oops = 0;
  int i;

  printf("Testing: %s (%s) ... ", source, endian == LITTLE ? "little":"big");

  tokens_open_buffer(&asm_context, source);
  tokens_reset(&asm_context);

  if (endian == BIG)
  {
    asm_context.memory.endian = 1;
  }

  assemble(&asm_context);

  uint32_t f = 0;

  for (i = 0; i < length * 4; i++)
  {
    if ((i % 4) == 0) { f = 0; }

    // printf("%d) %02x\n", i, memory_read_m(&asm_context.memory, i));
    if (endian == LITTLE)
    {
      f = (f >> 8) | (memory_read_m(&asm_context.memory, i) << 24);
    }
      else
    {
Exemple #2
0
void assemble_init(struct _asm_context *asm_context)
{
  tokens_reset(asm_context);
#ifndef NO_MSP430
  asm_context->parse_instruction = parse_instruction_msp430;
  asm_context->list_output = list_output_msp430;
  asm_context->cpu_list_index = -1;
#else
  configure_cpu(asm_context, 0);
#endif
  asm_context->address = 0;
  asm_context->instruction_count = 0;
  asm_context->code_count = 0;
  asm_context->data_count = 0;
  asm_context->ifdef_count = 0;
  asm_context->parsing_ifdef = 0;
  asm_context->bytes_per_address = 1;

  macros_free(&asm_context->macros);
  asm_context->def_param_stack_count = 0;
  if (asm_context->pass == 1)
  {
    // FIXME - probably need to allow 32 bit data
    //memory_init(&asm_context->memory, 1<<25, 1);
    memory_init(&asm_context->memory, ~((uint32_t)0), 1);
  }
}
Exemple #3
0
void test_int(const char *source, uint8_t *answer, int length, int endian)
{
  struct _asm_context asm_context = { 0 };
  int oops = 0;
  int i;

  printf("Testing: %s (%s) ... ", source, endian == LITTLE ? "little":"big");

  tokens_open_buffer(&asm_context, source);
  tokens_reset(&asm_context);

  if (endian == BIG)
  {
    asm_context.memory.endian = 1;
  }

  assemble(&asm_context);

  for (i = 0; i < length; i++)
  {
    if (memory_read_m(&asm_context.memory, i) != answer[i])
    {
      oops++;
    }
  }

  if (oops != 0)
  {
    printf("FAIL\n");
    errors++;
  }
    else
  {
    printf("PASS\n");
  }

  tokens_close(&asm_context);
  assembler_free(&asm_context);
}