summaryrefslogtreecommitdiff
path: root/testsuite/generate_opcodes_sys.c
blob: 2de7e81c5ca2cbdddc277002e65f02ea608226f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include <orc/orc.h>
#include <orc-test/orctest.h>


int error = FALSE;

void test_opcode (OrcStaticOpcode *opcode);
void test_opcode_const (OrcStaticOpcode *opcode);
void test_opcode_param (OrcStaticOpcode *opcode);

int
main (int argc, char *argv[])
{
  int i;
  OrcOpcodeSet *opcode_set;
  OrcStaticOpcode *opcode;
  const char *d1;

  orc_init();
  orc_test_init();

  opcode_set = orc_opcode_set_get ("sys");

  for(i=0;i<opcode_set->n_opcodes;i++){
    opcode = opcode_set->opcodes + i;

    printf(".function emulate_%s\n", opcode->name);
    if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) {
      printf(".accumulator %d a1\n", opcode->dest_size[0]);
      d1 = "a1";
    } else {
      printf(".dest %d d1\n", opcode->dest_size[0]);
      d1 = "d1";
    }
    if (opcode->dest_size[1]) {
      printf(".dest %d d2\n", opcode->dest_size[1]);
    }
    printf(".source %d s1\n", opcode->src_size[0]);
    if (opcode->src_size[1]) {
      if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) {
        printf(".param %d s2\n", opcode->src_size[1]);
      } else {
        printf(".source %d s2\n", opcode->src_size[1]);
      }
    }
    printf("\n");
    if (opcode->src_size[1]) {
      printf("%s %s, s1, s2\n", opcode->name, d1);
    } else {
      if (opcode->dest_size[1]) {
        printf("%s %s, d2, s1\n", opcode->name, d1);
      } else {
        printf("%s %s, s1\n", opcode->name, d1);
      }
    }
    printf("\n");
    printf("\n");

    printf(".function emulate_n16_%s\n", opcode->name);
    printf(".n 16\n");
    if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) {
      printf(".accumulator %d a1\n", opcode->dest_size[0]);
      d1 = "a1";
    } else {
      printf(".dest %d d1\n", opcode->dest_size[0]);
      d1 = "d1";
    }
    if (opcode->dest_size[1]) {
      printf(".dest %d d2\n", opcode->dest_size[1]);
    }
    printf(".source %d s1\n", opcode->src_size[0]);
    if (opcode->src_size[1]) {
      if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) {
        printf(".param %d s2\n", opcode->src_size[1]);
      } else {
        printf(".source %d s2\n", opcode->src_size[1]);
      }
    }
    printf("\n");
    if (opcode->src_size[1]) {
      printf("%s %s, s1, s2\n", opcode->name, d1);
    } else {
      if (opcode->dest_size[1]) {
        printf("%s %s, d2, s1\n", opcode->name, d1);
      } else {
        printf("%s %s, s1\n", opcode->name, d1);
      }
    }
    printf("\n");
    printf("\n");
  }

  if (error) return 1;
  return 0;
}