int tellstdfunc::stdLINEDEF::execute() { byte width = getByteValue(); byte patscale = getByteValue(); word pattern = getWordValue(); std::string col = getStringValue(); std::string name = getStringValue(); DATC->addline(name, col, pattern, patscale, width); LogFile << LogFile.getFN() << "(\""<< name << "\" , \"" << col << "\"," << pattern << " , " << patscale << " , " << width << ");";LogFile.flush(); return EXEC_NEXT; }
int tellstdfunc::stdCOLORDEF::execute() { byte sat = getByteValue(); byte colB = getByteValue(); byte colG = getByteValue(); byte colR = getByteValue(); std::string name = getStringValue(); // error message - included in the method DATC->addcolor(name, colR, colG, colB, sat); LogFile << LogFile.getFN() << "(\""<< name << "\"," << colR << "," << colG << "," << colB << "," << sat << ");";LogFile.flush(); return EXEC_NEXT; }
void tellstdfunc::stdGRID::undo() { TEUNDO_DEBUG("grid( int bool ) UNDO"); bool visu = getBoolValue(UNDOPstack, true); byte no = getByteValue(UNDOPstack, true); gridON(no,visu); RefreshGL(); }
int tellstdfunc::stdGRIDDEF::execute() { std::string colname = getStringValue(); real step = getOpValue(); byte no = getByteValue(); DATC->setGrid(no,step,colname); LogFile << LogFile.getFN() << "(" << no << "," << step << ",\"" << colname << "\");";LogFile.flush(); RefreshGL(); return EXEC_NEXT; }
unsigned int getByteValue(unsigned char *ch,int byteSum,int pos,int len,bool flag) { if(len > 32) return 0; //最多只能是4byte个字节 if(pos < 0 || pos >= (byteSum << 3)) return 0; if(len <= 0 || pos + len >= (byteSum << 3)) return 0; unsigned int temp = 0; int head = (pos >> 3); int end = ((pos + len) >> 3); if(flag) {//大头 if(head == end) return getByteValue(ch[head],pos % 8,len); for(int i = head;i <= end;++ i) { if(i == head) temp = getByteValue(ch[i],pos % 8,8 - (pos % 8)); else if(i == end) temp = (temp << ((pos + len) % 8)) + getByteValue(ch[i],0,(pos + len) % 8); else temp = (temp << 8) + ch[i]; } }else {//小头(未测试) if(head == end) return getByteValue(ch[byteSum - head],pos % 8,len); for(int i = head;i <= end;++ i) { if(i == head) temp = getByteValue(ch[byteSum - i],pos % 8,8 - (pos % 8)); else if(i == end) temp = (temp << ((pos + len) % 8)) + getByteValue(ch[byteSum - i],0,(pos + len) % 8); else temp = (temp << 8) + ch[byteSum - i]; } } return temp; }
int tellstdfunc::stdGRID::execute() { bool visu = getBoolValue(); byte no = getByteValue(); if (NULL != DATC->grid(no)) { UNDOcmdQ.push_front(this); UNDOPstack.push_front(new telldata::ttint(no)); UNDOPstack.push_front(new telldata::ttbool(DATC->grid_visual(no))); gridON(no,visu); LogFile << LogFile.getFN() << "(" << no << "," << LogFile._2bool(visu) << ");"; LogFile.flush(); RefreshGL(); } else tell_log(console::MT_ERROR,"Grid is not defined. Use definegrid(...) first"); return EXEC_NEXT; }
int tellstdfunc::stdSHAPEANGLE::execute() { byte angle = getByteValue(); if ((angle == 0) || (angle == 45) || (angle == 90)) { // prepare undo first UNDOcmdQ.push_front(this); UNDOPstack.push_front(new telldata::ttint(DATC->marker_angle())); // DATC->setmarker_angle(angle); wxCommandEvent eventGRIDUPD(wxEVT_SETINGSMENU); if (angle == 0) eventGRIDUPD.SetInt(tui::STS_ANGLE_0); else if (angle == 45) eventGRIDUPD.SetInt(tui::STS_ANGLE_45); else if (angle == 90) eventGRIDUPD.SetInt(tui::STS_ANGLE_90); else assert(false); wxPostEvent(TopedMainW, eventGRIDUPD); LogFile << LogFile.getFN() << "(" << angle << ");"; LogFile.flush(); } else { tell_log(console::MT_ERROR,"0, 45 or 90 degrees allowed only"); } return EXEC_NEXT; }
void tellstdfunc::stdSHAPEANGLE::undo() { TEUNDO_DEBUG("shapeangle() UNDO"); byte angle = getByteValue(UNDOPstack,true); DATC->setmarker_angle(angle); }
void tellstdfunc::stdSHAPEANGLE::undo_cleanup() { getByteValue(UNDOPstack,false); }
void tellstdfunc::stdGRID::undo_cleanup() { getByteValue(UNDOPstack, false); getBoolValue(UNDOPstack, false); }
void Pass2::readInstructions() { cout << endl << " Program Listing" << endl; cout << "-------------------------------------------------" << endl; listFile << endl << " Program Listing" << endl; listFile << "-------------------------------------------------" << endl; reader-> advance(); stringstream stream; stream << hex << pass_1->startLocation; string strtLoc = stream.str(); transform(strtLoc.begin(), strtLoc.end(), strtLoc.begin(), ::toupper); stream.str("");//==.clear stream << hex << pass_1->lengthOfProgram; string len = stream.str(); transform(len.begin(), len.end(), len.begin(), ::toupper); if (reader->getLabel().length() != 0) { writer->start(reader->getLabel() + "", strtLoc, len); cout << reader->getAddress() << "\t" << reader->getLabel() << "\t" << "START" << "\t" << pass_1->startLocation << endl; listFile << reader->getAddress() << "\t" << reader->getLabel() << "\t" << "START" << "\t" << pass_1->startLocation << endl; } else { writer->start(" ", strtLoc, len); cout << " " << "\t" << "START" << "\t" << pass_1->startLocation << "\t\t" << endl; listFile << " " << "\t" << "START" << "\t" << pass_1->startLocation << "\t\t" << endl; } // handles the flow of line parsing while (reader->advance()) { string opcode = reader->getOpcode(); string operand = reader->getOperand(); string currAddress = reader->getAddress(); string nextAddress; if (opcode != "END") nextAddress = reader->getNextAddress(); cout << currAddress << "\t" << reader->getLabel() << "\t" << opcode << "\t" << operand << "\t\t"; listFile << currAddress << "\t" << reader->getLabel() << "\t" << opcode << "\t" << operand << "\t\t"; if (opTable->contains(opcode)) {//valid opcode not directive bool needModRec = false; string objectCode = opParser->parse( pass_1->hexaParser(nextAddress), opcode, operand, needModRec); if (objectCode.substr(0, 5) == "error") { listFile << objectCode << endl; cout << "*** Error in operand: '" << operand << "' " << objectCode.substr(5, objectCode.length() - 4) << endl; continue; } if (needModRec) { writer->writeModRec(currAddress, 5); } cout << objectCode; listFile << objectCode; writer->writeTextRec(objectCode, currAddress, 0); } else {//directive if (opcode == "BYTE") { writer->writeTextRec(getByteValue(operand), currAddress, 0); cout << getByteValue(operand); } else if (opcode == "WORD") { writer->writeTextRec(operand, currAddress, 0); } else if (opcode == "BASE") { int i = 0; if (operand[0] >= '0' && operand[0] <= '9')//numeric value i = atoi(operand.c_str()); else if (pass_1->symTable->contains(operand)) i = pass_1->symTable->get(operand)->getAddress(); else { cerr << "BASE operand is not found"; listFile << " ****Error: BASE operand is not found"; } opParser->setBaseFlag(true, i); } else if (opcode == "NOBASE") { opParser->setBaseFlag(false, 0); } else if (opcode == "END") { setLiterals(currAddress); writer->end(strtLoc); } else if (opcode == "LTORG") { setLiterals(currAddress); } else if (opcode == "RESB" || opcode == "RESW" || opcode == "ORG") { // RESB, RESW, ORG writer->closeRecord(); } } cout << "" << endl; listFile << "" << endl; } }