protected int roxr_word_imm(int opcode)
	{
		int shift = (opcode >> 9) & 0x07;
		if(shift == 0)
			shift = 8;

		int reg = (opcode & 0x07);
		int d = cpu.getDataRegisterWord(reg);

                
		int last_out;
		boolean xflag=cpu.isFlagSet(Cpu.X_FLAG);        // state of the X flag
		int maskFlags;                                  // there is no 0 rotate count here
		for(int s= 0; s < shift; s++)
		{
			last_out = d & 0x01;                    // state of last bit befrre rotate
			d >>>= 1;                               // use >>> instead of >>, else the msb will always be set!
			if (xflag)                              // X flag was set before the rotate
				d |= 0x8000;                        // so set it in MSB
			if(last_out != 0)                       // now set new state of X flag according to last bit moved out
				xflag=true;
			else
				xflag=false;
		}
		d &= 0xffff;
		cpu.setDataRegisterWord(reg, d);
		if (xflag)
			maskFlags=Cpu.X_FLAG+Cpu.C_FLAG;        // if last bit was 1, set flags accordingly
		else
			maskFlags=0;                            // these flags aren't set
		if (d==0)
			maskFlags+=Cpu.Z_FLAG;
		if((d & 0x8000)!=0)
			maskFlags+=Cpu.N_FLAG;                      // N flag (the V flag is always 0)
		cpu.setCCRegister(maskFlags);
		return 6 + shift + shift;
	}