| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "asar.h" |
| 2 |
|
|
#include "assembleblock.h" |
| 3 |
|
|
#include "asar_math.h" |
| 4 |
|
|
#include <cassert> |
| 5 |
|
|
#include <initializer_list> |
| 6 |
|
|
#include "frozen/string.h" |
| 7 |
|
|
#include "frozen/unordered_map.h" |
| 8 |
|
|
|
| 9 |
|
|
// A bit of terminology i just invented: |
| 10 |
|
|
// "mnemonic" refers to the name of an instruction, e.g. LDA or JMP. |
| 11 |
|
|
// "address mode" is the form of an instruction's argument, with a specific |
| 12 |
|
|
// width, e.g. [$12] or $1234,x. determining the exact mode requires knowing |
| 13 |
|
|
// the width of the instruction. |
| 14 |
|
|
// "address kind" is like an address mode, but without a specific width. it |
| 15 |
|
|
// is determined purely from the syntax of the argument. |
| 16 |
|
|
// "modifier" is the length suffix (the .w in LDA.w), but it's called modifier |
| 17 |
|
|
// because it's a bit more general (also sets branch targeting mode). |
| 18 |
|
|
|
| 19 |
|
|
enum class addr_kind { |
| 20 |
|
|
abs, // $00 |
| 21 |
|
|
x, // $00,x |
| 22 |
|
|
y, // $00,y |
| 23 |
|
|
ind, // ($00) "indirect" |
| 24 |
|
|
lind, // [$00] "long indirect" |
| 25 |
|
|
xind, // ($00,x) |
| 26 |
|
|
indy, // ($00),y |
| 27 |
|
|
lindy, // [$00],y |
| 28 |
|
|
s, // $00,s |
| 29 |
|
|
sy, // ($00,s),y |
| 30 |
|
|
imp, // implied (no argument) |
| 31 |
|
|
a, // 'A' as argument |
| 32 |
|
|
imm, // #$00 "immediate" |
| 33 |
|
|
mvn, // special for mvn/mvp |
| 34 |
|
|
num_addr_kinds, |
| 35 |
|
|
}; |
| 36 |
|
|
// used as bitmasks |
| 37 |
|
|
static_assert((int)addr_kind::num_addr_kinds < 32); |
| 38 |
|
|
|
| 39 |
|
|
// various flags that affect parsing of specific instructions. |
| 40 |
|
|
// these are stored per mnemonic+kind, which is required for some of them, and |
| 41 |
|
|
// the rest usually have only 1 kind/width allowed anyways so it doesn't hurt. |
| 42 |
|
|
// this is not an `enum class` because those are annoying to use as bitmasks. |
| 43 |
|
|
enum mnemonic_flag { |
| 44 |
|
|
// for brk,cop,wdm: implied mode = immediate with arg 0 |
| 45 |
|
|
flag_imm_implied_0 = 1 << 0, |
| 46 |
|
|
// imm should be size 1 or 2 depending on accum size. |
| 47 |
|
|
// currently all this does is allow both 1- and 2-wide immediates, |
| 48 |
|
|
// but could be useful for tracking rep/sep state in asar in the future. |
| 49 |
|
|
flag_imm_width_a = 1 << 1, |
| 50 |
|
|
// imm should be size 1 or 2 depending on x/y size |
| 51 |
|
|
flag_imm_width_xy = 1 << 2, |
| 52 |
|
|
// branch opcodes, have weird target computation rules |
| 53 |
|
|
flag_branch = 1 << 3, |
| 54 |
|
|
// for jmp/jsr, sets optimizeforbank to K |
| 55 |
|
|
flag_bank_k = 1 << 4, |
| 56 |
|
|
// sets optimizeforbank to 0 (as some jumps always read from bank 0) |
| 57 |
|
|
flag_bank_0 = 1 << 5, |
| 58 |
|
|
// additionally allow `imm` addressing which is interpreted as repetition |
| 59 |
|
|
flag_implied_rep = 1 << 6, |
| 60 |
|
|
}; |
| 61 |
|
|
|
| 62 |
|
|
struct mnem_kind_info { |
| 63 |
|
|
uint8_t allowed_widths = 0; // bitmask, low 4 bits represent widths 0 to 3 |
| 64 |
|
|
uint8_t opcode_for_width[4] = {}; |
| 65 |
|
|
uint32_t flags = 0; // combination of `mnemonic_flag`s |
| 66 |
|
|
}; |
| 67 |
|
|
struct mnemonicinfo { |
| 68 |
|
|
// kind of a waste to have this array which most of the time only has 1 entry filled |
| 69 |
|
|
mnem_kind_info types[(int)addr_kind::num_addr_kinds]; |
| 70 |
|
|
uint32_t allowed_kinds_mask = 0; |
| 71 |
|
|
// helper struct for the initializer_list |
| 72 |
|
|
struct opcode { |
| 73 |
|
|
uint8_t byte; |
| 74 |
|
|
addr_kind akind; |
| 75 |
|
|
int width; // width of argument, not entire insn |
| 76 |
|
|
uint32_t flags; |
| 77 |
|
|
constexpr opcode(uint8_t byte_, addr_kind akind_, int width_, uint32_t flags_ = 0) |
| 78 |
|
|
: byte(byte_), akind(akind_), width(width_), |
| 79 |
|
|
flags(flags_) {} |
| 80 |
|
|
}; |
| 81 |
|
|
constexpr void add_one(addr_kind kind, int width, uint8_t byte, uint32_t flags) { |
| 82 |
|
|
allowed_kinds_mask |= 1 << (int)kind; |
| 83 |
|
|
auto& this_part = types[(int)kind]; |
| 84 |
|
|
assert((this_part.allowed_widths & (1 << width)) == 0); |
| 85 |
|
|
this_part.allowed_widths |= 1 << width; |
| 86 |
|
|
this_part.opcode_for_width[width] = byte; |
| 87 |
|
|
this_part.flags |= flags; |
| 88 |
|
|
|
| 89 |
|
|
} |
| 90 |
|
|
constexpr mnemonicinfo(const std::initializer_list<opcode>& opcodes) { |
| 91 |
|
|
for(auto& x : opcodes) { |
| 92 |
|
|
add_one(x.akind, x.width, x.byte, x.flags); |
| 93 |
|
|
if(x.flags & flag_imm_implied_0) { |
| 94 |
|
|
assert(x.akind == addr_kind::imm && x.width == 1); |
| 95 |
|
|
add_one(addr_kind::imp, 0, x.byte, x.flags); |
| 96 |
|
|
} |
| 97 |
|
|
if(x.akind == addr_kind::a) { |
| 98 |
|
|
add_one(addr_kind::imp, 0, x.byte, x.flags); |
| 99 |
|
|
} |
| 100 |
|
|
if(x.flags & flag_implied_rep) { |
| 101 |
|
|
add_one(addr_kind::imm, 0, x.byte, x.flags); |
| 102 |
|
|
} |
| 103 |
|
|
if(x.flags & (flag_imm_width_a | flag_imm_width_xy)) { |
| 104 |
|
|
assert(x.akind == addr_kind::imm && x.width == 1); |
| 105 |
|
|
add_one(x.akind, 2, x.byte, x.flags); |
| 106 |
|
|
} |
| 107 |
|
|
} |
| 108 |
|
|
} |
| 109 |
|
|
}; |
| 110 |
|
|
|
| 111 |
|
|
static constexpr auto mnemonic_lookup = frozen::make_unordered_map<frozen::string, mnemonicinfo>({ |
| 112 |
|
|
{ "adc", { { 0x65, addr_kind::abs , 1 }, |
| 113 |
|
|
{ 0x6d, addr_kind::abs , 2 }, |
| 114 |
|
|
{ 0x6f, addr_kind::abs , 3 }, |
| 115 |
|
|
{ 0x69, addr_kind::imm , 1, flag_imm_width_a }, |
| 116 |
|
|
{ 0x72, addr_kind::ind , 1 }, |
| 117 |
|
|
{ 0x71, addr_kind::indy , 1 }, |
| 118 |
|
|
{ 0x67, addr_kind::lind , 1 }, |
| 119 |
|
|
{ 0x77, addr_kind::lindy , 1 }, |
| 120 |
|
|
{ 0x63, addr_kind::s , 1 }, |
| 121 |
|
|
{ 0x73, addr_kind::sy , 1 }, |
| 122 |
|
|
{ 0x75, addr_kind::x , 1 }, |
| 123 |
|
|
{ 0x7d, addr_kind::x , 2 }, |
| 124 |
|
|
{ 0x7f, addr_kind::x , 3 }, |
| 125 |
|
|
{ 0x61, addr_kind::xind , 1 }, |
| 126 |
|
|
{ 0x79, addr_kind::y , 2 } } }, |
| 127 |
|
|
{ "and", { { 0x25, addr_kind::abs , 1 }, |
| 128 |
|
|
{ 0x2d, addr_kind::abs , 2 }, |
| 129 |
|
|
{ 0x2f, addr_kind::abs , 3 }, |
| 130 |
|
|
{ 0x29, addr_kind::imm , 1, flag_imm_width_a }, |
| 131 |
|
|
{ 0x32, addr_kind::ind , 1 }, |
| 132 |
|
|
{ 0x31, addr_kind::indy , 1 }, |
| 133 |
|
|
{ 0x27, addr_kind::lind , 1 }, |
| 134 |
|
|
{ 0x37, addr_kind::lindy , 1 }, |
| 135 |
|
|
{ 0x23, addr_kind::s , 1 }, |
| 136 |
|
|
{ 0x33, addr_kind::sy , 1 }, |
| 137 |
|
|
{ 0x35, addr_kind::x , 1 }, |
| 138 |
|
|
{ 0x3d, addr_kind::x , 2 }, |
| 139 |
|
|
{ 0x3f, addr_kind::x , 3 }, |
| 140 |
|
|
{ 0x21, addr_kind::xind , 1 }, |
| 141 |
|
|
{ 0x39, addr_kind::y , 2 } } }, |
| 142 |
|
|
{ "asl", { { 0x0a, addr_kind::a , 0, flag_implied_rep }, |
| 143 |
|
|
{ 0x06, addr_kind::abs , 1 }, |
| 144 |
|
|
{ 0x0e, addr_kind::abs , 2 }, |
| 145 |
|
|
{ 0x16, addr_kind::x , 1 }, |
| 146 |
|
|
{ 0x1e, addr_kind::x , 2 } } }, |
| 147 |
|
|
{ "bcc", { { 0x90, addr_kind::abs , 1, flag_branch } } }, |
| 148 |
|
|
{ "bcs", { { 0xb0, addr_kind::abs , 1, flag_branch } } }, |
| 149 |
|
|
{ "beq", { { 0xf0, addr_kind::abs , 1, flag_branch } } }, |
| 150 |
|
|
{ "bit", { { 0x24, addr_kind::abs , 1 }, |
| 151 |
|
|
{ 0x2c, addr_kind::abs , 2 }, |
| 152 |
|
|
{ 0x89, addr_kind::imm , 1, flag_imm_width_a }, |
| 153 |
|
|
{ 0x34, addr_kind::x , 1 }, |
| 154 |
|
|
{ 0x3c, addr_kind::x , 2 } } }, |
| 155 |
|
|
{ "bmi", { { 0x30, addr_kind::abs , 1, flag_branch } } }, |
| 156 |
|
|
{ "bne", { { 0xd0, addr_kind::abs , 1, flag_branch } } }, |
| 157 |
|
|
{ "bpl", { { 0x10, addr_kind::abs , 1, flag_branch } } }, |
| 158 |
|
|
{ "bra", { { 0x80, addr_kind::abs , 1, flag_branch } } }, |
| 159 |
|
|
{ "brk", { { 0x00, addr_kind::imm , 1, flag_imm_implied_0 } } }, |
| 160 |
|
|
{ "brl", { { 0x82, addr_kind::abs , 2, flag_branch } } }, |
| 161 |
|
|
{ "bvc", { { 0x50, addr_kind::abs , 1, flag_branch } } }, |
| 162 |
|
|
{ "bvs", { { 0x70, addr_kind::abs , 1, flag_branch } } }, |
| 163 |
|
|
{ "clc", { { 0x18, addr_kind::imp , 0 } } }, |
| 164 |
|
|
{ "cld", { { 0xd8, addr_kind::imp , 0 } } }, |
| 165 |
|
|
{ "cli", { { 0x58, addr_kind::imp , 0 } } }, |
| 166 |
|
|
{ "clv", { { 0xb8, addr_kind::imp , 0 } } }, |
| 167 |
|
|
{ "cmp", { { 0xc5, addr_kind::abs , 1 }, |
| 168 |
|
|
{ 0xcd, addr_kind::abs , 2 }, |
| 169 |
|
|
{ 0xcf, addr_kind::abs , 3 }, |
| 170 |
|
|
{ 0xc9, addr_kind::imm , 1, flag_imm_width_a }, |
| 171 |
|
|
{ 0xd2, addr_kind::ind , 1 }, |
| 172 |
|
|
{ 0xd1, addr_kind::indy , 1 }, |
| 173 |
|
|
{ 0xc7, addr_kind::lind , 1 }, |
| 174 |
|
|
{ 0xd7, addr_kind::lindy , 1 }, |
| 175 |
|
|
{ 0xc3, addr_kind::s , 1 }, |
| 176 |
|
|
{ 0xd3, addr_kind::sy , 1 }, |
| 177 |
|
|
{ 0xd5, addr_kind::x , 1 }, |
| 178 |
|
|
{ 0xdd, addr_kind::x , 2 }, |
| 179 |
|
|
{ 0xdf, addr_kind::x , 3 }, |
| 180 |
|
|
{ 0xc1, addr_kind::xind , 1 }, |
| 181 |
|
|
{ 0xd9, addr_kind::y , 2 } } }, |
| 182 |
|
|
{ "cop", { { 0x02, addr_kind::imm , 1, flag_imm_implied_0 } } }, |
| 183 |
|
|
{ "cpx", { { 0xe4, addr_kind::abs , 1 }, |
| 184 |
|
|
{ 0xec, addr_kind::abs , 2 }, |
| 185 |
|
|
{ 0xe0, addr_kind::imm , 1, flag_imm_width_xy } } }, |
| 186 |
|
|
{ "cpy", { { 0xc4, addr_kind::abs , 1 }, |
| 187 |
|
|
{ 0xcc, addr_kind::abs , 2 }, |
| 188 |
|
|
{ 0xc0, addr_kind::imm , 1, flag_imm_width_xy } } }, |
| 189 |
|
|
{ "dec", { { 0x3a, addr_kind::a , 0, flag_implied_rep }, |
| 190 |
|
|
{ 0xc6, addr_kind::abs , 1 }, |
| 191 |
|
|
{ 0xce, addr_kind::abs , 2 }, |
| 192 |
|
|
{ 0xd6, addr_kind::x , 1 }, |
| 193 |
|
|
{ 0xde, addr_kind::x , 2 } } }, |
| 194 |
|
|
{ "dex", { { 0xca, addr_kind::imp , 0, flag_implied_rep } } }, |
| 195 |
|
|
{ "dey", { { 0x88, addr_kind::imp , 0, flag_implied_rep } } }, |
| 196 |
|
|
{ "eor", { { 0x45, addr_kind::abs , 1 }, |
| 197 |
|
|
{ 0x4d, addr_kind::abs , 2 }, |
| 198 |
|
|
{ 0x4f, addr_kind::abs , 3 }, |
| 199 |
|
|
{ 0x49, addr_kind::imm , 1, flag_imm_width_a }, |
| 200 |
|
|
{ 0x52, addr_kind::ind , 1 }, |
| 201 |
|
|
{ 0x51, addr_kind::indy , 1 }, |
| 202 |
|
|
{ 0x47, addr_kind::lind , 1 }, |
| 203 |
|
|
{ 0x57, addr_kind::lindy , 1 }, |
| 204 |
|
|
{ 0x43, addr_kind::s , 1 }, |
| 205 |
|
|
{ 0x53, addr_kind::sy , 1 }, |
| 206 |
|
|
{ 0x55, addr_kind::x , 1 }, |
| 207 |
|
|
{ 0x5d, addr_kind::x , 2 }, |
| 208 |
|
|
{ 0x5f, addr_kind::x , 3 }, |
| 209 |
|
|
{ 0x41, addr_kind::xind , 1 }, |
| 210 |
|
|
{ 0x59, addr_kind::y , 2 } } }, |
| 211 |
|
|
{ "inc", { { 0x1a, addr_kind::a , 0, flag_implied_rep }, |
| 212 |
|
|
{ 0xe6, addr_kind::abs , 1 }, |
| 213 |
|
|
{ 0xee, addr_kind::abs , 2 }, |
| 214 |
|
|
{ 0xf6, addr_kind::x , 1 }, |
| 215 |
|
|
{ 0xfe, addr_kind::x , 2 } } }, |
| 216 |
|
|
{ "inx", { { 0xe8, addr_kind::imp , 0, flag_implied_rep } } }, |
| 217 |
|
|
{ "iny", { { 0xc8, addr_kind::imp , 0, flag_implied_rep } } }, |
| 218 |
|
|
{ "jml", { { 0x5c, addr_kind::abs , 3 }, |
| 219 |
|
|
{ 0xdc, addr_kind::lind , 2, flag_bank_0 } } }, |
| 220 |
|
|
{ "jmp", { { 0x4c, addr_kind::abs , 2, flag_bank_k }, |
| 221 |
|
|
{ 0x6c, addr_kind::ind , 2, flag_bank_0 }, |
| 222 |
|
|
{ 0xdc, addr_kind::lind , 2, flag_bank_0 }, |
| 223 |
|
|
{ 0x7c, addr_kind::xind , 2, flag_bank_k } } }, |
| 224 |
|
|
{ "jsl", { { 0x22, addr_kind::abs , 3 } } }, |
| 225 |
|
|
{ "jsr", { { 0x20, addr_kind::abs , 2, flag_bank_k }, |
| 226 |
|
|
{ 0xfc, addr_kind::xind , 2, flag_bank_k } } }, |
| 227 |
|
|
{ "lda", { { 0xa5, addr_kind::abs , 1 }, |
| 228 |
|
|
{ 0xad, addr_kind::abs , 2 }, |
| 229 |
|
|
{ 0xaf, addr_kind::abs , 3 }, |
| 230 |
|
|
{ 0xa9, addr_kind::imm , 1, flag_imm_width_a }, |
| 231 |
|
|
{ 0xb2, addr_kind::ind , 1 }, |
| 232 |
|
|
{ 0xb1, addr_kind::indy , 1 }, |
| 233 |
|
|
{ 0xa7, addr_kind::lind , 1 }, |
| 234 |
|
|
{ 0xb7, addr_kind::lindy , 1 }, |
| 235 |
|
|
{ 0xa3, addr_kind::s , 1 }, |
| 236 |
|
|
{ 0xb3, addr_kind::sy , 1 }, |
| 237 |
|
|
{ 0xb5, addr_kind::x , 1 }, |
| 238 |
|
|
{ 0xbd, addr_kind::x , 2 }, |
| 239 |
|
|
{ 0xbf, addr_kind::x , 3 }, |
| 240 |
|
|
{ 0xa1, addr_kind::xind , 1 }, |
| 241 |
|
|
{ 0xb9, addr_kind::y , 2 } } }, |
| 242 |
|
|
{ "ldx", { { 0xa6, addr_kind::abs , 1 }, |
| 243 |
|
|
{ 0xae, addr_kind::abs , 2 }, |
| 244 |
|
|
{ 0xa2, addr_kind::imm , 1, flag_imm_width_xy }, |
| 245 |
|
|
{ 0xb6, addr_kind::y , 1 }, |
| 246 |
|
|
{ 0xbe, addr_kind::y , 2 } } }, |
| 247 |
|
|
{ "ldy", { { 0xa4, addr_kind::abs , 1 }, |
| 248 |
|
|
{ 0xac, addr_kind::abs , 2 }, |
| 249 |
|
|
{ 0xa0, addr_kind::imm , 1, flag_imm_width_xy }, |
| 250 |
|
|
{ 0xb4, addr_kind::x , 1 }, |
| 251 |
|
|
{ 0xbc, addr_kind::x , 2 } } }, |
| 252 |
|
|
{ "lsr", { { 0x4a, addr_kind::a , 0, flag_implied_rep }, |
| 253 |
|
|
{ 0x46, addr_kind::abs , 1 }, |
| 254 |
|
|
{ 0x4e, addr_kind::abs , 2 }, |
| 255 |
|
|
{ 0x56, addr_kind::x , 1 }, |
| 256 |
|
|
{ 0x5e, addr_kind::x , 2 } } }, |
| 257 |
|
|
{ "mvn", { { 0x54, addr_kind::mvn , 2 } } }, |
| 258 |
|
|
{ "mvp", { { 0x44, addr_kind::mvn , 2 } } }, |
| 259 |
|
|
{ "nop", { { 0xea, addr_kind::imp , 0, flag_implied_rep } } }, |
| 260 |
|
|
{ "ora", { { 0x05, addr_kind::abs , 1 }, |
| 261 |
|
|
{ 0x0d, addr_kind::abs , 2 }, |
| 262 |
|
|
{ 0x0f, addr_kind::abs , 3 }, |
| 263 |
|
|
{ 0x09, addr_kind::imm , 1, flag_imm_width_a }, |
| 264 |
|
|
{ 0x12, addr_kind::ind , 1 }, |
| 265 |
|
|
{ 0x11, addr_kind::indy , 1 }, |
| 266 |
|
|
{ 0x07, addr_kind::lind , 1 }, |
| 267 |
|
|
{ 0x17, addr_kind::lindy , 1 }, |
| 268 |
|
|
{ 0x03, addr_kind::s , 1 }, |
| 269 |
|
|
{ 0x13, addr_kind::sy , 1 }, |
| 270 |
|
|
{ 0x15, addr_kind::x , 1 }, |
| 271 |
|
|
{ 0x1d, addr_kind::x , 2 }, |
| 272 |
|
|
{ 0x1f, addr_kind::x , 3 }, |
| 273 |
|
|
{ 0x01, addr_kind::xind , 1 }, |
| 274 |
|
|
{ 0x19, addr_kind::y , 2 } } }, |
| 275 |
|
|
{ "pea", { { 0xf4, addr_kind::abs , 2 } } }, |
| 276 |
|
|
{ "pei", { { 0xd4, addr_kind::ind , 1 } } }, |
| 277 |
|
|
{ "per", { { 0x62, addr_kind::abs , 2, flag_branch } } }, |
| 278 |
|
|
{ "pha", { { 0x48, addr_kind::imp , 0 } } }, |
| 279 |
|
|
{ "phb", { { 0x8b, addr_kind::imp , 0 } } }, |
| 280 |
|
|
{ "phd", { { 0x0b, addr_kind::imp , 0 } } }, |
| 281 |
|
|
{ "phk", { { 0x4b, addr_kind::imp , 0 } } }, |
| 282 |
|
|
{ "php", { { 0x08, addr_kind::imp , 0 } } }, |
| 283 |
|
|
{ "phx", { { 0xda, addr_kind::imp , 0 } } }, |
| 284 |
|
|
{ "phy", { { 0x5a, addr_kind::imp , 0 } } }, |
| 285 |
|
|
{ "pla", { { 0x68, addr_kind::imp , 0 } } }, |
| 286 |
|
|
{ "plb", { { 0xab, addr_kind::imp , 0 } } }, |
| 287 |
|
|
{ "pld", { { 0x2b, addr_kind::imp , 0 } } }, |
| 288 |
|
|
{ "plp", { { 0x28, addr_kind::imp , 0 } } }, |
| 289 |
|
|
{ "plx", { { 0xfa, addr_kind::imp , 0 } } }, |
| 290 |
|
|
{ "ply", { { 0x7a, addr_kind::imp , 0 } } }, |
| 291 |
|
|
{ "rep", { { 0xc2, addr_kind::imm , 1 } } }, |
| 292 |
|
|
{ "rol", { { 0x2a, addr_kind::a , 0, flag_implied_rep }, |
| 293 |
|
|
{ 0x26, addr_kind::abs , 1 }, |
| 294 |
|
|
{ 0x2e, addr_kind::abs , 2 }, |
| 295 |
|
|
{ 0x36, addr_kind::x , 1 }, |
| 296 |
|
|
{ 0x3e, addr_kind::x , 2 } } }, |
| 297 |
|
|
{ "ror", { { 0x6a, addr_kind::a , 0, flag_implied_rep }, |
| 298 |
|
|
{ 0x66, addr_kind::abs , 1 }, |
| 299 |
|
|
{ 0x6e, addr_kind::abs , 2 }, |
| 300 |
|
|
{ 0x76, addr_kind::x , 1 }, |
| 301 |
|
|
{ 0x7e, addr_kind::x , 2 } } }, |
| 302 |
|
|
{ "rti", { { 0x40, addr_kind::imp , 0 } } }, |
| 303 |
|
|
{ "rtl", { { 0x6b, addr_kind::imp , 0 } } }, |
| 304 |
|
|
{ "rts", { { 0x60, addr_kind::imp , 0 } } }, |
| 305 |
|
|
{ "sbc", { { 0xe5, addr_kind::abs , 1 }, |
| 306 |
|
|
{ 0xed, addr_kind::abs , 2 }, |
| 307 |
|
|
{ 0xef, addr_kind::abs , 3 }, |
| 308 |
|
|
{ 0xe9, addr_kind::imm , 1, flag_imm_width_a }, |
| 309 |
|
|
{ 0xf2, addr_kind::ind , 1 }, |
| 310 |
|
|
{ 0xf1, addr_kind::indy , 1 }, |
| 311 |
|
|
{ 0xe7, addr_kind::lind , 1 }, |
| 312 |
|
|
{ 0xf7, addr_kind::lindy , 1 }, |
| 313 |
|
|
{ 0xe3, addr_kind::s , 1 }, |
| 314 |
|
|
{ 0xf3, addr_kind::sy , 1 }, |
| 315 |
|
|
{ 0xf5, addr_kind::x , 1 }, |
| 316 |
|
|
{ 0xfd, addr_kind::x , 2 }, |
| 317 |
|
|
{ 0xff, addr_kind::x , 3 }, |
| 318 |
|
|
{ 0xe1, addr_kind::xind , 1 }, |
| 319 |
|
|
{ 0xf9, addr_kind::y , 2 } } }, |
| 320 |
|
|
{ "sec", { { 0x38, addr_kind::imp , 0 } } }, |
| 321 |
|
|
{ "sed", { { 0xf8, addr_kind::imp , 0 } } }, |
| 322 |
|
|
{ "sei", { { 0x78, addr_kind::imp , 0 } } }, |
| 323 |
|
|
{ "sep", { { 0xe2, addr_kind::imm , 1 } } }, |
| 324 |
|
|
{ "sta", { { 0x85, addr_kind::abs , 1 }, |
| 325 |
|
|
{ 0x8d, addr_kind::abs , 2 }, |
| 326 |
|
|
{ 0x8f, addr_kind::abs , 3 }, |
| 327 |
|
|
{ 0x92, addr_kind::ind , 1 }, |
| 328 |
|
|
{ 0x91, addr_kind::indy , 1 }, |
| 329 |
|
|
{ 0x87, addr_kind::lind , 1 }, |
| 330 |
|
|
{ 0x97, addr_kind::lindy , 1 }, |
| 331 |
|
|
{ 0x83, addr_kind::s , 1 }, |
| 332 |
|
|
{ 0x93, addr_kind::sy , 1 }, |
| 333 |
|
|
{ 0x95, addr_kind::x , 1 }, |
| 334 |
|
|
{ 0x9d, addr_kind::x , 2 }, |
| 335 |
|
|
{ 0x9f, addr_kind::x , 3 }, |
| 336 |
|
|
{ 0x81, addr_kind::xind , 1 }, |
| 337 |
|
|
{ 0x99, addr_kind::y , 2 } } }, |
| 338 |
|
|
{ "stp", { { 0xdb, addr_kind::imp , 0 } } }, |
| 339 |
|
|
{ "stx", { { 0x86, addr_kind::abs , 1 }, |
| 340 |
|
|
{ 0x8e, addr_kind::abs , 2 }, |
| 341 |
|
|
{ 0x96, addr_kind::y , 1 } } }, |
| 342 |
|
|
{ "sty", { { 0x84, addr_kind::abs , 1 }, |
| 343 |
|
|
{ 0x8c, addr_kind::abs , 2 }, |
| 344 |
|
|
{ 0x94, addr_kind::x , 1 } } }, |
| 345 |
|
|
{ "stz", { { 0x64, addr_kind::abs , 1 }, |
| 346 |
|
|
{ 0x9c, addr_kind::abs , 2 }, |
| 347 |
|
|
{ 0x74, addr_kind::x , 1 }, |
| 348 |
|
|
{ 0x9e, addr_kind::x , 2 } } }, |
| 349 |
|
|
{ "tax", { { 0xaa, addr_kind::imp , 0 } } }, |
| 350 |
|
|
{ "tay", { { 0xa8, addr_kind::imp , 0 } } }, |
| 351 |
|
|
{ "tcd", { { 0x5b, addr_kind::imp , 0 } } }, |
| 352 |
|
|
{ "tcs", { { 0x1b, addr_kind::imp , 0 } } }, |
| 353 |
|
|
{ "tdc", { { 0x7b, addr_kind::imp , 0 } } }, |
| 354 |
|
|
{ "trb", { { 0x14, addr_kind::abs , 1 }, |
| 355 |
|
|
{ 0x1c, addr_kind::abs , 2 } } }, |
| 356 |
|
|
{ "tsb", { { 0x04, addr_kind::abs , 1 }, |
| 357 |
|
|
{ 0x0c, addr_kind::abs , 2 } } }, |
| 358 |
|
|
{ "tsc", { { 0x3b, addr_kind::imp , 0 } } }, |
| 359 |
|
|
{ "tsx", { { 0xba, addr_kind::imp , 0 } } }, |
| 360 |
|
|
{ "txa", { { 0x8a, addr_kind::imp , 0 } } }, |
| 361 |
|
|
{ "txs", { { 0x9a, addr_kind::imp , 0 } } }, |
| 362 |
|
|
{ "txy", { { 0x9b, addr_kind::imp , 0 } } }, |
| 363 |
|
|
{ "tya", { { 0x98, addr_kind::imp , 0 } } }, |
| 364 |
|
|
{ "tyx", { { 0xbb, addr_kind::imp , 0 } } }, |
| 365 |
|
|
{ "wai", { { 0xcb, addr_kind::imp , 0 } } }, |
| 366 |
|
|
{ "wdm", { { 0x42, addr_kind::imm , 1, flag_imm_implied_0 } } }, |
| 367 |
|
|
{ "xba", { { 0xeb, addr_kind::imp , 0 } } }, |
| 368 |
|
|
{ "xce", { { 0xfb, addr_kind::imp , 0 } } }, |
| 369 |
|
|
}); |
| 370 |
|
|
|
| 371 |
|
|
struct parse_result { |
| 372 |
|
|
addr_kind kind; |
| 373 |
|
|
string arg; |
| 374 |
|
|
}; |
| 375 |
|
|
|
| 376 |
|
|
// checks for matching characters at the start of haystack, ignoring spaces. |
| 377 |
|
|
// returns index into haystack right after the match |
| 378 |
|
|
template<char... chars> |
| 379 |
|
11367 |
static int64_t startmatch(const string& haystack) { |
| 380 |
|
|
static const char needle[] = {chars...}; |
| 381 |
|
11367 |
size_t haystack_i = 0; |
| 382 |
12/18
long startmatch<(char)35>(string const&):
✗ Branch 12 → 3 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 19 → 3 taken 2130 times.
✓ Branch 19 → 20 taken 291 times.
long long startmatch<(char)35>(string const&):
✓ Branch 12 → 3 taken 2115 times.
✓ Branch 12 → 13 taken 285 times.
long startmatch<(char)40>(string const&):
✗ Branch 12 → 3 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 19 → 3 taken 1839 times.
✓ Branch 19 → 20 taken 108 times.
long long startmatch<(char)40>(string const&):
✓ Branch 12 → 3 taken 1830 times.
✓ Branch 12 → 13 taken 108 times.
long startmatch<(char)91>(string const&):
✗ Branch 12 → 3 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 19 → 3 taken 1731 times.
✓ Branch 19 → 20 taken 57 times.
long long startmatch<(char)91>(string const&):
✓ Branch 12 → 3 taken 1722 times.
✓ Branch 12 → 13 taken 57 times.
|
12273 |
for(size_t i = 0; i < sizeof...(chars); i++) { |
| 383 |
6/18
long startmatch<(char)35>(string const&):
✗ Branch 6 → 4 not taken.
✗ Branch 6 → 7 not taken.
✗ Branch 9 → 4 not taken.
✓ Branch 9 → 10 taken 2130 times.
long long startmatch<(char)35>(string const&):
✗ Branch 6 → 4 not taken.
✓ Branch 6 → 7 taken 2115 times.
long startmatch<(char)40>(string const&):
✗ Branch 6 → 4 not taken.
✗ Branch 6 → 7 not taken.
✗ Branch 9 → 4 not taken.
✓ Branch 9 → 10 taken 1839 times.
long long startmatch<(char)40>(string const&):
✗ Branch 6 → 4 not taken.
✓ Branch 6 → 7 taken 1830 times.
long startmatch<(char)91>(string const&):
✗ Branch 6 → 4 not taken.
✗ Branch 6 → 7 not taken.
✗ Branch 9 → 4 not taken.
✓ Branch 9 → 10 taken 1731 times.
long long startmatch<(char)91>(string const&):
✗ Branch 6 → 4 not taken.
✓ Branch 6 → 7 taken 1722 times.
|
11367 |
while(haystack[haystack_i] == ' ') haystack_i++; |
| 384 |
12/18
long startmatch<(char)35>(string const&):
✗ Branch 9 → 10 not taken.
✗ Branch 9 → 11 not taken.
✓ Branch 16 → 17 taken 1839 times.
✓ Branch 16 → 18 taken 291 times.
long long startmatch<(char)35>(string const&):
✓ Branch 9 → 10 taken 1830 times.
✓ Branch 9 → 11 taken 285 times.
long startmatch<(char)40>(string const&):
✗ Branch 9 → 10 not taken.
✗ Branch 9 → 11 not taken.
✓ Branch 16 → 17 taken 1731 times.
✓ Branch 16 → 18 taken 108 times.
long long startmatch<(char)40>(string const&):
✓ Branch 9 → 10 taken 1722 times.
✓ Branch 9 → 11 taken 108 times.
long startmatch<(char)91>(string const&):
✗ Branch 9 → 10 not taken.
✗ Branch 9 → 11 not taken.
✓ Branch 16 → 17 taken 1674 times.
✓ Branch 16 → 18 taken 57 times.
long long startmatch<(char)91>(string const&):
✓ Branch 9 → 10 taken 1665 times.
✓ Branch 9 → 11 taken 57 times.
|
11367 |
if(needle[i] != to_lower(haystack[haystack_i++])) return -1; |
| 385 |
|
|
} |
| 386 |
|
906 |
return haystack_i; |
| 387 |
|
|
} |
| 388 |
|
|
|
| 389 |
|
|
// checks for matching characters at the end of haystack, ignoring spaces. |
| 390 |
|
|
// returns index into haystack right before the match |
| 391 |
|
|
template<char... chars> |
| 392 |
|
9615 |
static int64_t endmatch(const string& haystack) { |
| 393 |
|
|
static const char needle[] = {chars...}; |
| 394 |
|
9615 |
int64_t haystack_i = haystack.length()-1; |
| 395 |
36/54
long endmatch<(char)41>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 29 → 5 taken 30 times.
✓ Branch 29 → 30 taken 30 times.
long long endmatch<(char)41>(string const&):
✓ Branch 21 → 4 taken 30 times.
✓ Branch 21 → 22 taken 30 times.
long endmatch<(char)41, (char)44, (char)121>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 132 times.
✓ Branch 31 → 32 taken 24 times.
long long endmatch<(char)41, (char)44, (char)121>(string const&):
✓ Branch 21 → 4 taken 132 times.
✓ Branch 21 → 22 taken 24 times.
long endmatch<(char)44, (char)115>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 1392 times.
✓ Branch 31 → 32 taken 24 times.
long long endmatch<(char)44, (char)115>(string const&):
✓ Branch 21 → 4 taken 1383 times.
✓ Branch 21 → 22 taken 24 times.
long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 276 times.
✓ Branch 31 → 32 taken 24 times.
long long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✓ Branch 21 → 4 taken 276 times.
✓ Branch 21 → 22 taken 24 times.
long endmatch<(char)44, (char)120>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 1944 times.
✓ Branch 31 → 32 taken 267 times.
long long endmatch<(char)44, (char)120>(string const&):
✓ Branch 21 → 4 taken 1935 times.
✓ Branch 21 → 22 taken 267 times.
long endmatch<(char)44, (char)120, (char)41>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 150 times.
✓ Branch 31 → 32 taken 30 times.
long long endmatch<(char)44, (char)120, (char)41>(string const&):
✓ Branch 21 → 4 taken 150 times.
✓ Branch 21 → 22 taken 30 times.
long endmatch<(char)44, (char)121>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 1449 times.
✓ Branch 31 → 32 taken 39 times.
long long endmatch<(char)44, (char)121>(string const&):
✓ Branch 21 → 4 taken 1440 times.
✓ Branch 21 → 22 taken 39 times.
long endmatch<(char)93>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 29 → 5 taken 33 times.
✓ Branch 29 → 30 taken 33 times.
long long endmatch<(char)93>(string const&):
✓ Branch 21 → 4 taken 33 times.
✓ Branch 21 → 22 taken 33 times.
long endmatch<(char)93, (char)44, (char)121>(string const&):
✗ Branch 21 → 4 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 31 → 5 taken 105 times.
✓ Branch 31 → 32 taken 24 times.
long long endmatch<(char)93, (char)44, (char)121>(string const&):
✓ Branch 21 → 4 taken 105 times.
✓ Branch 21 → 22 taken 24 times.
|
11985 |
for(int64_t i = sizeof...(chars)-1; i >= 0; i--) { |
| 396 |
60/162
long endmatch<(char)41>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 30 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 30 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 30 times.
long long endmatch<(char)41>(string const&):
✓ Branch 6 → 7 taken 30 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 30 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 30 times.
long endmatch<(char)41, (char)44, (char)121>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 132 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 132 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 132 times.
long long endmatch<(char)41, (char)44, (char)121>(string const&):
✓ Branch 6 → 7 taken 132 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 132 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 132 times.
long endmatch<(char)44, (char)115>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 759 times.
✓ Branch 7 → 14 taken 633 times.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 759 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 1392 times.
long long endmatch<(char)44, (char)115>(string const&):
✓ Branch 6 → 7 taken 750 times.
✓ Branch 6 → 10 taken 633 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 750 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 1383 times.
long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 276 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 276 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 276 times.
long long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✓ Branch 6 → 7 taken 276 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 276 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 276 times.
long endmatch<(char)44, (char)120>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 1308 times.
✓ Branch 7 → 14 taken 636 times.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 1308 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 1944 times.
long long endmatch<(char)44, (char)120>(string const&):
✓ Branch 6 → 7 taken 1299 times.
✓ Branch 6 → 10 taken 636 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 1299 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 1935 times.
long endmatch<(char)44, (char)120, (char)41>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 150 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 150 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 150 times.
long long endmatch<(char)44, (char)120, (char)41>(string const&):
✓ Branch 6 → 7 taken 150 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 150 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 150 times.
long endmatch<(char)44, (char)121>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 813 times.
✓ Branch 7 → 14 taken 636 times.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 813 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 1449 times.
long long endmatch<(char)44, (char)121>(string const&):
✓ Branch 6 → 7 taken 804 times.
✓ Branch 6 → 10 taken 636 times.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 804 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 1440 times.
long endmatch<(char)93>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 33 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 33 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 33 times.
long long endmatch<(char)93>(string const&):
✓ Branch 6 → 7 taken 33 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 33 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 33 times.
long endmatch<(char)93, (char)44, (char)121>(string const&):
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 10 not taken.
✓ Branch 7 → 8 taken 105 times.
✗ Branch 7 → 14 not taken.
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
✗ Branch 11 → 5 not taken.
✗ Branch 11 → 12 not taken.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 105 times.
✗ Branch 15 → 6 not taken.
✓ Branch 15 → 16 taken 105 times.
long long endmatch<(char)93, (char)44, (char)121>(string const&):
✓ Branch 6 → 7 taken 105 times.
✗ Branch 6 → 10 not taken.
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 105 times.
✗ Branch 11 → 5 not taken.
✓ Branch 11 → 12 taken 105 times.
|
10995 |
while(haystack_i >= 0 && haystack[haystack_i] == ' ') haystack_i--; |
| 397 |
88/162
long endmatch<(char)41>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 30 times.
✗ Branch 16 → 24 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 30 times.
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 30 times.
long long endmatch<(char)41>(string const&):
✓ Branch 12 → 13 taken 30 times.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 30 times.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 30 times.
long endmatch<(char)41, (char)44, (char)121>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 132 times.
✗ Branch 16 → 26 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 60 times.
✓ Branch 25 → 27 taken 72 times.
✓ Branch 28 → 29 taken 60 times.
✓ Branch 28 → 30 taken 72 times.
long long endmatch<(char)41, (char)44, (char)121>(string const&):
✓ Branch 12 → 13 taken 132 times.
✗ Branch 12 → 16 not taken.
✓ Branch 15 → 16 taken 60 times.
✓ Branch 15 → 17 taken 72 times.
✓ Branch 18 → 19 taken 60 times.
✓ Branch 18 → 20 taken 72 times.
long endmatch<(char)44, (char)115>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 759 times.
✓ Branch 16 → 26 taken 633 times.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 711 times.
✓ Branch 25 → 27 taken 48 times.
✓ Branch 28 → 29 taken 1344 times.
✓ Branch 28 → 30 taken 48 times.
long long endmatch<(char)44, (char)115>(string const&):
✓ Branch 12 → 13 taken 750 times.
✓ Branch 12 → 16 taken 633 times.
✓ Branch 15 → 16 taken 702 times.
✓ Branch 15 → 17 taken 48 times.
✓ Branch 18 → 19 taken 1335 times.
✓ Branch 18 → 20 taken 48 times.
long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 276 times.
✗ Branch 16 → 26 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 84 times.
✓ Branch 25 → 27 taken 192 times.
✓ Branch 28 → 29 taken 84 times.
✓ Branch 28 → 30 taken 192 times.
long long endmatch<(char)44, (char)115, (char)41, (char)44, (char)121>(string const&):
✓ Branch 12 → 13 taken 276 times.
✗ Branch 12 → 16 not taken.
✓ Branch 15 → 16 taken 84 times.
✓ Branch 15 → 17 taken 192 times.
✓ Branch 18 → 19 taken 84 times.
✓ Branch 18 → 20 taken 192 times.
long endmatch<(char)44, (char)120>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 1308 times.
✓ Branch 16 → 26 taken 636 times.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 771 times.
✓ Branch 25 → 27 taken 537 times.
✓ Branch 28 → 29 taken 1407 times.
✓ Branch 28 → 30 taken 537 times.
long long endmatch<(char)44, (char)120>(string const&):
✓ Branch 12 → 13 taken 1299 times.
✓ Branch 12 → 16 taken 636 times.
✓ Branch 15 → 16 taken 762 times.
✓ Branch 15 → 17 taken 537 times.
✓ Branch 18 → 19 taken 1398 times.
✓ Branch 18 → 20 taken 537 times.
long endmatch<(char)44, (char)120, (char)41>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 150 times.
✗ Branch 16 → 26 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 30 times.
✓ Branch 25 → 27 taken 120 times.
✓ Branch 28 → 29 taken 30 times.
✓ Branch 28 → 30 taken 120 times.
long long endmatch<(char)44, (char)120, (char)41>(string const&):
✓ Branch 12 → 13 taken 150 times.
✗ Branch 12 → 16 not taken.
✓ Branch 15 → 16 taken 30 times.
✓ Branch 15 → 17 taken 120 times.
✓ Branch 18 → 19 taken 30 times.
✓ Branch 18 → 20 taken 120 times.
long endmatch<(char)44, (char)121>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 813 times.
✓ Branch 16 → 26 taken 636 times.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 732 times.
✓ Branch 25 → 27 taken 81 times.
✓ Branch 28 → 29 taken 1368 times.
✓ Branch 28 → 30 taken 81 times.
long long endmatch<(char)44, (char)121>(string const&):
✓ Branch 12 → 13 taken 804 times.
✓ Branch 12 → 16 taken 636 times.
✓ Branch 15 → 16 taken 723 times.
✓ Branch 15 → 17 taken 81 times.
✓ Branch 18 → 19 taken 1359 times.
✓ Branch 18 → 20 taken 81 times.
long endmatch<(char)93>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 33 times.
✗ Branch 16 → 24 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 33 times.
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 28 taken 33 times.
long long endmatch<(char)93>(string const&):
✓ Branch 12 → 13 taken 33 times.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 33 times.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 33 times.
long endmatch<(char)93, (char)44, (char)121>(string const&):
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 16 not taken.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✓ Branch 16 → 17 taken 105 times.
✗ Branch 16 → 26 not taken.
✗ Branch 18 → 19 not taken.
✗ Branch 18 → 20 not taken.
✓ Branch 25 → 26 taken 33 times.
✓ Branch 25 → 27 taken 72 times.
✓ Branch 28 → 29 taken 33 times.
✓ Branch 28 → 30 taken 72 times.
long long endmatch<(char)93, (char)44, (char)121>(string const&):
✓ Branch 12 → 13 taken 105 times.
✗ Branch 12 → 16 not taken.
✓ Branch 15 → 16 taken 33 times.
✓ Branch 15 → 17 taken 72 times.
✓ Branch 18 → 19 taken 33 times.
✓ Branch 18 → 20 taken 72 times.
|
10995 |
if(haystack_i < 0 || needle[i] != to_lower(haystack[haystack_i--])) return -1; |
| 398 |
|
|
} |
| 399 |
|
990 |
return haystack_i+1; |
| 400 |
|
|
} |
| 401 |
|
|
|
| 402 |
|
|
/* |
| 403 |
|
|
* Parses the address kind from an argument, given a list of allowed address kinds. |
| 404 |
|
|
* Throws "invalid address mode" if the argument does not match any kinds. |
| 405 |
|
|
*/ |
| 406 |
|
|
// i still don't like this function... |
| 407 |
|
4245 |
static parse_result parse_addr_kind(const string& arg, uint32_t allowed_kinds_mask) { |
| 408 |
|
4245 |
int64_t start_i = 0, end_i = arg.length(); |
| 409 |
|
|
// If this addressing kind is allowed, return it, along with a trimmed version of the string. |
| 410 |
|
|
#define RETURN_IF_ALLOWED(kind) \ |
| 411 |
|
|
if (allowed_kinds_mask & 1<<(uint32_t)addr_kind::kind) { \ |
| 412 |
|
|
string out(arg.data() + start_i, end_i - start_i); \ |
| 413 |
|
|
return parse_result{addr_kind::kind, out}; \ |
| 414 |
|
|
} |
| 415 |
4/4
✓ Branch 4 → 5 taken 285 times.
✓ Branch 4 → 15 taken 1830 times.
✓ Branch 5 → 6 taken 291 times.
✓ Branch 5 → 23 taken 1839 times.
|
4245 |
if((start_i = startmatch<'#'>(arg)) >= 0) { |
| 416 |
6/12
✓ Branch 5 → 6 taken 285 times.
✗ Branch 5 → 12 not taken.
✓ Branch 6 → 7 taken 291 times.
✗ Branch 6 → 20 not taken.
✓ Branch 7 → 8 taken 285 times.
✗ Branch 7 → 168 not taken.
✓ Branch 8 → 9 taken 285 times.
✗ Branch 8 → 166 not taken.
✓ Branch 11 → 12 taken 291 times.
✗ Branch 11 → 261 not taken.
✓ Branch 16 → 17 taken 291 times.
✗ Branch 16 → 259 not taken.
|
576 |
RETURN_IF_ALLOWED(imm); |
| 417 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 418 |
|
|
} |
| 419 |
4/4
✓ Branch 16 → 17 taken 108 times.
✓ Branch 16 → 63 taken 1722 times.
✓ Branch 24 → 25 taken 108 times.
✓ Branch 24 → 99 taken 1731 times.
|
3669 |
if((start_i = startmatch<'('>(arg)) >= 0) { |
| 420 |
|
|
// TODO check if the end of this paren is where it should be |
| 421 |
4/4
✓ Branch 18 → 19 taken 24 times.
✓ Branch 18 → 29 taken 84 times.
✓ Branch 26 → 27 taken 24 times.
✓ Branch 26 → 44 taken 84 times.
|
216 |
if((end_i = endmatch<',', 's', ')', ',', 'y'>(arg)) >= 0) { |
| 422 |
6/12
✓ Branch 19 → 20 taken 24 times.
✗ Branch 19 → 26 not taken.
✓ Branch 21 → 22 taken 24 times.
✗ Branch 21 → 171 not taken.
✓ Branch 22 → 23 taken 24 times.
✗ Branch 22 → 169 not taken.
✓ Branch 27 → 28 taken 24 times.
✗ Branch 27 → 41 not taken.
✓ Branch 32 → 33 taken 24 times.
✗ Branch 32 → 265 not taken.
✓ Branch 37 → 38 taken 24 times.
✗ Branch 37 → 263 not taken.
|
48 |
RETURN_IF_ALLOWED(sy); |
| 423 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 424 |
|
|
} |
| 425 |
4/4
✓ Branch 30 → 31 taken 24 times.
✓ Branch 30 → 41 taken 60 times.
✓ Branch 45 → 46 taken 24 times.
✓ Branch 45 → 63 taken 60 times.
|
168 |
if((end_i = endmatch<')', ',', 'y'>(arg)) >= 0) { |
| 426 |
6/12
✓ Branch 31 → 32 taken 24 times.
✗ Branch 31 → 38 not taken.
✓ Branch 33 → 34 taken 24 times.
✗ Branch 33 → 174 not taken.
✓ Branch 34 → 35 taken 24 times.
✗ Branch 34 → 172 not taken.
✓ Branch 46 → 47 taken 24 times.
✗ Branch 46 → 60 not taken.
✓ Branch 51 → 52 taken 24 times.
✗ Branch 51 → 269 not taken.
✓ Branch 56 → 57 taken 24 times.
✗ Branch 56 → 267 not taken.
|
48 |
RETURN_IF_ALLOWED(indy); |
| 427 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 428 |
|
|
} |
| 429 |
4/4
✓ Branch 42 → 43 taken 30 times.
✓ Branch 42 → 53 taken 30 times.
✓ Branch 64 → 65 taken 30 times.
✓ Branch 64 → 82 taken 30 times.
|
120 |
if((end_i = endmatch<',', 'x', ')'>(arg)) >= 0) { |
| 430 |
6/12
✓ Branch 43 → 44 taken 30 times.
✗ Branch 43 → 50 not taken.
✓ Branch 45 → 46 taken 30 times.
✗ Branch 45 → 177 not taken.
✓ Branch 46 → 47 taken 30 times.
✗ Branch 46 → 175 not taken.
✓ Branch 65 → 66 taken 30 times.
✗ Branch 65 → 79 not taken.
✓ Branch 70 → 71 taken 30 times.
✗ Branch 70 → 273 not taken.
✓ Branch 75 → 76 taken 30 times.
✗ Branch 75 → 271 not taken.
|
60 |
RETURN_IF_ALLOWED(xind); |
| 431 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 432 |
|
|
} |
| 433 |
2/4
✓ Branch 54 → 55 taken 30 times.
✗ Branch 54 → 63 not taken.
✓ Branch 83 → 84 taken 30 times.
✗ Branch 83 → 99 not taken.
|
60 |
if((end_i = endmatch<')'>(arg)) >= 0) { |
| 434 |
6/12
✓ Branch 55 → 56 taken 30 times.
✗ Branch 55 → 62 not taken.
✓ Branch 57 → 58 taken 30 times.
✗ Branch 57 → 180 not taken.
✓ Branch 58 → 59 taken 30 times.
✗ Branch 58 → 178 not taken.
✓ Branch 84 → 85 taken 30 times.
✗ Branch 84 → 98 not taken.
✓ Branch 89 → 90 taken 30 times.
✗ Branch 89 → 277 not taken.
✓ Branch 94 → 95 taken 30 times.
✗ Branch 94 → 275 not taken.
|
60 |
RETURN_IF_ALLOWED(ind); |
| 435 |
|
✗ |
throw_warning(1, warn_assuming_address_mode, "($00)", "$00", " (if this was intentional, add a +0 after the parentheses.)"); |
| 436 |
|
|
} |
| 437 |
|
|
} |
| 438 |
4/4
✓ Branch 64 → 65 taken 57 times.
✓ Branch 64 → 89 taken 1665 times.
✓ Branch 100 → 101 taken 57 times.
✓ Branch 100 → 139 taken 1674 times.
|
3453 |
if((start_i = startmatch<'['>(arg)) >= 0) { |
| 439 |
4/4
✓ Branch 66 → 67 taken 24 times.
✓ Branch 66 → 77 taken 33 times.
✓ Branch 102 → 103 taken 24 times.
✓ Branch 102 → 120 taken 33 times.
|
114 |
if((end_i = endmatch<']', ',', 'y'>(arg)) >= 0) { |
| 440 |
6/12
✓ Branch 67 → 68 taken 24 times.
✗ Branch 67 → 74 not taken.
✓ Branch 69 → 70 taken 24 times.
✗ Branch 69 → 183 not taken.
✓ Branch 70 → 71 taken 24 times.
✗ Branch 70 → 181 not taken.
✓ Branch 103 → 104 taken 24 times.
✗ Branch 103 → 117 not taken.
✓ Branch 108 → 109 taken 24 times.
✗ Branch 108 → 281 not taken.
✓ Branch 113 → 114 taken 24 times.
✗ Branch 113 → 279 not taken.
|
48 |
RETURN_IF_ALLOWED(lindy); |
| 441 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 442 |
|
|
} |
| 443 |
2/4
✓ Branch 78 → 79 taken 33 times.
✗ Branch 78 → 89 not taken.
✓ Branch 121 → 122 taken 33 times.
✗ Branch 121 → 139 not taken.
|
66 |
if((end_i = endmatch<']'>(arg)) >= 0) { |
| 444 |
6/12
✓ Branch 79 → 80 taken 33 times.
✗ Branch 79 → 86 not taken.
✓ Branch 81 → 82 taken 33 times.
✗ Branch 81 → 186 not taken.
✓ Branch 82 → 83 taken 33 times.
✗ Branch 82 → 184 not taken.
✓ Branch 122 → 123 taken 33 times.
✗ Branch 122 → 136 not taken.
✓ Branch 127 → 128 taken 33 times.
✗ Branch 127 → 285 not taken.
✓ Branch 132 → 133 taken 33 times.
✗ Branch 132 → 283 not taken.
|
66 |
RETURN_IF_ALLOWED(lind); |
| 445 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 446 |
|
|
} |
| 447 |
|
|
} |
| 448 |
|
3339 |
start_i = 0; |
| 449 |
4/4
✓ Branch 90 → 91 taken 267 times.
✓ Branch 90 → 101 taken 1398 times.
✓ Branch 140 → 141 taken 267 times.
✓ Branch 140 → 158 taken 1407 times.
|
3339 |
if((end_i = endmatch<',', 'x'>(arg)) >= 0) { |
| 450 |
6/12
✓ Branch 91 → 92 taken 267 times.
✗ Branch 91 → 98 not taken.
✓ Branch 93 → 94 taken 267 times.
✗ Branch 93 → 189 not taken.
✓ Branch 94 → 95 taken 267 times.
✗ Branch 94 → 187 not taken.
✓ Branch 141 → 142 taken 267 times.
✗ Branch 141 → 155 not taken.
✓ Branch 146 → 147 taken 267 times.
✗ Branch 146 → 289 not taken.
✓ Branch 151 → 152 taken 267 times.
✗ Branch 151 → 287 not taken.
|
534 |
RETURN_IF_ALLOWED(x); |
| 451 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 452 |
|
|
} |
| 453 |
4/4
✓ Branch 102 → 103 taken 39 times.
✓ Branch 102 → 113 taken 1359 times.
✓ Branch 159 → 160 taken 39 times.
✓ Branch 159 → 177 taken 1368 times.
|
2805 |
if((end_i = endmatch<',', 'y'>(arg)) >= 0) { |
| 454 |
6/12
✓ Branch 103 → 104 taken 39 times.
✗ Branch 103 → 110 not taken.
✓ Branch 105 → 106 taken 39 times.
✗ Branch 105 → 192 not taken.
✓ Branch 106 → 107 taken 39 times.
✗ Branch 106 → 190 not taken.
✓ Branch 160 → 161 taken 39 times.
✗ Branch 160 → 174 not taken.
✓ Branch 165 → 166 taken 39 times.
✗ Branch 165 → 293 not taken.
✓ Branch 170 → 171 taken 39 times.
✗ Branch 170 → 291 not taken.
|
78 |
RETURN_IF_ALLOWED(y); |
| 455 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 456 |
|
|
} |
| 457 |
4/4
✓ Branch 114 → 115 taken 24 times.
✓ Branch 114 → 125 taken 1335 times.
✓ Branch 178 → 179 taken 24 times.
✓ Branch 178 → 196 taken 1344 times.
|
2727 |
if((end_i = endmatch<',', 's'>(arg)) >= 0) { |
| 458 |
6/12
✓ Branch 115 → 116 taken 24 times.
✗ Branch 115 → 122 not taken.
✓ Branch 117 → 118 taken 24 times.
✗ Branch 117 → 195 not taken.
✓ Branch 118 → 119 taken 24 times.
✗ Branch 118 → 193 not taken.
✓ Branch 179 → 180 taken 24 times.
✗ Branch 179 → 193 not taken.
✓ Branch 184 → 185 taken 24 times.
✗ Branch 184 → 297 not taken.
✓ Branch 189 → 190 taken 24 times.
✗ Branch 189 → 295 not taken.
|
48 |
RETURN_IF_ALLOWED(s); |
| 459 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 460 |
|
|
} |
| 461 |
|
2679 |
end_i = arg.length(); |
| 462 |
|
|
// hoping that by now, something would have stripped whitespace lol |
| 463 |
4/4
✓ Branch 127 → 128 taken 633 times.
✓ Branch 127 → 138 taken 702 times.
✓ Branch 200 → 201 taken 633 times.
✓ Branch 200 → 218 taken 711 times.
|
2679 |
if(arg.length() == 0) { |
| 464 |
6/12
✓ Branch 128 → 129 taken 633 times.
✗ Branch 128 → 135 not taken.
✓ Branch 130 → 131 taken 633 times.
✗ Branch 130 → 198 not taken.
✓ Branch 131 → 132 taken 633 times.
✗ Branch 131 → 196 not taken.
✓ Branch 201 → 202 taken 633 times.
✗ Branch 201 → 215 not taken.
✓ Branch 206 → 207 taken 633 times.
✗ Branch 206 → 301 not taken.
✓ Branch 211 → 212 taken 633 times.
✗ Branch 211 → 299 not taken.
|
1266 |
RETURN_IF_ALLOWED(imp); |
| 465 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 466 |
|
|
} |
| 467 |
12/12
✓ Branch 139 → 140 taken 699 times.
✓ Branch 139 → 142 taken 3 times.
✓ Branch 141 → 142 taken 18 times.
✓ Branch 141 → 143 taken 681 times.
✓ Branch 144 → 145 taken 21 times.
✓ Branch 144 → 155 taken 681 times.
✓ Branch 219 → 220 taken 708 times.
✓ Branch 219 → 222 taken 3 times.
✓ Branch 221 → 222 taken 18 times.
✓ Branch 221 → 223 taken 690 times.
✓ Branch 224 → 225 taken 21 times.
✓ Branch 224 → 242 taken 690 times.
|
1413 |
if(arg == "a" || arg == "A") { |
| 468 |
8/12
✓ Branch 145 → 146 taken 18 times.
✓ Branch 145 → 152 taken 3 times.
✓ Branch 147 → 148 taken 18 times.
✗ Branch 147 → 201 not taken.
✓ Branch 148 → 149 taken 18 times.
✗ Branch 148 → 199 not taken.
✓ Branch 225 → 226 taken 18 times.
✓ Branch 225 → 239 taken 3 times.
✓ Branch 230 → 231 taken 18 times.
✗ Branch 230 → 305 not taken.
✓ Branch 235 → 236 taken 18 times.
✗ Branch 235 → 303 not taken.
|
42 |
RETURN_IF_ALLOWED(a); |
| 469 |
|
|
// todo: some hint for "don't name your label "a" "? |
| 470 |
|
6 |
throw_err_block(1, err_bad_addr_mode); |
| 471 |
|
|
} |
| 472 |
6/12
✓ Branch 155 → 156 taken 681 times.
✗ Branch 155 → 162 not taken.
✓ Branch 157 → 158 taken 681 times.
✗ Branch 157 → 204 not taken.
✓ Branch 158 → 159 taken 681 times.
✗ Branch 158 → 202 not taken.
✓ Branch 242 → 243 taken 690 times.
✗ Branch 242 → 255 not taken.
✓ Branch 247 → 248 taken 690 times.
✗ Branch 247 → 309 not taken.
✓ Branch 251 → 252 taken 690 times.
✗ Branch 251 → 307 not taken.
|
1371 |
RETURN_IF_ALLOWED(abs); |
| 473 |
|
✗ |
throw_err_block(1, err_bad_addr_mode); |
| 474 |
|
|
#undef RETURN_IF_ALLOWED |
| 475 |
|
|
} |
| 476 |
|
|
|
| 477 |
|
✗ |
static const char* format_valid_widths(int min, int max) { |
| 478 |
|
✗ |
if(min == 1) { |
| 479 |
|
✗ |
if(max == 1) return "only 8-bit"; |
| 480 |
|
✗ |
if(max == 2) return "only 8-bit or 16-bit"; |
| 481 |
|
✗ |
if(max == 3) return "any width"; // shouldn't actually happen lol |
| 482 |
|
✗ |
} else if(min == 2) { |
| 483 |
|
✗ |
if(max == 2) return "only 16-bit"; |
| 484 |
|
✗ |
if(max == 3) return "only 16-bit or 24-bit"; |
| 485 |
|
✗ |
} else if(min == 3) { |
| 486 |
|
✗ |
return "only 24-bit"; |
| 487 |
|
|
} |
| 488 |
|
✗ |
return "???"; |
| 489 |
|
|
} |
| 490 |
|
|
|
| 491 |
|
2784 |
static int get_real_len(int min_len, int max_len, int arg_min_len, char modifier, const parse_result& parsed) { |
| 492 |
|
|
int out_len; |
| 493 |
2/2
✓ Branch 2 → 3 taken 780 times.
✓ Branch 2 → 10 taken 2004 times.
|
2784 |
if(modifier != 0) { |
| 494 |
|
780 |
out_len = getlenfromchar(modifier); |
| 495 |
3/5
✓ Branch 4 → 5 taken 774 times.
✗ Branch 4 → 6 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 27 taken 387 times.
✓ Branch 5 → 34 taken 387 times.
|
774 |
if(out_len < min_len || out_len > max_len) |
| 496 |
|
✗ |
throw_err_block(2, err_bad_access_width, format_valid_widths(min_len, max_len), out_len*8); |
| 497 |
|
|
} else { |
| 498 |
4/4
✓ Branch 10 → 11 taken 156 times.
✓ Branch 10 → 18 taken 840 times.
✓ Branch 11 → 12 taken 159 times.
✓ Branch 11 → 24 taken 849 times.
|
2004 |
if(parsed.kind == addr_kind::imm) { |
| 499 |
4/4
✓ Branch 13 → 14 taken 48 times.
✓ Branch 13 → 15 taken 108 times.
✓ Branch 19 → 20 taken 51 times.
✓ Branch 19 → 21 taken 108 times.
|
315 |
if(!is_hex_constant(parsed.arg.data())) |
| 500 |
|
99 |
throw_warning(2, warn_implicitly_sized_immediate); |
| 501 |
2/8
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 18 taken 156 times.
✗ Branch 16 → 17 not taken.
✗ Branch 16 → 18 not taken.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 24 taken 159 times.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
|
315 |
if(arg_min_len == 3 && max_len == 2) { |
| 502 |
|
|
// lda #label |
| 503 |
|
|
// todo: throw pedantic warning |
| 504 |
|
✗ |
return max_len; |
| 505 |
|
|
} |
| 506 |
|
|
} |
| 507 |
2/4
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 25 taken 996 times.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 31 taken 1008 times.
|
2004 |
if(arg_min_len > max_len) { |
| 508 |
|
|
// we might get here on pass 0 if getlen is wrong about the width, |
| 509 |
|
|
// which can happen with forward labels and namespaces. |
| 510 |
|
|
// in that case return some valid width to silence the error. |
| 511 |
|
✗ |
if(pass == 0) return max_len; |
| 512 |
|
|
|
| 513 |
|
✗ |
throw_err_block(2, err_bad_access_width, format_valid_widths(min_len, max_len), arg_min_len*8); |
| 514 |
|
|
} |
| 515 |
|
|
// todo warn about widening when dpbase != 0 |
| 516 |
|
2004 |
out_len = std::max(arg_min_len, min_len); |
| 517 |
|
|
} |
| 518 |
|
2778 |
return out_len; |
| 519 |
|
|
} |
| 520 |
|
|
|
| 521 |
|
24 |
static int64_t get_branch_value(parse_result& parsed, char modifier, int width) { |
| 522 |
4/4
✓ Branch 3 → 4 taken 11 times.
✓ Branch 3 → 76 taken 1 time.
✓ Branch 7 → 8 taken 11 times.
✓ Branch 7 → 105 taken 1 time.
|
24 |
auto expr = parse_math_expr(parsed.arg); |
| 523 |
4/8
✓ Branch 6 → 7 taken 11 times.
✗ Branch 6 → 61 not taken.
✓ Branch 7 → 8 taken 11 times.
✗ Branch 7 → 59 not taken.
✓ Branch 15 → 16 taken 11 times.
✗ Branch 15 → 85 not taken.
✓ Branch 17 → 18 taken 11 times.
✗ Branch 17 → 83 not taken.
|
44 |
int64_t num = expr->evaluate().get_integer(); |
| 524 |
2/4
✓ Branch 11 → 12 taken 11 times.
✗ Branch 11 → 74 not taken.
✓ Branch 29 → 30 taken 11 times.
✗ Branch 29 → 103 not taken.
|
22 |
bool target_is_abs = expr->has_label() > 0; |
| 525 |
2/4
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 27 taken 11 times.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 45 taken 11 times.
|
22 |
if(modifier != 0) { |
| 526 |
|
✗ |
if(to_lower(modifier) == 'a') target_is_abs = true; |
| 527 |
|
✗ |
else if(to_lower(modifier) == 'r') target_is_abs = false; |
| 528 |
|
|
// ignore for backwards compat |
| 529 |
|
✗ |
else if(to_lower(modifier) == (width == 2 ? 'w' : 'b')) {} |
| 530 |
|
|
// TODO: better error message |
| 531 |
|
✗ |
else throw_err_block(2, err_invalid_opcode_length); |
| 532 |
|
|
} |
| 533 |
4/4
✓ Branch 27 → 28 taken 10 times.
✓ Branch 27 → 43 taken 1 time.
✓ Branch 45 → 46 taken 10 times.
✓ Branch 45 → 65 taken 1 time.
|
22 |
if(target_is_abs) { |
| 534 |
|
|
// cast delta to signed 16-bit, this makes it possible to handle bank-border-wrapping automatically |
| 535 |
|
20 |
int16_t delta = num - (snespos + width + 1); |
| 536 |
2/4
✗ Branch 28 → 29 not taken.
✓ Branch 28 → 34 taken 10 times.
✗ Branch 46 → 47 not taken.
✓ Branch 46 → 54 taken 10 times.
|
20 |
if((num & ~0xffff) != (snespos & ~0xffff)) { |
| 537 |
|
|
// todo: should throw error "can't branch to different bank" |
| 538 |
|
✗ |
throw_err_block(2, err_relative_branch_out_of_bounds, dec(delta).data()); |
| 539 |
|
|
} |
| 540 |
8/12
✓ Branch 34 → 35 taken 9 times.
✓ Branch 34 → 42 taken 1 time.
✓ Branch 35 → 36 taken 9 times.
✗ Branch 35 → 37 not taken.
✗ Branch 36 → 37 not taken.
✓ Branch 36 → 42 taken 9 times.
✓ Branch 54 → 55 taken 9 times.
✓ Branch 54 → 64 taken 1 time.
✓ Branch 55 → 56 taken 9 times.
✗ Branch 55 → 57 not taken.
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 64 taken 9 times.
|
20 |
if(width==1 && (delta < -128 || delta > 127)) { |
| 541 |
|
✗ |
throw_err_block(2, err_relative_branch_out_of_bounds, dec(delta).data()); |
| 542 |
|
|
} |
| 543 |
|
20 |
return delta; |
| 544 |
|
|
} else { |
| 545 |
4/8
✓ Branch 43 → 44 taken 1 time.
✗ Branch 43 → 45 not taken.
✗ Branch 46 → 47 not taken.
✓ Branch 46 → 52 taken 1 time.
✓ Branch 65 → 66 taken 1 time.
✗ Branch 65 → 67 not taken.
✗ Branch 68 → 69 not taken.
✓ Branch 68 → 76 taken 1 time.
|
2 |
if(num & ~(width==2 ? 0xffff : 0xff)) { |
| 546 |
|
✗ |
throw_err_block(2, err_relative_branch_out_of_bounds, dec(num).data()); |
| 547 |
|
|
} |
| 548 |
2/4
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 1 time.
✗ Branch 76 → 77 not taken.
✓ Branch 76 → 78 taken 1 time.
|
2 |
return (int16_t)(width==2 ? num : (int8_t)num); |
| 549 |
|
|
} |
| 550 |
|
44 |
} |
| 551 |
|
|
|
| 552 |
|
26015 |
bool asblock_65816(const string& firstword, const char* par) |
| 553 |
|
|
{ |
| 554 |
|
|
// first find the mnemonic from the first word |
| 555 |
|
26015 |
bool autoclean = false; |
| 556 |
|
26015 |
string mnem; |
| 557 |
4/4
✓ Branch 5 → 6 taken 81 times.
✓ Branch 5 → 7 taken 12805 times.
✓ Branch 7 → 8 taken 81 times.
✓ Branch 7 → 9 taken 13048 times.
|
26015 |
if(!stricmpwithlower(firstword, "autoclean")) { |
| 558 |
|
162 |
autoclean = true; |
| 559 |
2/5
✓ Branch 6 → 8 taken 81 times.
✗ Branch 6 → 183 not taken.
✗ Branch 6 → 185 not taken.
✓ Branch 8 → 10 taken 81 times.
✗ Branch 8 → 282 not taken.
|
162 |
grab_until_space(mnem, par); |
| 560 |
|
|
} else { |
| 561 |
2/5
✓ Branch 7 → 8 taken 12805 times.
✗ Branch 7 → 183 not taken.
✗ Branch 7 → 185 not taken.
✓ Branch 9 → 10 taken 13048 times.
✗ Branch 9 → 282 not taken.
|
25853 |
mnem = firstword; |
| 562 |
|
|
} |
| 563 |
|
26015 |
lower(mnem); |
| 564 |
|
|
|
| 565 |
|
26015 |
char modifier = 0; |
| 566 |
12/12
✓ Branch 10 → 11 taken 12835 times.
✓ Branch 10 → 15 taken 51 times.
✓ Branch 12 → 13 taken 13078 times.
✓ Branch 12 → 19 taken 51 times.
✓ Branch 13 → 14 taken 390 times.
✓ Branch 13 → 15 taken 12445 times.
✓ Branch 16 → 17 taken 390 times.
✓ Branch 16 → 21 taken 12496 times.
✓ Branch 17 → 18 taken 390 times.
✓ Branch 17 → 19 taken 12688 times.
✓ Branch 20 → 21 taken 390 times.
✓ Branch 20 → 27 taken 12739 times.
|
26015 |
if(mnem.length() >= 2 && mnem[mnem.length()-2] == '.') { |
| 567 |
|
780 |
modifier = mnem[mnem.length()-1]; |
| 568 |
2/5
✓ Branch 20 → 21 taken 390 times.
✗ Branch 20 → 183 not taken.
✗ Branch 20 → 185 not taken.
✓ Branch 26 → 27 taken 390 times.
✗ Branch 26 → 282 not taken.
|
780 |
mnem.truncate(mnem.length()-2); |
| 569 |
|
|
} |
| 570 |
|
|
|
| 571 |
|
26015 |
frozen::string mnem2(mnem.data(), mnem.length()); |
| 572 |
2/5
✓ Branch 24 → 25 taken 12886 times.
✗ Branch 24 → 183 not taken.
✗ Branch 24 → 185 not taken.
✓ Branch 31 → 32 taken 13129 times.
✗ Branch 31 → 282 not taken.
|
26015 |
auto it = mnemonic_lookup.find(mnem2); |
| 573 |
4/4
✓ Branch 26 → 27 taken 10765 times.
✓ Branch 26 → 28 taken 2121 times.
✓ Branch 33 → 34 taken 10993 times.
✓ Branch 33 → 35 taken 2136 times.
|
26015 |
if(it == mnemonic_lookup.end()) return false; |
| 574 |
|
4257 |
const mnemonicinfo& mnem_info = it->second; |
| 575 |
|
|
|
| 576 |
|
|
// check if we're doing mvn/mvp, and if yes, parse completely differently |
| 577 |
|
|
// this is a little hacky, sorry... |
| 578 |
4/4
✓ Branch 28 → 29 taken 6 times.
✓ Branch 28 → 71 taken 2115 times.
✓ Branch 42 → 43 taken 6 times.
✓ Branch 42 → 95 taken 2130 times.
|
4257 |
if(mnem_info.allowed_kinds_mask & 1<<(uint32_t)addr_kind::mvn) { |
| 579 |
|
12 |
int count = 0; |
| 580 |
2/5
✓ Branch 29 → 30 taken 6 times.
✗ Branch 29 → 160 not taken.
✗ Branch 29 → 162 not taken.
✓ Branch 45 → 46 taken 6 times.
✗ Branch 45 → 248 not taken.
|
12 |
string parbuf = par; |
| 581 |
2/5
✓ Branch 31 → 32 taken 6 times.
✗ Branch 31 → 158 not taken.
✗ Branch 31 → 160 not taken.
✓ Branch 48 → 49 taken 6 times.
✗ Branch 48 → 246 not taken.
|
12 |
autoptr<char**> parts = qpsplit(parbuf.raw(), ',', &count); |
| 582 |
2/9
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 37 taken 6 times.
✗ Branch 34 → 35 not taken.
✗ Branch 34 → 156 not taken.
✗ Branch 34 → 158 not taken.
✗ Branch 50 → 51 not taken.
✓ Branch 50 → 54 taken 6 times.
✗ Branch 51 → 52 not taken.
✗ Branch 51 → 244 not taken.
|
12 |
if(count != 2) throw_err_block(2, err_bad_addr_mode); |
| 583 |
|
12 |
uint8_t opcode = mnem_info.types[(int)addr_kind::mvn].opcode_for_width[2]; |
| 584 |
2/5
✓ Branch 37 → 38 taken 6 times.
✗ Branch 37 → 156 not taken.
✗ Branch 37 → 158 not taken.
✓ Branch 56 → 57 taken 6 times.
✗ Branch 56 → 244 not taken.
|
12 |
write1(opcode); |
| 585 |
|
12 |
int64_t num1 = 0, num2 = 0; |
| 586 |
4/4
✓ Branch 38 → 39 taken 2 times.
✓ Branch 38 → 44 taken 4 times.
✓ Branch 57 → 58 taken 2 times.
✓ Branch 57 → 66 taken 4 times.
|
12 |
if(pass == 2) { |
| 587 |
2/5
✓ Branch 40 → 41 taken 2 times.
✗ Branch 40 → 156 not taken.
✗ Branch 40 → 158 not taken.
✓ Branch 60 → 61 taken 2 times.
✗ Branch 60 → 244 not taken.
|
4 |
num1 = getnum(parts[0]); |
| 588 |
2/5
✓ Branch 42 → 43 taken 2 times.
✗ Branch 42 → 156 not taken.
✗ Branch 42 → 158 not taken.
✓ Branch 64 → 65 taken 2 times.
✗ Branch 64 → 244 not taken.
|
4 |
num2 = getnum(parts[1]); |
| 589 |
|
|
} |
| 590 |
4/17
✓ Branch 44 → 45 taken 6 times.
✗ Branch 44 → 46 not taken.
✗ Branch 45 → 46 not taken.
✓ Branch 45 → 53 taken 6 times.
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 48 not taken.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 156 not taken.
✗ Branch 50 → 158 not taken.
✓ Branch 66 → 67 taken 6 times.
✗ Branch 66 → 68 not taken.
✗ Branch 67 → 68 not taken.
✓ Branch 67 → 75 taken 6 times.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 70 not taken.
✗ Branch 72 → 73 not taken.
✗ Branch 72 → 244 not taken.
|
12 |
if(num1 < 0 || num1 > 255) throw_err_block(2, err_bad_access_width, format_valid_widths(1, 1), num1 > 65535 ? 24 : 16); |
| 591 |
4/17
✓ Branch 53 → 54 taken 6 times.
✗ Branch 53 → 55 not taken.
✗ Branch 54 → 55 not taken.
✓ Branch 54 → 62 taken 6 times.
✗ Branch 55 → 56 not taken.
✗ Branch 55 → 57 not taken.
✗ Branch 59 → 60 not taken.
✗ Branch 59 → 156 not taken.
✗ Branch 59 → 158 not taken.
✓ Branch 75 → 76 taken 6 times.
✗ Branch 75 → 77 not taken.
✗ Branch 76 → 77 not taken.
✓ Branch 76 → 84 taken 6 times.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 244 not taken.
|
12 |
if(num2 < 0 || num2 > 255) throw_err_block(2, err_bad_access_width, format_valid_widths(1, 1), num2 > 65535 ? 24 : 16); |
| 592 |
2/5
✓ Branch 62 → 63 taken 6 times.
✗ Branch 62 → 156 not taken.
✗ Branch 62 → 158 not taken.
✓ Branch 84 → 85 taken 6 times.
✗ Branch 84 → 244 not taken.
|
12 |
write1(num1); |
| 593 |
2/5
✓ Branch 63 → 64 taken 6 times.
✗ Branch 63 → 156 not taken.
✗ Branch 63 → 158 not taken.
✓ Branch 85 → 86 taken 6 times.
✗ Branch 85 → 244 not taken.
|
12 |
write1(num2); |
| 594 |
|
|
// a bit hacky to check this here, but we kinda do need to early-return here |
| 595 |
2/9
✗ Branch 64 → 65 not taken.
✓ Branch 64 → 68 taken 6 times.
✗ Branch 65 → 66 not taken.
✗ Branch 65 → 156 not taken.
✗ Branch 65 → 158 not taken.
✗ Branch 86 → 87 not taken.
✓ Branch 86 → 90 taken 6 times.
✗ Branch 87 → 88 not taken.
✗ Branch 87 → 244 not taken.
|
12 |
if(autoclean) throw_err_block(2, err_broken_autoclean); |
| 596 |
|
12 |
return true; |
| 597 |
|
12 |
} |
| 598 |
6/10
✓ Branch 71 → 72 taken 2115 times.
✗ Branch 71 → 163 not taken.
✗ Branch 71 → 165 not taken.
✓ Branch 72 → 73 taken 2112 times.
✗ Branch 72 → 161 not taken.
✓ Branch 72 → 163 taken 3 times.
✓ Branch 99 → 100 taken 2130 times.
✗ Branch 99 → 254 not taken.
✓ Branch 101 → 102 taken 2127 times.
✓ Branch 101 → 252 taken 3 times.
|
4251 |
parse_result parse_res = parse_addr_kind(par, mnem_info.allowed_kinds_mask); |
| 599 |
|
4239 |
const mnem_kind_info& kind_info = mnem_info.types[(uint32_t)parse_res.kind]; |
| 600 |
|
|
|
| 601 |
|
|
// figure out the minimum/maximum argument width for this mnemonic+addr_kind combo |
| 602 |
|
|
// todo this is mildly jank |
| 603 |
|
|
// we also kinda implicitly assume that no insn has "gaps" in its allowed widths |
| 604 |
|
4239 |
int min_w = 99; |
| 605 |
|
4239 |
int max_w = 0; |
| 606 |
4/4
✓ Branch 80 → 75 taken 16896 times.
✓ Branch 80 → 81 taken 2112 times.
✓ Branch 125 → 115 taken 17016 times.
✓ Branch 125 → 126 taken 2127 times.
|
38151 |
for(int i = 0; i < 8; i++) { |
| 607 |
5/6
✓ Branch 75 → 76 taken 3630 times.
✓ Branch 75 → 79 taken 13266 times.
✗ Branch 115 → 116 not taken.
✓ Branch 115 → 117 taken 17016 times.
✓ Branch 118 → 119 taken 3654 times.
✓ Branch 118 → 124 taken 13362 times.
|
33912 |
if(kind_info.allowed_widths & 1<<i) { |
| 608 |
|
7284 |
min_w = std::min(min_w, i); |
| 609 |
|
7284 |
max_w = std::max(max_w, i); |
| 610 |
|
|
} |
| 611 |
|
|
} |
| 612 |
|
|
|
| 613 |
|
|
// compute argument value |
| 614 |
8/8
✓ Branch 81 → 82 taken 285 times.
✓ Branch 81 → 84 taken 1827 times.
✓ Branch 82 → 83 taken 36 times.
✓ Branch 82 → 84 taken 249 times.
✓ Branch 127 → 128 taken 291 times.
✓ Branch 127 → 132 taken 1836 times.
✓ Branch 130 → 131 taken 39 times.
✓ Branch 130 → 132 taken 252 times.
|
4239 |
bool is_implied_rep = parse_res.kind == addr_kind::imm && (kind_info.flags & flag_implied_rep); |
| 615 |
|
|
int arg_len; |
| 616 |
|
|
int64_t arg_value; |
| 617 |
|
4239 |
int64_t rep_count = 0; |
| 618 |
4/5
✓ Branch 85 → 86 taken 36 times.
✗ Branch 85 → 93 not taken.
✓ Branch 85 → 94 taken 2076 times.
✓ Branch 135 → 136 taken 36 times.
✓ Branch 135 → 143 taken 2091 times.
|
4239 |
if(kind_info.flags & flag_branch) { |
| 619 |
2/4
✗ Branch 86 → 87 not taken.
✓ Branch 86 → 88 taken 36 times.
✗ Branch 136 → 137 not taken.
✓ Branch 136 → 138 taken 36 times.
|
72 |
assert(min_w == max_w); // can't call get_real_len, but there should be only one width anyways |
| 620 |
|
72 |
arg_len = min_w; |
| 621 |
8/11
✗ Branch 88 → 89 not taken.
✗ Branch 88 → 91 not taken.
✓ Branch 89 → 90 taken 12 times.
✓ Branch 89 → 92 taken 24 times.
✗ Branch 89 → 181 not taken.
✓ Branch 90 → 91 taken 11 times.
✓ Branch 90 → 183 taken 1 time.
✓ Branch 138 → 139 taken 12 times.
✓ Branch 138 → 141 taken 24 times.
✓ Branch 139 → 140 taken 11 times.
✓ Branch 139 → 280 taken 1 time.
|
72 |
arg_value = pass == 2 ? get_branch_value(parse_res, modifier, arg_len) : 0; |
| 622 |
4/6
✗ Branch 93 → 94 not taken.
✗ Branch 93 → 102 not taken.
✓ Branch 94 → 95 taken 36 times.
✓ Branch 94 → 103 taken 2040 times.
✓ Branch 143 → 144 taken 39 times.
✓ Branch 143 → 157 taken 2052 times.
|
4167 |
} else if(is_implied_rep) { |
| 623 |
|
75 |
arg_len = 0; |
| 624 |
6/17
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 168 not taken.
✓ Branch 96 → 97 taken 36 times.
✗ Branch 96 → 170 not taken.
✗ Branch 97 → 98 not taken.
✗ Branch 97 → 166 not taken.
✓ Branch 98 → 99 taken 36 times.
✗ Branch 98 → 164 not taken.
✗ Branch 98 → 168 not taken.
✓ Branch 99 → 100 taken 36 times.
✗ Branch 99 → 166 not taken.
✓ Branch 147 → 148 taken 39 times.
✗ Branch 147 → 260 not taken.
✓ Branch 150 → 151 taken 39 times.
✗ Branch 150 → 258 not taken.
✓ Branch 152 → 153 taken 39 times.
✗ Branch 152 → 256 not taken.
|
75 |
rep_count = parse_math_expr(parse_res.arg)->evaluate_static().get_integer(); |
| 625 |
8/10
✗ Branch 102 → 103 not taken.
✗ Branch 102 → 104 not taken.
✓ Branch 103 → 104 taken 1407 times.
✓ Branch 103 → 105 taken 633 times.
✓ Branch 104 → 105 taken 18 times.
✓ Branch 104 → 106 taken 1389 times.
✓ Branch 157 → 158 taken 1419 times.
✓ Branch 157 → 159 taken 633 times.
✓ Branch 158 → 159 taken 18 times.
✓ Branch 158 → 160 taken 1401 times.
|
4092 |
} else if(parse_res.kind == addr_kind::imp || parse_res.kind == addr_kind::a) { |
| 626 |
|
1302 |
arg_len = 0; |
| 627 |
|
|
} else { |
| 628 |
|
2790 |
int old_optimize = optimizeforbank; |
| 629 |
4/6
✗ Branch 105 → 106 not taken.
✗ Branch 105 → 107 not taken.
✓ Branch 106 → 107 taken 12 times.
✓ Branch 106 → 108 taken 1377 times.
✓ Branch 162 → 163 taken 12 times.
✓ Branch 162 → 164 taken 1389 times.
|
2790 |
if(kind_info.flags & flag_bank_0) optimizeforbank = 0; |
| 630 |
4/6
✗ Branch 107 → 108 not taken.
✗ Branch 107 → 109 not taken.
✓ Branch 108 → 109 taken 30 times.
✓ Branch 108 → 110 taken 1347 times.
✓ Branch 166 → 167 taken 36 times.
✓ Branch 166 → 168 taken 1353 times.
|
2766 |
else if(kind_info.flags & flag_bank_k) optimizeforbank = -1; |
| 631 |
4/6
✗ Branch 110 → 111 not taken.
✗ Branch 110 → 180 not taken.
✓ Branch 111 → 112 taken 1386 times.
✓ Branch 111 → 182 taken 3 times.
✓ Branch 170 → 171 taken 1398 times.
✓ Branch 170 → 278 taken 3 times.
|
2790 |
auto math_parsed = parse_math_expr(parse_res.arg); |
| 632 |
2/6
✗ Branch 112 → 113 not taken.
✗ Branch 112 → 178 not taken.
✓ Branch 113 → 114 taken 1386 times.
✗ Branch 113 → 180 not taken.
✓ Branch 178 → 179 taken 1398 times.
✗ Branch 178 → 276 not taken.
|
2784 |
int arg_min_len = math_parsed->get_len(parse_res.kind == addr_kind::imm); |
| 633 |
4/6
✗ Branch 113 → 114 not taken.
✗ Branch 113 → 178 not taken.
✓ Branch 114 → 115 taken 1383 times.
✓ Branch 114 → 180 taken 3 times.
✓ Branch 179 → 180 taken 1395 times.
✓ Branch 179 → 276 taken 3 times.
|
2784 |
arg_len = get_real_len(min_w, max_w, arg_min_len, modifier, parse_res); |
| 634 |
|
2778 |
optimizeforbank = old_optimize; |
| 635 |
28/49
✗ Branch 114 → 115 not taken.
✗ Branch 114 → 120 not taken.
✓ Branch 115 → 116 taken 461 times.
✓ Branch 115 → 121 taken 922 times.
✗ Branch 117 → 118 not taken.
✗ Branch 117 → 170 not taken.
✓ Branch 118 → 119 taken 460 times.
✗ Branch 118 → 170 not taken.
✓ Branch 118 → 172 taken 1 time.
✓ Branch 119 → 120 taken 460 times.
✗ Branch 119 → 172 not taken.
✗ Branch 121 → 122 not taken.
✗ Branch 121 → 123 not taken.
✓ Branch 122 → 123 taken 460 times.
✓ Branch 122 → 124 taken 922 times.
✗ Branch 123 → 124 not taken.
✗ Branch 123 → 125 not taken.
✓ Branch 124 → 125 taken 460 times.
✓ Branch 124 → 126 taken 922 times.
✗ Branch 170 → 171 not taken.
✗ Branch 170 → 172 not taken.
✗ Branch 172 → 173 not taken.
✓ Branch 172 → 174 taken 1 time.
✗ Branch 174 → 175 not taken.
✗ Branch 174 → 176 not taken.
✓ Branch 176 → 177 taken 1 time.
✗ Branch 176 → 178 not taken.
✓ Branch 180 → 181 taken 465 times.
✓ Branch 180 → 192 taken 930 times.
✓ Branch 188 → 189 taken 464 times.
✓ Branch 188 → 264 taken 1 time.
✓ Branch 190 → 191 taken 464 times.
✗ Branch 190 → 264 not taken.
✓ Branch 193 → 194 taken 464 times.
✓ Branch 193 → 195 taken 930 times.
✓ Branch 195 → 196 taken 464 times.
✓ Branch 195 → 197 taken 930 times.
✓ Branch 197 → 198 taken 464 times.
✓ Branch 197 → 199 taken 930 times.
✓ Branch 199 → 200 taken 464 times.
✓ Branch 199 → 201 taken 930 times.
✗ Branch 264 → 265 not taken.
✓ Branch 264 → 266 taken 1 time.
✓ Branch 267 → 268 taken 1 time.
✗ Branch 267 → 269 not taken.
✓ Branch 270 → 271 taken 1 time.
✗ Branch 270 → 272 not taken.
✓ Branch 273 → 274 taken 1 time.
✗ Branch 273 → 275 not taken.
|
3709 |
arg_value = pass == 2 ? math_parsed->evaluate().get_integer() : 0; |
| 636 |
|
2784 |
} |
| 637 |
|
|
|
| 638 |
3/8
✗ Branch 127 → 128 not taken.
✗ Branch 127 → 129 not taken.
✗ Branch 128 → 129 not taken.
✓ Branch 128 → 130 taken 2104 times.
✗ Branch 203 → 204 not taken.
✓ Branch 203 → 205 taken 2119 times.
✗ Branch 206 → 207 not taken.
✓ Branch 206 → 208 taken 2119 times.
|
4223 |
assert((kind_info.allowed_widths & 1<<arg_len) != 0); |
| 639 |
|
4223 |
uint8_t opcode = kind_info.opcode_for_width[arg_len]; |
| 640 |
|
|
|
| 641 |
8/12
✗ Branch 129 → 130 not taken.
✗ Branch 129 → 132 not taken.
✗ Branch 130 → 131 not taken.
✗ Branch 130 → 132 not taken.
✓ Branch 131 → 132 taken 687 times.
✓ Branch 131 → 134 taken 1417 times.
✓ Branch 132 → 133 taken 9 times.
✓ Branch 132 → 134 taken 678 times.
✓ Branch 211 → 212 taken 690 times.
✓ Branch 211 → 216 taken 1429 times.
✓ Branch 214 → 215 taken 9 times.
✓ Branch 214 → 216 taken 681 times.
|
4223 |
if(arg_len == 0 && (kind_info.flags & flag_imm_implied_0)) { |
| 642 |
|
18 |
arg_len = 1; |
| 643 |
|
18 |
arg_value = 0; |
| 644 |
|
|
} |
| 645 |
|
|
|
| 646 |
4/6
✗ Branch 132 → 133 not taken.
✗ Branch 132 → 137 not taken.
✓ Branch 134 → 135 taken 36 times.
✓ Branch 134 → 139 taken 2068 times.
✓ Branch 216 → 217 taken 39 times.
✓ Branch 216 → 221 taken 2080 times.
|
4223 |
if(is_implied_rep) { |
| 647 |
6/12
✗ Branch 134 → 135 not taken.
✗ Branch 134 → 181 not taken.
✗ Branch 136 → 134 not taken.
✓ Branch 136 → 137 taken 84 times.
✗ Branch 136 → 145 not taken.
✗ Branch 136 → 183 not taken.
✓ Branch 138 → 136 taken 84 times.
✓ Branch 138 → 147 taken 36 times.
✓ Branch 218 → 219 taken 90 times.
✗ Branch 218 → 280 not taken.
✓ Branch 220 → 218 taken 90 times.
✓ Branch 220 → 229 taken 39 times.
|
249 |
for(int64_t i = 0; i < rep_count; i++) write1(opcode); |
| 648 |
|
|
} else { |
| 649 |
2/6
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 181 not taken.
✓ Branch 139 → 140 taken 2068 times.
✗ Branch 139 → 183 not taken.
✓ Branch 221 → 222 taken 2080 times.
✗ Branch 221 → 280 not taken.
|
4148 |
write1(opcode); |
| 650 |
4/6
✗ Branch 138 → 139 not taken.
✗ Branch 138 → 145 not taken.
✓ Branch 140 → 141 taken 1426 times.
✓ Branch 140 → 147 taken 642 times.
✓ Branch 222 → 223 taken 1438 times.
✓ Branch 222 → 229 taken 642 times.
|
4148 |
if(arg_len == 0); |
| 651 |
6/12
✗ Branch 139 → 140 not taken.
✗ Branch 139 → 141 not taken.
✗ Branch 140 → 145 not taken.
✗ Branch 140 → 181 not taken.
✓ Branch 141 → 142 taken 611 times.
✓ Branch 141 → 143 taken 815 times.
✓ Branch 142 → 147 taken 611 times.
✗ Branch 142 → 183 not taken.
✓ Branch 223 → 224 taken 614 times.
✓ Branch 223 → 225 taken 824 times.
✓ Branch 224 → 229 taken 614 times.
✗ Branch 224 → 280 not taken.
|
2864 |
else if(arg_len == 1) write1(arg_value); |
| 652 |
6/12
✗ Branch 141 → 142 not taken.
✗ Branch 141 → 143 not taken.
✗ Branch 142 → 145 not taken.
✗ Branch 142 → 181 not taken.
✓ Branch 143 → 144 taken 541 times.
✓ Branch 143 → 145 taken 274 times.
✓ Branch 144 → 147 taken 541 times.
✗ Branch 144 → 183 not taken.
✓ Branch 225 → 226 taken 550 times.
✓ Branch 225 → 227 taken 274 times.
✓ Branch 226 → 229 taken 550 times.
✗ Branch 226 → 280 not taken.
|
1639 |
else if(arg_len == 2) write2(arg_value); |
| 653 |
4/12
✗ Branch 143 → 144 not taken.
✗ Branch 143 → 145 not taken.
✗ Branch 144 → 145 not taken.
✗ Branch 144 → 181 not taken.
✓ Branch 145 → 146 taken 274 times.
✗ Branch 145 → 147 not taken.
✓ Branch 146 → 147 taken 274 times.
✗ Branch 146 → 183 not taken.
✓ Branch 227 → 228 taken 274 times.
✗ Branch 227 → 229 not taken.
✓ Branch 228 → 229 taken 274 times.
✗ Branch 228 → 280 not taken.
|
548 |
else if(arg_len == 3) write3(arg_value); |
| 654 |
|
|
} |
| 655 |
|
|
|
| 656 |
8/12
✗ Branch 145 → 146 not taken.
✗ Branch 145 → 152 not taken.
✗ Branch 146 → 147 not taken.
✗ Branch 146 → 152 not taken.
✓ Branch 147 → 148 taken 72 times.
✓ Branch 147 → 154 taken 2032 times.
✓ Branch 148 → 149 taken 48 times.
✓ Branch 148 → 154 taken 24 times.
✓ Branch 229 → 230 taken 72 times.
✓ Branch 229 → 236 taken 2047 times.
✓ Branch 230 → 231 taken 48 times.
✓ Branch 230 → 236 taken 24 times.
|
4223 |
if(autoclean && pass > 0) { |
| 657 |
|
|
// should be changed to "can't use autoclean on this instruction"? |
| 658 |
2/12
✗ Branch 147 → 148 not taken.
✗ Branch 147 → 151 not taken.
✗ Branch 148 → 149 not taken.
✗ Branch 148 → 181 not taken.
✗ Branch 149 → 150 not taken.
✓ Branch 149 → 153 taken 48 times.
✗ Branch 150 → 151 not taken.
✗ Branch 150 → 183 not taken.
✗ Branch 231 → 232 not taken.
✓ Branch 231 → 235 taken 48 times.
✗ Branch 232 → 233 not taken.
✗ Branch 232 → 280 not taken.
|
96 |
if(arg_len != 3) throw_err_block(2, err_broken_autoclean); |
| 659 |
2/6
✗ Branch 151 → 152 not taken.
✗ Branch 151 → 181 not taken.
✓ Branch 153 → 154 taken 48 times.
✗ Branch 153 → 183 not taken.
✓ Branch 235 → 236 taken 48 times.
✗ Branch 235 → 280 not taken.
|
96 |
handle_autoclean(parse_res.arg, opcode, snespos - 4); |
| 660 |
|
|
} |
| 661 |
|
4223 |
return true; |
| 662 |
|
26957 |
} |
| 663 |
|
|
|