asar coverage - build #133


src/asar/
File: src/asar/arch-65816.cpp
Date: 2024-01-22 23:28:38
Lines:
277/307
90.2%
Functions:
136/137
99.3%
Branches:
397/594
66.8%

Line Branch Exec Source
1 #include "asar.h"
2 #include "assembleblock.h"
3 #include "asar_math.h"
4
5 #define write1 write1_pick
6
7 2106 void asinit_65816()
8 {
9 2106 }
10
11 1968 void asend_65816()
12 {
13 1968 }
14
15 // like an address mode, but without a specific width
16 enum class addr_kind {
17 abs, // $00
18 x, // $00,x
19 y, // $00,y
20 ind, // ($00)
21 lind, // [$00]
22 xind, // ($00,x)
23 indy, // ($00),y
24 lindy, // [$00],y
25 s, // $00,s
26 sy, // ($00,s),y
27 imp, // implied (no argument)
28 a, // 'A' as argument
29 imm, // #$00
30 };
31
32 5787 struct insn_context {
33 string arg;
34 char orig_insn[3]; // oops i didn't end up using this... could be useful in some error messages maybe
35 char modifier;
36 };
37
38 // checks for matching characters at the start of haystack, ignoring spaces.
39 // returns index into haystack right after the match
40 template<char... chars>
41 58074 int64_t startmatch(const string& haystack) {
42 static const char needle[] = {chars...};
43 29058 size_t haystack_i = 0;
44
2/2
✓ Branch 0 taken 29037 times.
✓ Branch 1 taken 2415 times.
62904 for(size_t i = 0; i < sizeof...(chars); i++) {
45
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29037 times.
58074 while(haystack[haystack_i] == ' ') haystack_i++;
46
2/2
✓ Branch 0 taken 14526 times.
✓ Branch 1 taken 14511 times.
58074 if(needle[i] != to_lower(haystack[haystack_i++])) return -1;
47 }
48 4830 return haystack_i;
49 }
50
51 // checks for matching characters at the end of haystack, ignoring spaces.
52 // returns index into haystack right before the match
53 template<char... chars>
54
1/2
✓ Branch 0 taken 12105 times.
✗ Branch 1 not taken.
48456 int64_t endmatch(const string& haystack) {
55 static const char needle[] = {chars...};
56 48456 int64_t haystack_i = haystack.length()-1;
57
2/2
✓ Branch 0 taken 28296 times.
✓ Branch 1 taken 2898 times.
62388 for(int64_t i = sizeof...(chars)-1; i >= 0; i--) {
58
4/6
✓ Branch 0 taken 19458 times.
✓ Branch 1 taken 8838 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19458 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14157 times.
56592 while(haystack_i >= 0 && haystack[haystack_i] == ' ') haystack_i--;
59
6/6
✓ Branch 0 taken 19458 times.
✓ Branch 1 taken 8838 times.
✓ Branch 2 taken 9738 times.
✓ Branch 3 taken 9720 times.
✓ Branch 4 taken 10674 times.
✓ Branch 5 taken 3483 times.
56592 if(haystack_i < 0 || needle[i] != to_lower(haystack[haystack_i--])) return -1;
60 }
61 5796 return haystack_i+1;
62 }
63
64 /*
65 * Parses the address kind from an argument, given a list of allowed address kinds.
66 * Throws "invalid address mode" if the argument does not match any kinds.
67 */
68 // i still don't like this function...
69 template<addr_kind... allowed_kinds>
70
1/2
✓ Branch 0 taken 4824 times.
✗ Branch 1 not taken.
21690 std::pair<addr_kind, string> parse_addr_kind(insn_context& arg) {
71 10854 int64_t start_i = 0, end_i = arg.arg.length();
72 // If this addressing kind is allowed, return it, along with a trimmed version of the string.
73 #define RETURN_IF_ALLOWED(kind) \
74 if constexpr(((allowed_kinds == addr_kind::kind) || ...)) { \
75 string out(arg.arg.data() + start_i, end_i - start_i); \
76 return std::make_pair(addr_kind::kind, out); \
77 }
78
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 9420 times.
21690 if((start_i = startmatch<'#'>(arg.arg)) >= 0) {
79
2/4
✓ Branch 0 taken 714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
✗ Branch 3 not taken.
5700 RETURN_IF_ALLOWED(imm);
80 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
81 }
82
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 8772 times.
18840 if((start_i = startmatch<'('>(arg.arg)) >= 0) {
83
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 504 times.
1296 if((end_i = endmatch<',', 's', ')', ',', 'y'>(arg.arg)) >= 0) {
84
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
576 RETURN_IF_ALLOWED(sy);
85 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
86 }
87
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 360 times.
1008 if((end_i = endmatch<')', ',', 'y'>(arg.arg)) >= 0) {
88
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
576 RETURN_IF_ALLOWED(indy);
89 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
90 }
91
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 180 times.
720 if((end_i = endmatch<',', 'x', ')'>(arg.arg)) >= 0) {
92
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
720 RETURN_IF_ALLOWED(xind);
93 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
94 }
95
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 if((end_i = endmatch<')'>(arg.arg)) >= 0) {
96
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
720 RETURN_IF_ALLOWED(ind);
97 asar_throw_warning(1, warning_id_assuming_address_mode, "($00)", "$00", " (if this was intentional, add a +0 after the parentheses.)");
98 }
99 }
100
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 8430 times.
17544 if((start_i = startmatch<'['>(arg.arg)) >= 0) {
101
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 198 times.
684 if((end_i = endmatch<']', ',', 'y'>(arg.arg)) >= 0) {
102
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
576 RETURN_IF_ALLOWED(lindy);
103 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
104 }
105
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
396 if((end_i = endmatch<']'>(arg.arg)) >= 0) {
106
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
792 RETURN_IF_ALLOWED(lind);
107 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
108 }
109 }
110 8436 start_i = 0;
111
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6900 times.
16860 if((end_i = endmatch<',', 'x'>(arg.arg)) >= 0) {
112
2/4
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
6120 RETURN_IF_ALLOWED(x);
113 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
114 }
115
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 6666 times.
13800 if((end_i = endmatch<',', 'y'>(arg.arg)) >= 0) {
116
2/4
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
936 RETURN_IF_ALLOWED(y);
117 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
118 }
119
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 6522 times.
13332 if((end_i = endmatch<',', 's'>(arg.arg)) >= 0) {
120
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
576 RETURN_IF_ALLOWED(s);
121 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
122 }
123 // hoping that by now, something would have stripped whitespace lol
124
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 3588 times.
13044 if(arg.arg.length() == 0) {
125
2/4
✓ Branch 0 taken 1467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1467 times.
✗ Branch 3 not taken.
11736 RETURN_IF_ALLOWED(imp);
126 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
127 }
128
6/6
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 3462 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1734 times.
7176 if(arg.arg == "a" || arg.arg == "A") {
129
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
432 RETURN_IF_ALLOWED(a);
130 // todo: some hint for "don't name your label "a" "?
131 36 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
132 }
133 if constexpr(((allowed_kinds == addr_kind::abs) || ...)) {
134
1/2
✓ Branch 0 taken 1734 times.
✗ Branch 1 not taken.
6936 return std::make_pair(addr_kind::abs, arg.arg);
135 }
136 asar_throw_error(1, error_type_block, error_id_bad_addr_mode);
137 #undef RETURN_IF_ALLOWED
138 // clang doesn't know that asar_throw_error is noreturn in this case... :(
139 return {};
140 }
141
142 const char* format_valid_widths(int min, int max) {
143 if(min == 1) {
144 if(max == 1) return "only 8-bit";
145 if(max == 2) return "only 8-bit or 16-bit";
146 if(max == 3) return "any width"; // shouldn't actually happen lol
147 } else if(min == 2) {
148 if(max == 2) return "only 16-bit";
149 if(max == 3) return "only 16-bit or 24-bit";
150 } else if(min == 3) {
151 return "only 24-bit";
152 }
153 return "???";
154 }
155
156 7305 int get_real_len(int min_len, int max_len, char modifier, int arg_min_len) {
157
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 4965 times.
7305 if(modifier != 0) {
158 2340 int given_len = getlenfromchar(modifier);
159
2/4
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2322 times.
2322 if(given_len < min_len || given_len > max_len)
160 asar_throw_error(2, error_type_block, error_id_bad_access_width, format_valid_widths(min_len, max_len), given_len*8);
161 2322 return given_len;
162 } else {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4965 times.
4965 if(arg_min_len > max_len) {
164 asar_throw_error(2, error_type_block, error_id_bad_access_width, format_valid_widths(min_len, max_len), arg_min_len*8);
165 }
166 // todo warn about widening when dpbase != 0
167 4965 return std::max(arg_min_len, min_len);
168 }
169 }
170
171 1113 void check_implicit_immediate(char modifier, const string& target) {
172
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 558 times.
1113 if(modifier != 0) return;
173
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 288 times.
573 if(is_hex_constant(target.data())) return;
174 87 asar_throw_warning(2, warning_id_implicitly_sized_immediate);
175 }
176
177 template<int base, bool allow_imm = true>
178 9006 void the8(insn_context& arg) {
179 using K = addr_kind;
180
1/2
✓ Branch 0 taken 2253 times.
✗ Branch 1 not taken.
9006 auto parse_result = parse_addr_kind<K::xind, K::s, K::abs, K::lind, K::imm, K::indy, K::ind, K::sy, K::x, K::y, K::lindy>(arg);
181 9006 addr_kind kind = parse_result.first;
182 4506 int min_len = 0, max_len = 4;
183
4/4
✓ Branch 0 taken 1501 times.
✓ Branch 1 taken 3002 times.
✓ Branch 2 taken 1489 times.
✓ Branch 3 taken 12 times.
9006 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
184
1/2
✓ Branch 0 taken 4491 times.
✗ Branch 1 not taken.
8982 int arg_min_len = getlen(parse_result.second, kind == K::imm);
185
14/14
✓ Branch 0 taken 2175 times.
✓ Branch 1 taken 2316 times.
✓ Branch 2 taken 2103 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 2031 times.
✓ Branch 5 taken 72 times.
✓ Branch 6 taken 1959 times.
✓ Branch 7 taken 72 times.
✓ Branch 8 taken 1887 times.
✓ Branch 9 taken 72 times.
✓ Branch 10 taken 1815 times.
✓ Branch 11 taken 72 times.
✓ Branch 12 taken 72 times.
✓ Branch 13 taken 1743 times.
8982 if(kind == K::xind || kind == K::s || kind == K::sy || kind == K::indy || kind == K::ind || kind == K::lind || kind == K::lindy) min_len = max_len = 1;
186
2/2
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 882 times.
3486 else if(kind == K::abs) min_len = 1, max_len = 3;
187
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 450 times.
1764 else if(kind == K::x) min_len = 1, max_len = 3;
188
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 378 times.
900 else if(kind == K::y) min_len = max_len = 2;
189
1/2
✓ Branch 0 taken 378 times.
✗ Branch 1 not taken.
756 else if(kind == K::imm) min_len = 1, max_len = 2;
190
3/4
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 3738 times.
✓ Branch 2 taken 753 times.
✗ Branch 3 not taken.
8982 if(kind == K::imm) check_implicit_immediate(arg.modifier, parse_result.second);
191
2/2
✓ Branch 0 taken 4473 times.
✓ Branch 1 taken 18 times.
8982 int real_len = get_real_len(min_len, max_len, arg.modifier, arg_min_len);
192 4476 int opcode_offset = 0;
193
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 2508 times.
8946 if(real_len == 1) {
194
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 984 times.
3930 if(kind == K::xind) opcode_offset = 0x1;
195
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 984 times.
3786 if(kind == K::s) opcode_offset = 0x3;
196
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 984 times.
3786 if(kind == K::abs) opcode_offset = 0x5;
197
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 984 times.
3570 if(kind == K::lind) opcode_offset = 0x7;
198
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 981 times.
3786 if(kind == K::imm) opcode_offset = 0x9;
199
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 984 times.
3624 if(kind == K::indy) opcode_offset = 0x11;
200
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 984 times.
3786 if(kind == K::ind) opcode_offset = 0x12;
201
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 984 times.
3786 if(kind == K::sy) opcode_offset = 0x13;
202
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 984 times.
3786 if(kind == K::x) opcode_offset = 0x15;
203
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1677 times.
3642 if(kind == K::lindy) opcode_offset = 0x17;
204
2/2
✓ Branch 0 taken 1602 times.
✓ Branch 1 taken 906 times.
5016 } else if(real_len == 2) {
205
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 801 times.
3204 if(kind == K::imm) opcode_offset = 0x9;
206
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 801 times.
2778 if(kind == K::abs) opcode_offset = 0xd;
207
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 801 times.
2460 if(kind == K::y) opcode_offset = 0x19;
208
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 1242 times.
3060 if(kind == K::x) opcode_offset = 0x1d;
209
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 453 times.
1812 } else if(real_len == 3) {
210
2/2
✓ Branch 0 taken 453 times.
✓ Branch 1 taken 453 times.
1812 if(kind == K::abs) opcode_offset = 0xf;
211
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 453 times.
1194 if(kind == K::x) opcode_offset = 0x1f;
212 }
213
1/2
✓ Branch 0 taken 4473 times.
✗ Branch 1 not taken.
8946 write1(opcode_offset + base);
214
3/4
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 2508 times.
✓ Branch 2 taken 1965 times.
✗ Branch 3 not taken.
8946 if(real_len == 1) write1(the_num);
215
3/4
✓ Branch 0 taken 1602 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 1602 times.
✗ Branch 3 not taken.
5016 else if(real_len == 2) write2(the_num);
216
2/4
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
1812 else if(real_len == 3) write3(the_num);
217 8976 }
218
219 template<int base, int accum_opc, bool is_bit = false>
220 2448 void thenext8(insn_context& arg) {
221 using K = addr_kind;
222 addr_kind kind;
223 1224 string parsed_str;
224 if constexpr(is_bit) {
225
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
432 auto parse_result = parse_addr_kind<K::x, K::abs, K::imm>(arg);
226 432 kind = parse_result.first;
227
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
216 parsed_str = parse_result.second;
228 216 } else {
229
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
2016 auto parse_result = parse_addr_kind<K::x, K::abs, K::imm, K::a, K::imp>(arg);
230 2016 kind = parse_result.first;
231
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
1008 parsed_str = parse_result.second;
232 // todo: some checks on arg.modifier here
233
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 972 times.
2016 if(kind == K::imm) {
234 // implied rep
235
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 int64_t rep_count = getnum(parsed_str);
236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(foundlabel) asar_throw_error(0, error_type_block, error_id_no_labels_here);
237
3/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 36 times.
252 for (int64_t i=0;i<rep_count;i++) { write1(accum_opc); }
238 36 return;
239 }
240
3/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 486 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
1944 if(kind == K::a || kind == K::imp) {
241
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
216 write1(accum_opc);
242 108 return;
243 }
244
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 72 times.
1008 }
245
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 720 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
2160 int64_t the_num = pass == 2 ? getnum(parsed_str) : 0;
246
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
2160 int arg_min_len = getlen(parsed_str, kind == K::imm);
247
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
2160 int real_len = get_real_len(1, 2, arg.modifier, arg_min_len);
248 1080 int opcode = 0;
249
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 576 times.
1296 if(kind == K::imm) {
250
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
144 check_implicit_immediate(arg.modifier, parsed_str);
251 72 opcode = accum_opc;
252
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 504 times.
2016 } else if(real_len == 1) {
253
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
1008 if(kind == K::abs) opcode = base+0x6;
254
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 252 times.
756 if(kind == K::x) opcode = base+0x16;
255
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
1008 } else if(real_len == 2) {
256
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
1008 if(kind == K::abs) opcode = base+0xe;
257
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 252 times.
756 if(kind == K::x) opcode = base+0x1e;
258 }
259
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
2160 write1(opcode);
260
3/4
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 540 times.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
2160 if(real_len == 1) write1(the_num);
261
2/4
✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
1080 else if(real_len == 2) write2(the_num);
262
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 72 times.
2448 }
263
264 template<int base>
265 288 void tsb_trb(insn_context& arg) {
266 using K = addr_kind;
267
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
288 auto parse_result = parse_addr_kind<K::abs>(arg);
268
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
288 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
269
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
288 int arg_min_len = getlen(parse_result.second, false);
270
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
288 int real_len = get_real_len(1, 2, arg.modifier, arg_min_len);
271
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
288 int opcode_offset = real_len == 1 ? 0x04 : 0x0c;
272
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
288 write1(opcode_offset + base);
273
3/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
288 if(real_len == 1) write1(the_num);
274
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
144 else if(real_len == 2) write2(the_num);
275 288 }
276
277 template<int opc, int width = 1>
278 432 void branch(insn_context& arg) {
279 using K = addr_kind;
280
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 9 times.
432 auto parse_result = parse_addr_kind<K::abs>(arg);
281 198 int64_t num = 0;
282
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 132 times.
396 if(pass == 2) {
283
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
132 num = getnum(parse_result.second);
284
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 6 times.
132 if(foundlabel) {
285 120 int64_t delta = num - (snespos + width + 1);
286
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 57 times.
120 if((num & ~0xffff) != (snespos & ~0xffff)) {
287 // todo: should throw error "can't branch to different bank"
288 asar_throw_error(2, error_type_block, error_id_relative_branch_out_of_bounds, dec(delta).data());
289 }
290
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
108 if(width==1 && (delta < -128 || delta > 127)) {
291 asar_throw_error(2, error_type_block, error_id_relative_branch_out_of_bounds, dec(delta).data());
292 }
293 60 num = delta;
294 } else {
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
12 if(num & ~(width==2 ? 0xffff : 0xff)) {
296 asar_throw_error(2, error_type_block, error_id_relative_branch_out_of_bounds, dec(num).data());
297 }
298 12 num = (int16_t)(width==2 ? num : (int8_t)num);
299 }
300 }
301
302
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
396 write1(opc);
303
1/2
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
324 if(width == 1) write1(num);
304
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 else if(width == 2) write2(num);
305 396 }
306
307 template<int opc>
308 1404 void implied(insn_context& arg) {
309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 702 times.
1404 if(arg.arg != "") {
310 // todo: some kind of "this instruction doesn't take an argument" message?
311 asar_throw_error(0, error_type_block, error_id_bad_addr_mode);
312 }
313 1404 write1(opc);
314 1404 }
315
316 template<int opc>
317 6120 void implied_rep(insn_context& arg) {
318 using K = addr_kind;
319
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
6120 auto parse_result = parse_addr_kind<K::imm, K::imp>(arg);
320
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 180 times.
6120 if(parse_result.first == K::imp) {
321
1/2
✓ Branch 0 taken 2880 times.
✗ Branch 1 not taken.
5760 write1(opc);
322 } else {
323
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 int64_t rep_count = getnum(parse_result.second);
324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
360 if(foundlabel) asar_throw_error(0, error_type_block, error_id_no_labels_here);
325
3/4
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 180 times.
1188 for (int64_t i=0;i<rep_count;i++) { write1(opc); }
326 }
327 6120 }
328
329 template<int base, char op, char xy>
330 1800 void xy_ops(insn_context& arg) {
331 using K = addr_kind;
332 900 std::pair<addr_kind, string> parse_result;
333 if(op == 'S') { // stx
334
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
360 parse_result = parse_addr_kind<K::abs, (xy == 'X' ? K::y : K::x)>(arg);
335 } else if(op == 'L') { // ldx
336
2/4
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
864 parse_result = parse_addr_kind<K::abs, K::imm, (xy == 'X' ? K::y : K::x)>(arg);
337 } else { // cpx
338
2/4
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144 times.
✗ Branch 3 not taken.
576 parse_result = parse_addr_kind<K::abs, K::imm>(arg);
339 }
340
3/4
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
1800 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
341
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
1800 int arg_min_len = getlen(parse_result.second, false);
342
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
1800 int real_len = get_real_len(1, 2, arg.modifier, arg_min_len);
343 900 int opcode = 0;
344
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 612 times.
1800 if(parse_result.first == K::imm) {
345
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
576 check_implicit_immediate(arg.modifier, parse_result.second);
346 288 opcode = base;
347
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 180 times.
1224 } else if(parse_result.first == K::abs) {
348
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 216 times.
864 if(real_len == 1) opcode = base + 0x4;
349 216 else opcode = base + 0xc;
350 } else { // ,x or ,y
351
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 90 times.
360 if(real_len == 1) opcode = base + 0x14;
352 72 else opcode = base + 0x1c;
353 }
354
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
1800 write1(opcode);
355
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 432 times.
✓ Branch 2 taken 468 times.
✗ Branch 3 not taken.
1800 if(real_len == 1) write1(the_num);
356
2/4
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
864 else if(real_len == 2) write2(the_num);
357 1800 }
358
359 template<int opc>
360 216 void interrupt(insn_context& arg) {
361 using K = addr_kind;
362
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
216 auto parse_result = parse_addr_kind<K::imm, K::imp>(arg);
363
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 54 times.
216 if(parse_result.first == K::imp) {
364
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
108 write1(opc);
365
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
108 write1(0);
366 } else {
367
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
108 int64_t num = pass == 2 ? getnum(parse_result.second) : 0;
368 // this is kinda hacky
369
2/11
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
72 if(num < 0 || num > 255) asar_throw_error(2, error_type_block, error_id_bad_access_width, format_valid_widths(1, 1), num > 65535 ? 24 : 16);
370
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
108 write1(opc);
371
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
108 write1(num);
372 }
373 216 }
374
375 template<int opc, addr_kind k, int width>
376 504 void oneoff(insn_context& arg) {
377
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
504 auto parse_result = parse_addr_kind<k>(arg);
378
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
504 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
379
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
504 int arg_min_len = getlen(parse_result.second, false);
380 // only for error checking, we know the answer anyways
381
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
504 get_real_len(width, width, arg.modifier, arg_min_len);
382
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
504 write1(opc);
383
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
108 if(width == 1) write1(the_num);
384
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 else if(width == 2) write2(the_num);
385
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
360 else if(width == 3) write3(the_num);
386 504 }
387
388 144 void stz(insn_context& arg) {
389 using K = addr_kind;
390
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
144 auto parse_result = parse_addr_kind<K::abs, K::x>(arg);
391
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
144 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
392
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 int arg_min_len = getlen(parse_result.second, false);
393
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 int real_len = get_real_len(1, 2, arg.modifier, arg_min_len);
394
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
144 if(real_len == 1) {
395
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
72 if(parse_result.first == K::abs) write1(0x64);
396
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 else if(parse_result.first == K::x) write1(0x74);
397
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 write1(the_num);
398 } else {
399
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
72 if(parse_result.first == K::abs) write1(0x9c);
400
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 else if(parse_result.first == K::x) write1(0x9e);
401
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 write2(the_num);
402 }
403 144 }
404
405 template<char which>
406 588 void jmp_jsr_jml(insn_context& arg) {
407 using K = addr_kind;
408
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
588 auto parse_result = which == 'R' ? parse_addr_kind<K::abs, K::xind>(arg)
409 : which == 'P' ? parse_addr_kind<K::abs, K::xind, K::ind, K::lind>(arg)
410 : /* 'L' */ parse_addr_kind<K::abs, K::lind>(arg);
411
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
588 int64_t the_num = pass == 2 ? getnum(parse_result.second) : 0;
412 // set optimizeforbank to -1 (i.e. auto, assume DBR = current bank)
413 // because jmp and jsr's arguments are relative to the program bank anyways
414 588 int old_optimize = optimizeforbank;
415
4/4
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 135 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 114 times.
588 if(parse_result.first == K::lind || parse_result.first == K::ind) {
416 // these ones for Some Reason always read the pointer from bank 0 lol
417 144 optimizeforbank = 0;
418 } else {
419 // the rest use bank K
420 444 optimizeforbank = -1;
421 }
422
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
588 int arg_min_len = getlen(parse_result.second, false);
423 588 optimizeforbank = old_optimize;
424
3/5
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
606 get_real_len(2, (which == 'L' && parse_result.first == K::abs) ? 3 : 2, arg.modifier, arg_min_len);
425 if(which == 'R') {
426
3/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
288 if(parse_result.first == K::abs) write1(0x20);
427
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
36 else if(parse_result.first == K::xind) write1(0xfc);
428 } else if(which == 'L') {
429
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 18 times.
108 if(parse_result.first == K::abs) {
430
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 write1(0x5c);
431
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 write3(the_num);
432 36 return;
433
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 } else if(parse_result.first == K::lind) {
434
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
36 write1(0xdc);
435 }
436 } else {
437
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
192 if(parse_result.first == K::abs) write1(0x4c);
438
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
144 else if(parse_result.first == K::ind) write1(0x6c);
439
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
108 else if(parse_result.first == K::xind) write1(0x7c);
440
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
72 else if(parse_result.first == K::lind) write1(0xdc);
441 }
442
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
516 write2(the_num);
443
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 18 times.
300 }
444
445 template<int opc>
446 72 void mvn_mvp(insn_context& arg) {
447 int count;
448
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
72 autoptr<char**> parts = qpsplit(arg.arg.raw(), ',', &count);
449
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(count != 2) asar_throw_error(2, error_type_block, error_id_bad_addr_mode);
450 // todo length checks ???
451
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
72 write1(opc);
452
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
72 if(pass == 2) {
453
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 write1(getnum(parts[0]));
454
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 write1(getnum(parts[1]));
455 } else {
456
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 write2(0);
457 }
458 72 }
459
460 assocarr<void(*)(insn_context&)> mnemonics = {
461 { "ora", the8<0x00> },
462 { "and", the8<0x20> },
463 { "eor", the8<0x40> },
464 { "adc", the8<0x60> },
465 { "sta", the8<0x80, false> },
466 { "lda", the8<0xa0> },
467 { "cmp", the8<0xc0> },
468 { "sbc", the8<0xe0> },
469 { "asl", thenext8<0x00, 0x0a> },
470 { "bit", thenext8<0x1e, 0x89, true> },
471 { "rol", thenext8<0x20, 0x2a> },
472 { "lsr", thenext8<0x40, 0x4a> },
473 { "ror", thenext8<0x60, 0x6a> },
474 { "dec", thenext8<0xc0, 0x3a> },
475 { "inc", thenext8<0xe0, 0x1a> },
476 { "bcc", branch<0x90> },
477 { "bcs", branch<0xb0> },
478 { "beq", branch<0xf0> },
479 { "bmi", branch<0x30> },
480 { "bne", branch<0xd0> },
481 { "bpl", branch<0x10> },
482 { "bra", branch<0x80> },
483 { "bvc", branch<0x50> },
484 { "bvs", branch<0x70> },
485 { "brl", branch<0x82, 2> },
486 { "clc", implied<0x18> },
487 { "cld", implied<0xd8> },
488 { "cli", implied<0x58> },
489 { "clv", implied<0xb8> },
490 { "dex", implied_rep<0xca> },
491 { "dey", implied_rep<0x88> },
492 { "inx", implied_rep<0xe8> },
493 { "iny", implied_rep<0xc8> },
494 { "nop", implied_rep<0xea> },
495 { "pha", implied<0x48> },
496 { "phb", implied<0x8b> },
497 { "phd", implied<0x0b> },
498 { "phk", implied<0x4b> },
499 { "php", implied<0x08> },
500 { "phx", implied<0xda> },
501 { "phy", implied<0x5a> },
502 { "pla", implied<0x68> },
503 { "plb", implied<0xab> },
504 { "pld", implied<0x2b> },
505 { "plp", implied<0x28> },
506 { "plx", implied<0xfa> },
507 { "ply", implied<0x7a> },
508 { "rti", implied<0x40> },
509 { "rtl", implied<0x6b> },
510 { "rts", implied<0x60> },
511 { "sec", implied<0x38> },
512 { "sed", implied<0xf8> },
513 { "sei", implied<0x78> },
514 { "stp", implied<0xdb> },
515 { "tax", implied<0xaa> },
516 { "tay", implied<0xa8> },
517 { "tcd", implied<0x5b> },
518 { "tcs", implied<0x1b> },
519 { "tdc", implied<0x7b> },
520 { "tsc", implied<0x3b> },
521 { "tsx", implied<0xba> },
522 { "txa", implied<0x8a> },
523 { "txs", implied<0x9a> },
524 { "txy", implied<0x9b> },
525 { "tya", implied<0x98> },
526 { "tyx", implied<0xbb> },
527 { "wai", implied<0xcb> },
528 { "xba", implied<0xeb> },
529 { "xce", implied<0xfb> },
530 { "ldy", xy_ops<0xa0, 'L', 'Y'> },
531 { "ldx", xy_ops<0xa2, 'L', 'X'> },
532 { "cpy", xy_ops<0xc0, 'C', 'Y'> },
533 { "cpx", xy_ops<0xe0, 'C', 'X'> },
534 { "stx", xy_ops<0x82, 'S', 'X'> },
535 { "sty", xy_ops<0x80, 'S', 'Y'> },
536 { "cop", interrupt<0x02> },
537 { "wdm", interrupt<0x42> },
538 { "brk", interrupt<0x00> },
539 { "tsb", tsb_trb<0x00> },
540 { "trb", tsb_trb<0x10> },
541 { "rep", oneoff<0xc2, addr_kind::imm, 1> },
542 { "sep", oneoff<0xe2, addr_kind::imm, 1> },
543 { "pei", oneoff<0xd4, addr_kind::ind, 1> },
544 { "pea", oneoff<0xf4, addr_kind::abs, 2> },
545 { "mvn", mvn_mvp<0x54> },
546 { "mvp", mvn_mvp<0x44> },
547 { "jsl", oneoff<0x22, addr_kind::abs, 3> },
548 { "per", branch<0x62, 2> },
549 { "stz", stz },
550 { "jmp", jmp_jsr_jml<'P'> },
551 { "jsr", jmp_jsr_jml<'R'> },
552 { "jml", jmp_jsr_jml<'L'> },
553 };
554
555
556 67332 bool asblock_65816(char** word, int numwords)
557 {
558 #define is(test) (!stricmpwithupper(word[0], test))
559
2/2
✓ Branch 0 taken 36846 times.
✓ Branch 1 taken 30486 times.
67332 if(word[0][0] == '\'') return false;
560 29883 string par;
561
2/2
✓ Branch 0 taken 60963 times.
✓ Branch 1 taken 66126 times.
127089 for(int i = 1; i < numwords; i++){
562
3/4
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 59115 times.
✓ Branch 2 taken 924 times.
✗ Branch 3 not taken.
60963 if(i > 1) par += " ";
563
1/2
✓ Branch 0 taken 27288 times.
✗ Branch 1 not taken.
60963 par += word[i];
564 }
565 // todo handle code like `nop = $1234`
566
1/2
✓ Branch 0 taken 29883 times.
✗ Branch 1 not taken.
66126 string opc = word[0];
567
4/4
✓ Branch 0 taken 368832 times.
✓ Branch 1 taken 36243 times.
✓ Branch 2 taken 150231 times.
✓ Branch 3 taken 29883 times.
441318 for(int i = 0; i < opc.length(); i++) opc.raw()[i] = to_lower(opc[i]);
568 29883 char mod = 0;
569
9/10
✓ Branch 0 taken 65982 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 30909 times.
✓ Branch 3 taken 35073 times.
✓ Branch 4 taken 29739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 28569 times.
✓ Branch 8 taken 1170 times.
✓ Branch 9 taken 28713 times.
66126 if(opc.length() >= 2 && opc[opc.length()-2] == '.') {
570
1/2
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
2340 mod = opc[opc.length()-1];
571
2/4
✓ Branch 0 taken 1170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1170 times.
✗ Branch 3 not taken.
2340 opc.truncate(opc.length()-2);
572 }
573
4/4
✓ Branch 0 taken 35670 times.
✓ Branch 1 taken 30456 times.
✓ Branch 2 taken 24087 times.
✓ Branch 3 taken 5796 times.
66126 if(!mnemonics.exists(opc.data())) return false;
574
2/2
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 24 times.
11583 insn_context ctx{par, {}, mod};
575 11583 ctx.orig_insn[0] = opc[0];
576 11583 ctx.orig_insn[1] = opc[1];
577 11583 ctx.orig_insn[2] = opc[2];
578
4/4
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 5772 times.
✓ Branch 3 taken 24 times.
11583 mnemonics.find(opc.data())(ctx);
579 5772 return true;
580 66198 }
581