@@ -797,330 +797,5 @@ public void testClearExtendedCorrect() throws MalformedInstructionException {
797797// cpu.decimalAdditionAdjust();
798798// assertEquals(new UnsignedByte(0xD2), registerSet.getA());
799799// assertTrue(io.regs.cc.isMasked(CC_C));
800- // }
801-
802- @ Test
803- public void testGetDirectReadsAddressFromDPAndPC () {
804- Instruction instruction = new ByteInstruction (0x6F , 4 , "CLRM" , INDEXED , ByteInstruction ::clear );
805- io .writeByte (0x00BE , 0xCD );
806- io .writeByte (0xABCD , 0xFF );
807- regs .pc .set (0xBE );
808- regs .dp .set (0xAB );
809- instruction .getDirect (io );
810- assertEquals (1 , instruction .numBytesRead );
811- assertEquals (0xABCD , instruction .addressRead .getInt ());
812- assertEquals (0xFF , io .readByte (0xABCD ).getShort ());
813- }
814-
815-
816- @ Test
817- public void testGetImmediateReadsAddressFromPC () {
818- Instruction instruction = new ByteInstruction (0x6F , 4 , "CLRM" , INDEXED , ByteInstruction ::clear );
819- io .writeByte (0xBEEE , 0xAB );
820- regs .pc .set (0xBEEE );
821- instruction .getImmediate (io );
822- assertEquals (1 , instruction .numBytesRead );
823- assertEquals (0xAB , instruction .byteRead .getShort ());
824- assertEquals (0xBEEE , instruction .addressRead .getInt ());
825- }
826-
827- @ Test
828- public void testGetImmediateWordReadsAddressFromPC () {
829- Instruction instruction = new ByteInstruction (0x6F , 4 , "CLRM" , INDEXED , ByteInstruction ::clear );
830- instruction .isByteSized = false ;
831- io .writeWord (0xBEEE , 0xABCD );
832- regs .pc .set (0xBEEE );
833- instruction .getImmediate (io );
834- assertEquals (2 , instruction .numBytesRead );
835- assertEquals (0xABCD , instruction .wordRead .getInt ());
836- assertEquals (0xBEEE , instruction .addressRead .getInt ());
837- }
838-
839- @ Test
840- public void testGetExtendedWorksCorrectly () {
841- Instruction instruction = new ByteInstruction (0x6F , 4 , "CLRM" , EXTENDED , ByteInstruction ::clear );
842- instruction .isByteSized = false ;
843- io .writeWord (0xBEEE , 0xABCD );
844- io .writeWord (0xABCD , 0xDEAD );
845- regs .pc .set (0xBEEE );
846- instruction .getExtended (io );
847- assertEquals (2 , instruction .numBytesRead );
848- assertEquals (0xDEAD , instruction .wordRead .getInt ());
849- assertEquals (0xABCD , instruction .addressRead .getInt ());
850- }
851-
852- // @Test
853- // public void testGetIndexedZeroOffset() throws MalformedInstructionException {
854- // Instruction instruction = new ByteInstruction(0x6F, 4, "CLRM", INDEXED, ByteInstruction::clear);
855- // instruction.getIndexed(io);
856- // regs.x.set(0xB000);
857- // io.writeByte(0x0000, 0x84);
858- // assertEquals(0xB000, instruction.byteRead.getShort());
859- // }
860- //
861- // @Test
862- // public void testGetIndexedZeroOffsetIndirect() throws MalformedInstructionException {
863- // regs.x.set(new UnsignedWord(0xB000));
864- // io.writeWord(new UnsignedWord(0xB000), new UnsignedWord(0xBEEF));
865- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x94));
866- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
867- // }
868- //
869- // @Test
870- // public void testGetIndexed5BitPositiveOffset() throws MalformedInstructionException {
871- // regs.x.set(new UnsignedWord(0xB000));
872- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x01));
873- // assertEquals(new UnsignedWord(0xB001), io.getIndexed().value);
874- // }
875- //
876- // @Test
877- // public void testGetIndexed5BitNegativeOffset() throws MalformedInstructionException {
878- // regs.x.set(new UnsignedWord(0xB000));
879- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x1F));
880- // assertEquals(new UnsignedWord(0xAFFF), io.getIndexed().value);
881- // }
882- //
883- // @Test
884- // public void testGetIndexedRPostIncrement() throws MalformedInstructionException {
885- // regs.x.set(new UnsignedWord(0xB000));
886- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x80));
887- // assertEquals(new UnsignedWord(0xB000), io.getIndexed().value);
888- // assertEquals(new UnsignedWord(0xB001), regs.x);
889- // }
890- //
891- // @Test
892- // public void testGetIndexedRPostIncrementTwice() throws MalformedInstructionException {
893- // regs.x.set(new UnsignedWord(0xB000));
894- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x81));
895- // assertEquals(new UnsignedWord(0xB000), io.getIndexed().value);
896- // assertEquals(new UnsignedWord(0xB002), regs.x);
897- // }
898- //
899- // @Test
900- // public void testGetIndexedRPostIncrementTwiceIndirect() throws MalformedInstructionException {
901- // regs.x.set(new UnsignedWord(0xB000));
902- // io.writeWord(new UnsignedWord(0xB000), new UnsignedWord(0xBEEF));
903- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x91));
904- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
905- // assertEquals(new UnsignedWord(0xB002), regs.x);
906- // }
907- //
908- // @Test
909- // public void testGetIndexedRDecrement() throws MalformedInstructionException {
910- // regs.x.set(new UnsignedWord(0xB000));
911- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x82));
912- // assertEquals(new UnsignedWord(0xAFFF), io.getIndexed().value);
913- // assertEquals(new UnsignedWord(0xAFFF), regs.x);
914- // }
915- //
916- // @Test
917- // public void testGetIndexedRDecrementTwice() throws MalformedInstructionException {
918- // regs.x.set(new UnsignedWord(0xB000));
919- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x83));
920- // assertEquals(new UnsignedWord(0xAFFE), io.getIndexed().value);
921- // assertEquals(new UnsignedWord(0xAFFE), regs.x);
922- // }
923- //
924- // @Test
925- // public void testGetIndexedRDecrementTwiceIndirect() throws MalformedInstructionException {
926- // regs.x.set(new UnsignedWord(0xB000));
927- // io.writeWord(new UnsignedWord(0xAFFE), new UnsignedWord(0xBEEF));
928- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x93));
929- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
930- // assertEquals(new UnsignedWord(0xAFFE), regs.x);
931- // }
932- //
933- // @Test
934- // public void testGetIndexedRWithBOffset() throws MalformedInstructionException {
935- // regs.x.set(new UnsignedWord(0xB000));
936- // regs.b.set(new UnsignedByte(0x0B));
937- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x85));
938- // assertEquals(new UnsignedWord(0xB00B), io.getIndexed().value);
939- // }
940- //
941- // @Test
942- // public void testGetIndexedRWithBOffsetIndirect() throws MalformedInstructionException {
943- // regs.x.set(new UnsignedWord(0xB000));
944- // regs.b.set(new UnsignedByte(0x0B));
945- // io.writeWord(new UnsignedWord(0xB00B), new UnsignedWord(0xBEEF));
946- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x95));
947- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
948- // }
949- //
950- // @Test
951- // public void testGetIndexedRWithAOffset() throws MalformedInstructionException {
952- // regs.x.set(new UnsignedWord(0xB000));
953- // regs.a.set(new UnsignedByte(0x0A));
954- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x86));
955- // assertEquals(new UnsignedWord(0xB00A), io.getIndexed().value);
956- // }
957- //
958- // @Test
959- // public void testGetIndexedRWithAOffsetIndirect() throws MalformedInstructionException {
960- // regs.x.set(new UnsignedWord(0xB000));
961- // regs.a.set(new UnsignedByte(0x0A));
962- // io.writeWord(new UnsignedWord(0xB00A), new UnsignedWord(0xBEEF));
963- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x96));
964- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
965- // }
966- //
967- // @Test
968- // public void testGetIndexed8BitPositiveOffset() throws MalformedInstructionException {
969- // regs.x.set(new UnsignedWord(0xB000));
970- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x8802));
971- // assertEquals(new UnsignedWord(0xB002), io.getIndexed().value);
972- // }
973- //
974- // @Test
975- // public void testGetIndexed8BitNegativeOffset() throws MalformedInstructionException {
976- // regs.x.set(new UnsignedWord(0xB000));
977- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x88FE));
978- // assertEquals(new UnsignedWord(0xAFFE), io.getIndexed().value);
979- // }
980- //
981- // @Test
982- // public void testGetIndexed8BitPositiveOffsetIndirect() throws MalformedInstructionException {
983- // regs.x.set(new UnsignedWord(0xB000));
984- // io.writeWord(new UnsignedWord(0xB002), new UnsignedWord(0xBEEF));
985- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x9802));
986- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
987- // }
988- //
989- // @Test
990- // public void testGetIndexed8BitNegativeOffsetIndirect() throws MalformedInstructionException {
991- // regs.x.set(new UnsignedWord(0xB000));
992- // io.writeWord(new UnsignedWord(0xAFFE), new UnsignedWord(0xBEEF));
993- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x98FE));
994- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
995- // }
996- //
997- // @Test
998- // public void testGetIndexed16BitPositiveOffset() throws MalformedInstructionException {
999- // regs.x.set(new UnsignedWord(0xB000));
1000- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x89));
1001- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0x0200));
1002- // assertEquals(new UnsignedWord(0xB200), io.getIndexed().value);
1003- // }
1004- //
1005- // @Test
1006- // public void testGetIndexed16BitNegativeOffset() throws MalformedInstructionException {
1007- // regs.x.set(new UnsignedWord(0xB000));
1008- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x89));
1009- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0xFE00));
1010- // assertEquals(new UnsignedWord(0xAE00), io.getIndexed().value);
1011- // }
1012- //
1013- // @Test
1014- // public void testGetIndexed16BitPositiveOffsetIndirect() throws MalformedInstructionException {
1015- // regs.x.set(new UnsignedWord(0xB000));
1016- // io.writeWord(new UnsignedWord(0xB200), new UnsignedWord(0xBEEF));
1017- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x99));
1018- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0x0200));
1019- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1020- // }
1021- //
1022- // @Test
1023- // public void testGetIndexed16BitNegativeOffsetIndirect() throws MalformedInstructionException {
1024- // regs.x.set(new UnsignedWord(0xB000));
1025- // io.writeWord(new UnsignedWord(0xAE00), new UnsignedWord(0xBEEF));
1026- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x99));
1027- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0xFE00));
1028- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1029- // }
1030- //
1031- // @Test
1032- // public void testGetIndexedRWithDOffset() throws MalformedInstructionException {
1033- // regs.x.set(new UnsignedWord(0xB000));
1034- // regs.setD(new UnsignedWord(0x0200));
1035- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x8B));
1036- // assertEquals(new UnsignedWord(0xB200), io.getIndexed().value);
1037- // }
1038- //
1039- // @Test
1040- // public void testGetIndexedRWithDOffsetIndirect() throws MalformedInstructionException {
1041- // regs.x.set(new UnsignedWord(0xB000));
1042- // regs.setD(new UnsignedWord(0x0200));
1043- // io.writeWord(new UnsignedWord(0xB200), new UnsignedWord(0xBEEF));
1044- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x9B));
1045- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1046- // }
1047- //
1048- // @Test
1049- // public void testGetIndexedPCWith8BitPositiveOffset() throws MalformedInstructionException {
1050- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x8C0A));
1051- // assertEquals(new UnsignedWord(0x000C), io.getIndexed().value);
1052- // }
1053- //
1054- // @Test
1055- // public void testGetIndexedPCWith8BitNegativeOffset() throws MalformedInstructionException {
1056- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x8CFC));
1057- // assertEquals(new UnsignedWord(0xFFFE), io.getIndexed().value);
1058- // }
1059- //
1060- // @Test
1061- // public void testGetIndexedPCWith8BitPositiveOffsetIndexed() throws MalformedInstructionException {
1062- // io.writeWord(new UnsignedWord(0x000C), new UnsignedWord(0xBEEF));
1063- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x9C0A));
1064- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1065- // }
1066- //
1067- // @Test
1068- // public void testGetIndexedPCWith8BitNegativeOffsetIndexed() throws MalformedInstructionException {
1069- // memory.rom = new short [0x4000];
1070- // memory.rom[0x3FFC] = (short) 0xBE;
1071- // memory.rom[0x3FFD] = (short) 0xEF;
1072- //
1073- // io.writeWord(new UnsignedWord(0x0000), new UnsignedWord(0x9CFA));
1074- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1075- // }
1076- //
1077- // @Test
1078- // public void testGetIndexedPCWith16BitPositiveOffset() throws MalformedInstructionException {
1079- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x8D));
1080- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0x0200));
1081- // assertEquals(new UnsignedWord(0x0203), io.getIndexed().value);
1082- // }
1083- //
1084- // @Test
1085- // public void testGetIndexedPCWith16BitNegativeOffset() throws MalformedInstructionException {
1086- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x8D));
1087- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0xFE00));
1088- // assertEquals(new UnsignedWord(0xFE03), io.getIndexed().value);
1089- // }
1090- //
1091- // @Test
1092- // public void testGetIndexedPCWith16BitPositiveOffsetIndexed() throws MalformedInstructionException {
1093- // io.writeWord(new UnsignedWord(0x0203), new UnsignedWord(0xBEEF));
1094- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x9D));
1095- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0x0200));
1096- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1097- // }
1098- //
1099- // @Test
1100- // public void testGetIndexedPCWith16BitNegativeOffsetIndexed() throws MalformedInstructionException {
1101- // io.writeWord(new UnsignedWord(0xFE03), new UnsignedWord(0xBEEF));
1102- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x9D));
1103- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0xFE00));
1104- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1105- // }
1106- //
1107- // @Test
1108- // public void testGetIndexedExtendedIndirect() throws MalformedInstructionException {
1109- // io.writeWord(new UnsignedWord(0xB000), new UnsignedWord(0xBEEF));
1110- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x9F));
1111- // io.writeWord(new UnsignedWord(0x0001), new UnsignedWord(0xB000));
1112- // assertEquals(new UnsignedWord(0xBEEF), io.getIndexed().value);
1113- // }
1114- //
1115- // @Test(expected = MalformedInstructionException.class)
1116- // public void testGetIndexedIllegalPostByteExceptionOnRPostIncrement() throws MalformedInstructionException {
1117- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x90));
1118- // io.getIndexed();
1119- // }
1120- //
1121- // @Test(expected = MalformedInstructionException.class)
1122- // public void testGetIndexedIllegalPostByteExceptionOnRPostDecrement() throws MalformedInstructionException {
1123- // io.writeByte(new UnsignedWord(0x0000), new UnsignedByte(0x92));
1124- // io.getIndexed();
1125800// }
1126801}
0 commit comments