Path: blob/master/libmeteor/source/disassembler/argmulregisters.cpp
2 views
// Meteor - A Nintendo Gameboy Advance emulator1// Copyright (C) 2009-2011 Philippe Daouadi2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// This program is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program. If not, see <http://www.gnu.org/licenses/>.1516#include "ameteor/disassembler/argmulregisters.hpp"1718#include <sstream>1920namespace AMeteor21{22namespace Disassembler23{24std::string ArgMulRegisters::GetString () const25{26std::ostringstream ss;27ss << '{';2829bool open = false;3031for (Registers::const_iterator iter = m_regs.begin();32iter != m_regs.end(); ++iter)33{34if (open &&35iter + 1 < m_regs.end() &&36*(iter + 1) == (*iter) + 1)37{38continue;39}40else if (iter + 2 < m_regs.end() &&41*(iter + 1) == (*iter) + 1 &&42*(iter + 2) == (*iter) + 2)43{44ss << 'r' << (int)*iter << '-';45open = true;46}47else48{49ss << 'r' << (int)*iter;50open = false;51if (iter + 1 != m_regs.end())52ss << ", ";53}54}5556if (m_lastreg == SPREG_LR)57{58if (ss.width() != 1)59ss << ", ";60ss << "lr";61}62else if (m_lastreg == SPREG_PC)63{64if (ss.width() != 1)65ss << ", ";66ss << "pc";67}6869ss << '}';7071if (m_forceuser)72ss << '^';7374return ss.str();75}7677Argument* ArgMulRegisters::Clone () const78{79return new ArgMulRegisters(*this);80}81}82}838485