CPD Results

The following document contains the results of PMD's CPD 5.6.1.

Duplications

File Line
me/felinewith/kcpu/util/helpers/ValueHelper.java 14
me/felinewith/kcpu/util/helpers/ValueHelper.java 78
	public static short readByte(short pos, short ref, short[] regs, short[] values, IMemory memory) {
		short output = 0;
		short reg = (short)(0x03 & values[pos]);
		// 00: direct
		// 01: register
		// 02: direct address
		// 03: register address
		short cref = 0;
		switch (pos) {
			case 0: cref = (short)(0x0003 & ref); break;
			case 1: cref = (short)(0x000c & ref); break;
			case 2: cref = (short)(0x0030 & ref); break;
			case 3: cref = (short)(0x00c0 & ref); break;
		}

		switch (cref) {
			case 0x0000: output = values[pos]; break;
			case 0x0001: case 0x0004: case 0x0010: case 0x0040:
				output = regs[reg]; break;
			case 0x0002: case 0x0008: case 0x0020: case 0x0080:
				output = MemHelper.readByte(values[pos], memory); break;
File Line
me/felinewith/kcpu/util/helpers/ValueHelper.java 49
me/felinewith/kcpu/util/helpers/ValueHelper.java 107
	public static short[] writeByte(short pos, short ref, short[] regs, short[] values, IMemory memory, byte data) {
		short[] output = Arrays.copyOf(regs, regs.length);
		short reg = (short)(0x03 & values[pos]);
		short cref = 0;
		switch (pos) {
			case 0: cref = (short)(0x0003 & ref); break;
			case 1: cref = (short)(0x000c & ref); break;
			case 2: cref = (short)(0x0030 & ref); break;
			case 3: cref = (short)(0x00c0 & ref); break;
		}

		// short-circuit write to register if position isn't used in the instruction
		if (pos > ((0x0f00 & reg) >> 8)) { cref = 1; }