diff --git a/Server/src/net/simon987/server/assembly/CPU.java b/Server/src/net/simon987/server/assembly/CPU.java index 3c30014..8c50197 100755 --- a/Server/src/net/simon987/server/assembly/CPU.java +++ b/Server/src/net/simon987/server/assembly/CPU.java @@ -152,7 +152,7 @@ public class CPU implements JSONSerialisable{ // LogManager.LOGGER.info(instruction.getMnemonic()); } double elapsed = (System.currentTimeMillis() - startTime); - LogManager.LOGGER.fine("----------\n" + counter + " instruction in " + elapsed + "ms : " + (double) counter / (elapsed / 1000) / 1000000 + "MHz"); + LogManager.LOGGER.fine(counter + " instruction in " + elapsed + "ms : " + (double) counter / (elapsed / 1000) / 1000000 + "MHz"); } public void executeInstruction(Instruction instruction, int source, int destination) { diff --git a/Server/src/net/simon987/server/assembly/DefaultInstructionSet.java b/Server/src/net/simon987/server/assembly/DefaultInstructionSet.java index 8ec302f..c1cd47b 100755 --- a/Server/src/net/simon987/server/assembly/DefaultInstructionSet.java +++ b/Server/src/net/simon987/server/assembly/DefaultInstructionSet.java @@ -1,6 +1,7 @@ package net.simon987.server.assembly; import net.simon987.server.assembly.instruction.*; +import net.simon987.server.logging.LogManager; import java.util.HashMap; @@ -31,6 +32,7 @@ public class DefaultInstructionSet implements InstructionSet { add(new AndInstruction()); add(new OrInstruction()); add(new ShlInstruction()); + add(new SalInstruction()); //Alias is added add(new ShrInstruction()); add(new XorInstruction()); add(new TestInstruction()); @@ -85,6 +87,12 @@ public class DefaultInstructionSet implements InstructionSet { @Override public void add(Instruction instruction) { - instructionMap.put(instruction.getOpCode(), instruction); + if (instructionMap.containsKey(instruction.getOpCode())) { + LogManager.LOGGER.fine(instruction.getMnemonic() + " instruction is an alias for " + + instructionMap.get(instruction.getOpCode()).getMnemonic()); + } else { + instructionMap.put(instruction.getOpCode(), instruction); + + } } } diff --git a/Server/src/net/simon987/server/assembly/instruction/RolInstruction.java b/Server/src/net/simon987/server/assembly/instruction/RolInstruction.java index fa114dc..3afbf27 100644 --- a/Server/src/net/simon987/server/assembly/instruction/RolInstruction.java +++ b/Server/src/net/simon987/server/assembly/instruction/RolInstruction.java @@ -4,6 +4,11 @@ import net.simon987.server.assembly.Instruction; import net.simon987.server.assembly.Status; import net.simon987.server.assembly.Target; +/** + * +-----------------+ + * | | + * CF < 0<0<0<0<0<0<0<0 <-+ + */ public class RolInstruction extends Instruction { private static final int OPCODE = 35; @@ -15,7 +20,7 @@ public class RolInstruction extends Instruction { @Override public Status execute(Target dst, int dstIndex, Target src, int srcIndex, Status status) { - int count = src.get(srcIndex); + int count = src.get(srcIndex) % 16; int destination = dst.get(dstIndex); int signBit = (destination & 0x8000); @@ -34,12 +39,12 @@ public class RolInstruction extends Instruction { @Override public Status execute(Target dst, int dstIndex, int src, Status status) { - + int count = src % 16; int destination = dst.get(dstIndex); int signBit = (destination & 0x8000); - destination = (destination << src) | (destination >>> (16 - src)); - if (src == 1) { + destination = (destination << count) | (destination >>> (16 - count)); + if (count == 1) { status.setOverflowFlag((destination & 0x8000) != signBit); //Set OF if sign bit changed } status.setCarryFlag((destination & 1) == 1); diff --git a/Server/src/net/simon987/server/assembly/instruction/RorInstruction.java b/Server/src/net/simon987/server/assembly/instruction/RorInstruction.java index e41d6cc..b72c5ff 100644 --- a/Server/src/net/simon987/server/assembly/instruction/RorInstruction.java +++ b/Server/src/net/simon987/server/assembly/instruction/RorInstruction.java @@ -5,9 +5,10 @@ import net.simon987.server.assembly.Status; import net.simon987.server.assembly.Target; /** - * Rotate right - *
- * ->  destination -(CF)>  + * +-----------------+ + * | | + * +-> 0>0>0>0>0>0>0>0 > CF + * */ public class RorInstruction extends Instruction { @@ -20,7 +21,7 @@ public class RorInstruction extends Instruction { @Override public Status execute(Target dst, int dstIndex, Target src, int srcIndex, Status status) { - int count = src.get(srcIndex); + int count = src.get(srcIndex) % 16; int destination = dst.get(dstIndex); int signBit = (destination & 0x8000); @@ -37,11 +38,12 @@ public class RorInstruction extends Instruction { @Override public Status execute(Target dst, int dstIndex, int src, Status status) { + int count = src % 16; int destination = dst.get(dstIndex); int signBit = (destination & 0x8000); - destination = (destination >>> src) | (destination << (16 - src)); - if (src == 1) { + destination = (destination >>> count) | (destination << (16 - count)); + if (count == 1) { status.setOverflowFlag((destination & 0x8000) != signBit); //Set OF if sign bit changed } dst.set(dstIndex, destination); diff --git a/Server/src/net/simon987/server/assembly/instruction/SalInstruction.java b/Server/src/net/simon987/server/assembly/instruction/SalInstruction.java new file mode 100644 index 0000000..f24ab94 --- /dev/null +++ b/Server/src/net/simon987/server/assembly/instruction/SalInstruction.java @@ -0,0 +1,13 @@ +package net.simon987.server.assembly.instruction; + +import net.simon987.server.assembly.Instruction; + +/** + * Alias of SHL instruction + */ +public class SalInstruction extends Instruction { + + public SalInstruction() { + super("sal", ShlInstruction.OPCODE); + } +} diff --git a/Server/src/net/simon987/server/assembly/instruction/XorInstruction.java b/Server/src/net/simon987/server/assembly/instruction/XorInstruction.java index c8bbe26..b9a8c2e 100644 --- a/Server/src/net/simon987/server/assembly/instruction/XorInstruction.java +++ b/Server/src/net/simon987/server/assembly/instruction/XorInstruction.java @@ -5,15 +5,13 @@ import net.simon987.server.assembly.Status; import net.simon987.server.assembly.Target; import net.simon987.server.assembly.Util; -/** - * Created by Gilbert Fortier on 3/12/2017. - */ + public class XorInstruction extends Instruction { /** * Opcode of the instruction */ - public static final int OPCODE = 5; + public static final int OPCODE = 38; public XorInstruction() { super("xor", OPCODE); diff --git a/Server/src/net/simon987/server/logging/GenericFormatter.java b/Server/src/net/simon987/server/logging/GenericFormatter.java index dbee2b0..a91d4cd 100755 --- a/Server/src/net/simon987/server/logging/GenericFormatter.java +++ b/Server/src/net/simon987/server/logging/GenericFormatter.java @@ -3,7 +3,6 @@ package net.simon987.server.logging; import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.Formatter; -import java.util.logging.Level; import java.util.logging.LogRecord; /** @@ -16,24 +15,13 @@ public class GenericFormatter extends Formatter { StringBuilder sb = new StringBuilder(); - if (record.getLevel() == Level.FINE) { - //Chat message, maximum 50 char per line - if (record.getMessage().length() > 50) { - sb.append(record.getMessage().substring(0, 50)); - sb.append('\n'); - sb.append(record.getMessage().substring(50)); - } else { - sb.append(record.getMessage()); - } - sb.append('\n'); - } else { - //Regular record - Date date = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm:ss:SSS"); //ex. 11/25 22:03:59:010 + //Regular record + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm:ss:SSS"); //ex. 11/25 22:03:59:010 + + sb.append(String.format("[%s] [%s] %s", sdf.format(date), record.getLevel(), record.getMessage())); + sb.append('\n'); - sb.append(String.format("[%s] [%s] %s", sdf.format(date), record.getLevel(), record.getMessage())); - sb.append('\n'); - } return sb.toString(); diff --git a/plugins/Cubot.jar b/plugins/Cubot.jar index fb49b22..7991cf6 100644 Binary files a/plugins/Cubot.jar and b/plugins/Cubot.jar differ