| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include "cpu.h" |
| 7 |
#include "dynabuf.h" |
| 8 |
#include "global.h" |
| 9 |
#include "mnemo.h" |
| 10 |
#include "tree.h" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
static struct cpu_type cpu_type_6502 = { |
| 16 |
keyword_is_6502_mnemo, |
| 17 |
CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY, |
| 18 |
|
| 19 |
0x200, |
| 20 |
234 |
| 21 |
}; |
| 22 |
static struct cpu_type cpu_type_nmos6502 = { |
| 23 |
keyword_is_nmos6502_mnemo, |
| 24 |
CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, |
| 25 |
|
| 26 |
0x200, |
| 27 |
234 |
| 28 |
}; |
| 29 |
static struct cpu_type cpu_type_c64dtv2 = { |
| 30 |
keyword_is_c64dtv2_mnemo, |
| 31 |
CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, |
| 32 |
|
| 33 |
0x200, |
| 34 |
234 |
| 35 |
}; |
| 36 |
static struct cpu_type cpu_type_65c02 = { |
| 37 |
keyword_is_65c02_mnemo, |
| 38 |
CPUFLAG_WARN_ABOUT_FF_PTR, |
| 39 |
|
| 40 |
0x200, |
| 41 |
234 |
| 42 |
}; |
| 43 |
static struct cpu_type cpu_type_r65c02 = { |
| 44 |
keyword_is_r65c02_mnemo, |
| 45 |
CPUFLAG_WARN_ABOUT_FF_PTR, |
| 46 |
|
| 47 |
0x200, |
| 48 |
234 |
| 49 |
}; |
| 50 |
static struct cpu_type cpu_type_w65c02 = { |
| 51 |
keyword_is_w65c02_mnemo, |
| 52 |
CPUFLAG_WARN_ABOUT_FF_PTR, |
| 53 |
|
| 54 |
0x200, |
| 55 |
234 |
| 56 |
}; |
| 57 |
static struct cpu_type cpu_type_65816 = { |
| 58 |
keyword_is_65816_mnemo, |
| 59 |
|
| 60 |
CPUFLAG_SUPPORTSLONGREGS, |
| 61 |
|
| 62 |
0x200, |
| 63 |
234 |
| 64 |
}; |
| 65 |
static struct cpu_type cpu_type_65ce02 = { |
| 66 |
keyword_is_65ce02_mnemo, |
| 67 |
CPUFLAG_DECIMALSUBTRACTBUGGY, |
| 68 |
|
| 69 |
0x200, |
| 70 |
234 |
| 71 |
}; |
| 72 |
static struct cpu_type cpu_type_4502 = { |
| 73 |
keyword_is_4502_mnemo, |
| 74 |
CPUFLAG_DECIMALSUBTRACTBUGGY, |
| 75 |
|
| 76 |
0x200, |
| 77 |
234 |
| 78 |
}; |
| 79 |
static struct cpu_type cpu_type_m65 = { |
| 80 |
keyword_is_m65_mnemo, |
| 81 |
CPUFLAG_WARN_ABOUT_FF_PTR, |
| 82 |
|
| 83 |
0x200, |
| 84 |
234 |
| 85 |
}; |
| 86 |
|
| 87 |
static struct ronode cputype_tree[] = { |
| 88 |
PREDEF_START, |
| 89 |
|
| 90 |
PREDEFNODE("6502", &cpu_type_6502), |
| 91 |
PREDEFNODE("nmos6502", &cpu_type_nmos6502), |
| 92 |
PREDEFNODE("6510", &cpu_type_nmos6502), |
| 93 |
PREDEFNODE("65c02", &cpu_type_65c02), |
| 94 |
PREDEFNODE("r65c02", &cpu_type_r65c02), |
| 95 |
PREDEFNODE("w65c02", &cpu_type_w65c02), |
| 96 |
PREDEFNODE("65816", &cpu_type_65816), |
| 97 |
PREDEFNODE("65ce02", &cpu_type_65ce02), |
| 98 |
PREDEFNODE("4502", &cpu_type_4502), |
| 99 |
PREDEFNODE("m65", &cpu_type_m65), |
| 100 |
PREDEF_END("c64dtv2", &cpu_type_c64dtv2), |
| 101 |
|
| 102 |
}; |
| 103 |
|
| 104 |
const char cputype_names[] = "'6502', 'nmos6502', '6510', '65c02', 'r65c02', 'w65c02', '65816', '65ce02', '4502', 'm65', 'c64dtv2'"; |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
const struct cpu_type *cpu_current_type = NULL; |
| 109 |
boolean cpu_a_is_long = FALSE; |
| 110 |
boolean cpu_xy_are_long = FALSE; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
const struct cpu_type *cputype_find(void) |
| 115 |
{ |
| 116 |
void *node_body; |
| 117 |
|
| 118 |
|
| 119 |
if (!tree_easy_scan(cputype_tree, &node_body, GlobalDynaBuf)) |
| 120 |
return NULL; |
| 121 |
|
| 122 |
return node_body; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
void vcpu_check_and_set_reg_length(boolean *var, boolean make_long) |
| 131 |
{ |
| 132 |
if (((cpu_current_type->flags & CPUFLAG_SUPPORTSLONGREGS) == 0) && make_long) |
| 133 |
throw_error("Chosen CPU does not support long registers."); |
| 134 |
else |
| 135 |
*var = make_long; |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
void cputype_passinit(void) |
| 141 |
{ |
| 142 |
|
| 143 |
if (config.initial_cpu_type != NULL) |
| 144 |
cpu_current_type = config.initial_cpu_type; |
| 145 |
else |
| 146 |
cpu_current_type = &cpu_type_6502; |
| 147 |
|
| 148 |
cpu_a_is_long = FALSE; |
| 149 |
cpu_xy_are_long = FALSE; |
| 150 |
} |