⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 instruction.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
📖 第 1 页 / 共 2 页
字号:
//// Copyright (c) 2002 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA//------------------------------------------------------------------------------#include "Instruction.h"//------------------------------------------------------------------------------using dvd::vm::Operand;using dvd::vm::Instruction;//------------------------------------------------------------------------------void Operand::printHex(FILE* f) const{    fprintf(f, "%02x %02x", (unsigned)high, (unsigned)low);}//------------------------------------------------------------------------------//------------------------------------------------------------------------------void Instruction::printRegister(FILE* f, unsigned registerNumber){    if (registerNumber<=15) {        fprintf(f, "GPR[%02x]", registerNumber);    } else if (registerNumber>=128 & registerNumber<=151) {        fprintf(f, "SPR[%02x]", registerNumber-128);    } else {        fprintf(f, "<Invalid register #%02x>", registerNumber);    }}//------------------------------------------------------------------------------void Instruction::printComparison(FILE* f, cmpOp_t cmpOp){    switch(cmpOp) {      case Instruction::BC:        fprintf(f, " & ");        break;      case Instruction::EQ:        fprintf(f, " == ");        break;      case Instruction::NE:        fprintf(f, " != ");        break;      case Instruction::GE:        fprintf(f, " >= ");        break;      case Instruction::GT:        fprintf(f, " > ");        break;      case Instruction::LE:        fprintf(f, " <= ");        break;      case Instruction::LT:        fprintf(f, " < ");        break;      default:        fprintf(f, "<Invalid comparison operator: %u>",                (unsigned)cmpOp);        break;    }}//------------------------------------------------------------------------------void Instruction::printHighlightButton(FILE* f, unsigned button){    if (button!=0) {        fprintf(f, ", button=%u", button);    }}//------------------------------------------------------------------------------bool Instruction::printCondition(FILE* f, cmpOp_t cmpOp,                                 unsigned value1,                                 bool isDirect2, unsigned value2){    if (cmpOp==CMP_NONE) return false;        fprintf(f, "[ ");    printRegister(f, value1);            printComparison(f, cmpOp);            if (isDirect2) fprintf(f, "0x%04x", value2);    else printRegister(f, value2);            fprintf(f, "] ");    return true;}//------------------------------------------------------------------------------//------------------------------------------------------------------------------void Instruction::printHex(FILE* f) const{    const unsigned char* bytes = reinterpret_cast<const unsigned char*>(this);        fprintf(f, "%02x %02x ", (unsigned)bytes[0], (unsigned)bytes[1]);    operand1.printHex(f); fprintf(f, " ");    operand2.printHex(f); fprintf(f, " ");    operand3.printHex(f);}//------------------------------------------------------------------------------void Instruction::printAssembly(FILE* f) const{    switch(getType()) {      case SPECIAL:        printSpecial(f);        break;      case BRANCH:        printBranch(f);        break;      case SETSYSREG:        printSetSysReg(f);        break;      case SET:        printSet(f);        break;      case SETCLNK:        printSetCLnk(f);        break;      case CSETCLNK:        printCSetCLnk(f);        break;      case CMPSETLNK:        printCmpSetLnk(f);        break;      default:        fprintf(f, "<Invalid instruction type: %u\n", type);        break;    }};//------------------------------------------------------------------------------void Instruction::printSpecial(FILE* f) const{    printSpecialCondition(f);    switch(getSpecCmd()) {      case BREAK:        fprintf(f, "Break");        break;      case GOTO:        fprintf(f, "Goto %u", operand3.getLineNumber());        break;      case SETTMPPLVL:        fprintf(f, "SetTmpPML %u, %u",                operand3.getLVL(),                operand3.getLineNumber());        break;      case NOP:        fprintf(f, "NOP");        break;      default:        fprintf(f, "<Invalid special command: %u>", (unsigned)getSpecCmd());        break;    }}//------------------------------------------------------------------------------void Instruction::printBranch(FILE* f) const{    if (isDirect()) {        printJumpCall(f);    } else {        printLink(f);    }}//------------------------------------------------------------------------------void Instruction::printLinkUnconditionally(FILE* f) const{    switch(getLinkCmd()) {      case LINKSUBSET:        printLinkSubset(f);        break;      case LINKPGCN:        fprintf(f, "LinkPGCN %u", operand3.getPGCN());        break;      case Instruction::LINKPTTN:        fprintf(f, "LinkPTTN %u", operand3.getPTTN());        printHighlightButton(f, operand3.getHLBN());        break;      case Instruction::LINKPGN:        fprintf(f, "LinkPGN %u", operand3.getPGN());        printHighlightButton(f, operand3.getHLBN());        break;      case Instruction::LINKCN:        fprintf(f, "LinkCN %u", operand3.getCN());        printHighlightButton(f, operand3.getHLBN());        break;      case Instruction::LINK_NOP:        fprintf(f, "NOP");        break;      default:        fprintf(f, "<Invalid link command: %u>",                (unsigned)getLinkCmd());        break;    }}//------------------------------------------------------------------------------void Instruction::printLink(FILE* f) const{    printLinkCondition(f);    printLinkUnconditionally(f);}//------------------------------------------------------------------------------void Instruction::printLinkSubset(FILE* f) const{    switch(operand3.getLinkType()) {      case Operand3::TOPCELL:        fprintf(f, "LinkTopCell");        break;      case Operand3::NEXTCELL:        fprintf(f, "LinkNextCell");        break;      case Operand3::PREVCELL:        fprintf(f, "LinkPrevCell");        break;      case Operand3::TOPPG:        fprintf(f, "LinkTopPG");        break;      case Operand3::NEXTPG:        fprintf(f, "LinkNextPG");        break;      case Operand3::PREVPG:        fprintf(f, "LinkPrevPG");        break;      case Operand3::TOPPGC:        fprintf(f, "LinkTopPGC");        break;      case Operand3::NEXTPGC:        fprintf(f, "LinkNextPGC");        break;      case Operand3::PREVPGC:        fprintf(f, "LinkPrevPGC");        break;      case Operand3::GOUPPGC:        fprintf(f, "LinkGoUpPGC");        break;      case Operand3::TAILPGC:        fprintf(f, "LinkTailPGC");        break;      case Operand3::RSM:        fprintf(f, "RSM");        break;      case Operand3::LINK_NOP:        fprintf(f, "NOP");        break;      default:        fprintf(f, "<Invalid link subset type: %u>",                (unsigned)operand3.getLinkType());        break;    }    printHighlightButton(f, operand3.getHLBN());}//------------------------------------------------------------------------------void Instruction::printJumpCall(FILE* f) const{    printJumpCallCondition(f);        switch(getJumpCallCmd()) {      case EXIT:        fprintf(f, "Exit");        break;      case JUMPTT:        fprintf(f, "JumpTT %u", operand2.getTTN());        break;      case JUMPVTS_TT:        fprintf(f, "JumpVTS_TT %u", operand2.getTTN());        break;      case JUMPVTS_PTT:        fprintf(f, "JumpVTS_PTT %u, %u",                operand2.getTTN(), operand1.getPTTN());        break;      case JUMPSS:        printJumpSS(f);        break;      case CALLSS:        printCallSS(f);        break;      case NOP:        fprintf(f, "NOP");        break;      default:        fprintf(f, "<Invalid jump/call command: %u>",                (unsigned)getJumpCallCmd());        break;    }}//------------------------------------------------------------------------------void Instruction::printJumpCallSS(FILE* f, bool isJump) const{    switch(operand2.getJumpCallType()) {      case Operand2::FP:        fprintf(f, "FP");        break;      case Operand2::VMGM_MENU:        fprintf(f, "VMGM_MENU %u", operand2.getMenu());        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -