/* SmArc VMachine - Simplified SPARC emulator Copyright (C) 2002 Michal Stochmialek 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; version 2 of the License 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * $Id: shifter.cc,v 1.1 2002/12/28 16:28:11 misto Exp $ */ #include "shifter.h" // in[0] = Mpx4 ~= A1 ~= reg[src1] // in[1] = Mpx5 ~= A2 ~= (reg[src2] || imm13 ) // void shifter::process( instr_word op ) { // FIXME: is this right?? // imm13 shr R[src1] == imm13 >> R[src1] ? // is specification right? // // Sat Dec 28 14:27:06 CET 2002: // I think it should be: // imm13 shr R[src1] == R[src1] >> imm13 // [according to SPARCV8 Manual] // if ( op.instr == instr_word::sll ) set_out_all( get_in(0) << get_in(1) ); else if ( op.instr == instr_word::srl ) set_out_all( get_in(0) >> get_in(1) ); else if ( op.instr == instr_word::sra ){ bit_word arg1 = get_in(0), arg2 = get_in(1), res; res = arg1 >> arg2; if ( arg1.b(31) == 1 ) res.bset(31); set_out_all( res ); } }