SHARE
TWEET

Untitled

a guest Dec 6th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. case delete_instr:
  2.             Iterator1 = registersList.begin();
  3.             std::cout << "\n delete \n";
  4.             advance(Iterator1, ((nrOfElementToDelete - 1) * chunkToRemove));    //first iterator points to the first element to delete
  5.             advance(Iterator2, nrOfElementToDelete * chunkToRemove);            //second iterator points to the last element to delete
  6.             registersList.erase(Iterator1, Iterator2);
  7.             for (int j = 0; j < chunkToRemove; j++)                             //after deletion fill last elements with zeros
  8.                 registersList.push_back(0);
  9.             //Iterator1 = registersList.begin();
  10.             //advance(Iterator1, chunkToRemove);
  11.             for (int i = 0; i < registersList.size(); i += 6) { // iterate through all next instructions
  12.                 //std::cout << "i = " << i << "\n";
  13.                 //std::cout << *Iterator1 << "\n";
  14.                 //std::cout << "3rd element = " << *Iterator1;
  15.                 if ((*Iterator1) == 3) { // if instruction type is 3- JMP
  16.                     //std::cout << *Iterator1 << "\n";
  17.                     advance(Iterator1, 5); //set iterator to 6th position in this instruction- (according point)
  18.                     //std::cout << "Iterator (5)" << *Iterator1 << "\n";                       
  19.                     if (*Iterator1 > nrOfElementToDelete) {//if number of instruction to jump to is before deleted instruction leave it alone
  20.                         *Iterator1 = (*Iterator1) - 1;
  21.                     }
  22.                     //decrement value stored in 6th position - shift jump point reference to fit updated list (jumps have to shift when deleting instruction)
  23.                    //std::cout << "zdekrementowana wartosc iterator = " << *Iterator1 << "\n";
  24.                 }
  25.                 advance(Iterator1, 1);
  26.  
  27.             }
  28.             break;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top