1 #include "followop.h" 2 3 #ifndef KERNEL_DS 4 follow_straight(UInt16 where)5UInt16 follow_straight (UInt16 where) 6 { 7 UChar op = get_8bit_addr (where); 8 9 return where + addr_info_debug[optable_debug[op].addr_mode].size; 10 } 11 follow_BBRi(UInt16 where)12UInt16 follow_BBRi (UInt16 where) 13 { 14 UChar op = get_8bit_addr (where); 15 UChar test_char = get_8bit_addr (get_8bit_addr (where + 1)); 16 UChar nb_bit = op >> 4; 17 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 18 19 test_char >>= nb_bit; 20 21 if (!(test_char & 0x1)) // no jump 22 return where + size; 23 24 // jump 25 return where + addr_info_debug[optable_debug[op].addr_mode].size 26 + (SChar) get_8bit_addr (where + size - 1); 27 28 } 29 follow_BCC(UInt16 where)30UInt16 follow_BCC (UInt16 where) 31 { 32 UChar op = get_8bit_addr (where); 33 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 34 35 if (M.P & C_FLAG) // no jump 36 return where + size; 37 38 // jump 39 return where + size + (SChar) get_8bit_addr (where + size - 1); 40 } 41 follow_BBSi(UInt16 where)42UInt16 follow_BBSi (UInt16 where) 43 { 44 UChar op = get_8bit_addr (where); 45 UChar test_char = get_8bit_addr (get_8bit_addr (where + 1)); 46 UChar nb_bit = op >> 4; 47 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 48 49 test_char >>= nb_bit; 50 51 if ((test_char & 0x1)) // no jump 52 return where + size; 53 54 // jump 55 return where + addr_info_debug[optable_debug[op].addr_mode].size 56 + (SChar) get_8bit_addr (where + size - 1); 57 58 } 59 follow_BCS(UInt16 where)60UInt16 follow_BCS (UInt16 where) 61 { 62 UChar op = get_8bit_addr (where); 63 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 64 65 if (!(M.P & C_FLAG)) // no jump 66 return where + size; 67 68 // jump 69 return where + size + (SChar) get_8bit_addr (where + size - 1); 70 } 71 follow_BEQ(UInt16 where)72UInt16 follow_BEQ (UInt16 where) 73 { 74 UChar op = get_8bit_addr (where); 75 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 76 77 if (M.ZF) // no jump 78 return where + size; 79 80 // jump 81 return where + size + (SChar) get_8bit_addr (where + size - 1); 82 } 83 follow_BNE(UInt16 where)84UInt16 follow_BNE (UInt16 where) 85 { 86 UChar op = get_8bit_addr (where); 87 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 88 89 if (!(M.ZF)) // no jump 90 return where + size; 91 92 // jump 93 return where + size + (SChar) get_8bit_addr (where + size - 1); 94 } 95 follow_BMI(UInt16 where)96UInt16 follow_BMI (UInt16 where) 97 { 98 UChar op = get_8bit_addr (where); 99 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 100 101 if (M.NF & N_FLAG) // no jump 102 return where + size; 103 104 // jump 105 return where + size + (SChar) get_8bit_addr (where + size - 1); 106 } 107 follow_BPL(UInt16 where)108UInt16 follow_BPL (UInt16 where) 109 { 110 UChar op = get_8bit_addr (where); 111 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 112 113 if (!(M.NF & N_FLAG)) // no jump 114 return where + size; 115 116 // jump 117 return where + size + (SChar) get_8bit_addr (where + size - 1); 118 } 119 follow_BRA(UInt16 where)120UInt16 follow_BRA (UInt16 where) 121 { 122 UChar op = get_8bit_addr (where); 123 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 124 125 return where + size // always jump 126 + (SChar) get_8bit_addr (where + size - 1); 127 } 128 follow_BSR(UInt16 where)129UInt16 follow_BSR (UInt16 where) 130 { 131 UChar op = get_8bit_addr (where); 132 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 133 134 if (running_mode == STEPPING) // no jump 135 return where + size; 136 137 // jump 138 return where + size + (SChar) get_8bit_addr (where + size - 1); 139 } 140 follow_BVC(UInt16 where)141UInt16 follow_BVC (UInt16 where) 142 { 143 UChar op = get_8bit_addr (where); 144 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 145 146 if (M.VF & V_FLAG) // no jump 147 return where + size; 148 149 // jump 150 return where + size + (SChar) get_8bit_addr (where + size - 1); 151 } 152 follow_BVS(UInt16 where)153UInt16 follow_BVS (UInt16 where) 154 { 155 UChar op = get_8bit_addr (where); 156 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 157 158 if (!(M.VF & V_FLAG)) // no jump 159 return where + size; 160 161 // jump 162 return where + size + (SChar) get_8bit_addr (where + size - 1); 163 } 164 follow_JMPabs(UInt16 where)165UInt16 follow_JMPabs (UInt16 where) 166 { 167 UChar op = get_8bit_addr (where); 168 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 169 170 return get_8bit_addr (where + size - 2) + 256 * get_8bit_addr (where + size - 1); 171 172 } 173 follow_JMPindir(UInt16 where)174UInt16 follow_JMPindir (UInt16 where) 175 { 176 UChar op = get_8bit_addr (where); 177 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 178 179 UInt16 indir = get_8bit_addr (where + size - 2) + 256 * get_8bit_addr (where + size - 1); 180 181 return get_8bit_addr (indir) + 256 * get_8bit_addr (indir + 1); 182 183 } 184 follow_JMPindirX(UInt16 where)185UInt16 follow_JMPindirX (UInt16 where) 186 { 187 UChar op = get_8bit_addr (where); 188 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 189 190 UInt16 indir = get_8bit_addr (where + size - 2) + 256 * get_8bit_addr (where + size - 1); 191 192 indir += M.X; 193 194 return get_8bit_addr (indir) + 256 * get_8bit_addr (indir + 1); 195 196 } 197 follow_JSR(UInt16 where)198UInt16 follow_JSR (UInt16 where) 199 { 200 UChar op = get_8bit_addr (where); 201 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 202 203 if (running_mode == STEPPING) 204 return where + size; // no jump 205 206 return get_8bit_addr (where + size - 2) + 256 * get_8bit_addr (where + size - 1); 207 208 } 209 follow_RTI(UInt16 where)210UInt16 follow_RTI (UInt16 where) 211 { 212 return RAM[SP + M.S + 2] + 256 * RAM[SP + M.S + 3]; 213 } 214 follow_RTS(UInt16 where)215UInt16 follow_RTS (UInt16 where) 216 { 217 return RAM[SP + M.S + 1] + 256 * RAM[SP + M.S + 2] + 1; 218 } 219 220 #else 221 follow_straight(UInt16 where)222UInt16 follow_straight (UInt16 where) 223 { 224 UChar op = get_8bit_addr (where); 225 226 return where + addr_info_debug[optable_debug[op].addr_mode].size; 227 } 228 follow_BBRi(UInt16 where)229UInt16 follow_BBRi (UInt16 where) 230 { 231 UChar op = get_8bit_addr (where); 232 UChar test_char = get_8bit_addr (get_8bit_addr ((UInt16)(where + 1))); 233 UChar nb_bit = op >> 4; 234 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 235 236 test_char >>= nb_bit; 237 238 if (!(test_char & 0x1)) // no jump 239 return where + size; 240 241 // jump 242 return where + addr_info_debug[optable_debug[op].addr_mode].size 243 + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 244 245 } 246 follow_BCC(UInt16 where)247UInt16 follow_BCC (UInt16 where) 248 { 249 UChar op = get_8bit_addr (where); 250 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 251 252 if (reg_p & FL_C) // no jump 253 return where + size; 254 255 // jump 256 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 257 } 258 follow_BBSi(UInt16 where)259UInt16 follow_BBSi (UInt16 where) 260 { 261 UChar op = get_8bit_addr (where); 262 UChar test_char = get_8bit_addr (get_8bit_addr ((UInt16)(where + 1))); 263 UChar nb_bit = op >> 4; 264 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 265 266 test_char >>= nb_bit; 267 268 if ((test_char & 0x1)) // no jump 269 return where + size; 270 271 // jump 272 return where + addr_info_debug[optable_debug[op].addr_mode].size 273 + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 274 275 } 276 follow_BCS(UInt16 where)277UInt16 follow_BCS (UInt16 where) 278 { 279 UChar op = get_8bit_addr (where); 280 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 281 282 if (!(reg_p & FL_C)) // no jump 283 return where + size; 284 285 // jump 286 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 287 } 288 follow_BEQ(UInt16 where)289UInt16 follow_BEQ (UInt16 where) 290 { 291 UChar op = get_8bit_addr (where); 292 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 293 294 if (reg_pc & FL_Z) // no jump 295 return where + size; 296 297 // jump 298 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 299 } 300 follow_BNE(UInt16 where)301UInt16 follow_BNE (UInt16 where) 302 { 303 UChar op = get_8bit_addr (where); 304 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 305 306 if (!(reg_pc & FL_Z)) // no jump 307 return where + size; 308 309 // jump 310 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 311 } 312 follow_BMI(UInt16 where)313UInt16 follow_BMI (UInt16 where) 314 { 315 UChar op = get_8bit_addr (where); 316 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 317 318 if (reg_p & FL_N) // no jump 319 return where + size; 320 321 // jump 322 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 323 } 324 follow_BPL(UInt16 where)325UInt16 follow_BPL (UInt16 where) 326 { 327 UChar op = get_8bit_addr (where); 328 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 329 330 if (!(reg_p & FL_N)) // no jump 331 return where + size; 332 333 // jump 334 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 335 } 336 follow_BRA(UInt16 where)337UInt16 follow_BRA (UInt16 where) 338 { 339 UChar op = get_8bit_addr (where); 340 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 341 342 return where + size // always jump 343 + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 344 } 345 follow_BSR(UInt16 where)346UInt16 follow_BSR (UInt16 where) 347 { 348 UChar op = get_8bit_addr (where); 349 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 350 351 if (running_mode == STEPPING) // no jump 352 return where + size; 353 354 // jump 355 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 356 } 357 follow_BVC(UInt16 where)358UInt16 follow_BVC (UInt16 where) 359 { 360 UChar op = get_8bit_addr (where); 361 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 362 363 if (reg_p & FL_V) // no jump 364 return where + size; 365 366 // jump 367 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 368 } 369 follow_BVS(UInt16 where)370UInt16 follow_BVS (UInt16 where) 371 { 372 UChar op = get_8bit_addr (where); 373 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 374 375 if (!(reg_p & FL_V)) // no jump 376 return where + size; 377 378 // jump 379 return where + size + (SChar) get_8bit_addr ((UInt16)(where + size - 1)); 380 } 381 follow_JMPabs(UInt16 where)382UInt16 follow_JMPabs (UInt16 where) 383 { 384 UChar op = get_8bit_addr (where); 385 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 386 387 return (UInt16)(get_8bit_addr ((UInt16)(where + size - 2)) + 256 * get_8bit_addr ((UInt16)(where + size - 1))); 388 389 } 390 follow_JMPindir(UInt16 where)391UInt16 follow_JMPindir (UInt16 where) 392 { 393 UChar op = get_8bit_addr (where); 394 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 395 396 UInt16 indir = (UInt16)(get_8bit_addr ((UInt16)(where + size - 2)) + 256 * get_8bit_addr ((UInt16)(where + size - 1))); 397 398 return (UInt16)(get_8bit_addr ((UInt16)indir) + 256 * get_8bit_addr ((UInt16)(indir + 1))); 399 400 } 401 follow_JMPindirX(UInt16 where)402UInt16 follow_JMPindirX (UInt16 where) 403 { 404 UChar op = get_8bit_addr (where); 405 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 406 407 UInt16 indir = (UInt16)(get_8bit_addr ((UInt16)(where + size - 2)) + 256 * get_8bit_addr ((UInt16)(where + size - 1))); 408 409 indir += reg_x; 410 411 return (UInt16)(get_8bit_addr ((UInt16)indir) + 256 * get_8bit_addr ((UInt16)(indir + 1))); 412 413 } 414 follow_JSR(UInt16 where)415UInt16 follow_JSR (UInt16 where) 416 { 417 UChar op = get_8bit_addr (where); 418 UChar size = addr_info_debug[optable_debug[op].addr_mode].size; 419 420 if (running_mode == STEPPING) 421 return where + size; // no jump 422 423 return (UInt16)(get_8bit_addr ((UInt16)(where + size - 2)) + 256 * get_8bit_addr ((UInt16)(where + size - 1))); 424 425 } 426 follow_RTI(UInt16 where)427UInt16 follow_RTI (UInt16 where) 428 { 429 return (UInt16)(sp_base[reg_s + 2] + 256 * sp_base[reg_s + 3]); 430 } 431 follow_RTS(UInt16 where)432UInt16 follow_RTS (UInt16 where) 433 { 434 return (UInt16)(sp_base[reg_s + 1] + 256 * sp_base[reg_s + 2] + 1); 435 } 436 437 438 #endif 439