| 1410 | } |
| 1411 | |
| 1412 | void cHardwareCPU::FindLabelInMemory(const cCodeLabel& label, cHeadCPU& search_head) |
| 1413 | { |
| 1414 | assert(label.GetSize() > 0); // Trying to find label of 0 size! |
| 1415 | |
| 1416 | |
| 1417 | while (search_head.InMemory()) { |
| 1418 | // If we are not in a label, jump to the next checkpoint... |
| 1419 | if (!m_inst_set->IsNop(search_head.GetInst())) { |
| 1420 | search_head.AbsJump(label.GetSize()); |
| 1421 | continue; |
| 1422 | } |
| 1423 | |
| 1424 | // Otherwise, rewind to the begining of this label... |
| 1425 | |
| 1426 | while (!(search_head.AtFront()) && m_inst_set->IsNop(search_head.GetInst(-1))) |
| 1427 | search_head.AbsJump(-1); |
| 1428 | |
| 1429 | // Calculate the size of the label being checked, and make sure they |
| 1430 | // are equal. |
| 1431 | |
| 1432 | int size = 0; |
| 1433 | bool label_match = true; |
| 1434 | do { |
| 1435 | // Check if the nop matches |
| 1436 | if (size < label.GetSize() && label[size] != m_inst_set->GetNopMod(search_head.GetInst())) |
| 1437 | label_match = false; |
| 1438 | |
| 1439 | // Increment the current position and length calculation |
| 1440 | search_head.AbsJump(1); |
| 1441 | size++; |
| 1442 | |
| 1443 | // While still within memory and the instruction is a nop |
| 1444 | } while (search_head.InMemory() && m_inst_set->IsNop(search_head.GetInst())); |
| 1445 | |
| 1446 | if (size != label.GetSize()) continue; |
| 1447 | |
| 1448 | // temp_head will point to the first non-nop instruction after the label, or the end of the memory space |
| 1449 | // if this is a match, return this position |
| 1450 | if (label_match) return; |
| 1451 | } |
| 1452 | |
| 1453 | // The label does not exist in this creature. |
| 1454 | |
| 1455 | search_head.AbsSet(-1); |
| 1456 | } |
| 1457 | |
| 1458 | |
| 1459 | void cHardwareCPU::ReadInst(const int in_inst) |