public void Jump_Unconditional_Address() { var sourceCode = " JP 194Fh"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <UnconditionalJumpCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <AddressWithoutParenthesisOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.JP, actualCommand.OpCode); Assert.AreEqual(0x194F, actualOperand.MemoryAddress); }
public void JumpTests_UnconditionalCallCommand_ToLabeledAddress() { var sourceCode = " CALL overThere"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <UnconditionalCallCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <LabeledAddressWithoutParenthesisOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.CALL, actualCommand.OpCode); Assert.AreEqual("overThere", actualOperand.Label); }
public void Jump_Unconditional_IndirectRegister() { var sourceCode = " JP (IX)"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <UnconditionalJumpCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <IndirectRegisterOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.JP, actualCommand.OpCode); Assert.AreEqual(ExtendedRegister.IX, actualOperand.Register); }
public void JumpTests_UnconditionalCallCommand() { var sourceCode = " CALL 45B2h"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <UnconditionalCallCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <AddressWithoutParenthesisOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.CALL, actualCommand.OpCode); Assert.AreEqual(0x45b2, actualOperand.MemoryAddress); }
public void SingleOperandParsing_Or_Register() { var sourceCode = " OR D"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <OrCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.OR, actualCommand.OpCode); Assert.AreEqual(Register.D, actualOperand.Register); }
public void JumpTests_DJNZ() { var sourceCode = " DJNZ loop1"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <DjnzCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <LabeledAddressWithoutParenthesisOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.DJNZ, actualCommand.OpCode); Assert.AreEqual("loop1", actualOperand.Label); }
public void JumpRelative_Unconditional_Labeled() { var sourceCode = " JR elsewhere"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <UnconditionalRelativeJumpCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <LabeledAddressWithoutParenthesisOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.JR, actualCommand.OpCode); Assert.AreEqual("elsewhere", actualOperand.Label); }
public void SingleOperandParsing_Xor_Immediate() { var sourceCode = " XOR 8Ah"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <XorCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.XOR, actualCommand.OpCode); Assert.AreEqual(0x8A, actualOperand.ImmediateValue); }
public void SingleOperandParsing_Subtract_NegativeImmediate() { var sourceCode = " SUB -4"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <SubCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.SUB, actualCommand.OpCode); Assert.AreEqual(0xFC, actualOperand.ImmediateValue); }
public void JumpTests_ConditionalReturn() { var sourceCode = " RET Z"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <ConditionalReturnCommand>(parser.ParseLine(sourceCode)); var conditionOperand = AssertExtension.IsCorrectOperandType <ConditionOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.RET, actualCommand.OpCode); Assert.AreEqual(JumpConditions.Z, conditionOperand.Condition); }
public void SingleOperandParsing_AndIndirectAddress() { var sourceCode = " AND (HL)"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <AndCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <IndirectRegisterOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.AND, actualCommand.OpCode); Assert.AreEqual(ExtendedRegister.HL, actualOperand.Register); }
public void ArithmeticParing_SubCommand() { var sourceCode = " sub B"; var parser = new Z80LineParser("#", ""); var actualCommand = AssertExtension.IsCorrectCommandType <SubCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.SUB, actualCommand.OpCode); Assert.AreEqual(Register.B, actualOperand.Register); }
public void SingleOperandParsing_PopCommand() { var sourceCode = " POP AF"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <PopCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.POP, actualCommand.OpCode); Assert.AreEqual(ExtendedRegister.AF, actualOperand.Register); }
public void SingleOperandParsing_InterruptMode() { var sourceCode = " IM 1"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <InterruptModeCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.IM, actualCommand.OpCode); Assert.AreEqual(1, actualOperand.ImmediateValue); }
public void SingleOperandParsing_Decrement_IndirectRegister() { var sourceCode = " DEC (HL)"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <DecrementCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <IndirectRegisterOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.DEC, actualCommand.OpCode); Assert.AreEqual(ExtendedRegister.HL, actualOperand.Register); }
public void SingleOperandParsing_AndImmediate() { var sourceCode = " AND 5Ch"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <AndCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.AND, actualCommand.OpCode); Assert.AreEqual(0x5C, actualOperand.ImmediateValue); }
public void LoadParing_LoadCommand_TwoExtendedRegisters() { var sourceCode = " LD DE,HL"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(ExtendedRegister.HL, actualSourceOperand.Register); Assert.AreEqual(ExtendedRegister.DE, actualDestinationOperand.Register); }
public void LoadParing_LoadCommand_FromMemory_SixteenBit() { var sourceCode = " LD BC,(#48a9)"; var parser = new Z80LineParser("#", ""); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ExtendedAddressOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(0x48a9, actualSourceOperand.MemoryAddress); Assert.AreEqual(ExtendedRegister.BC, actualDestinationOperand.Register); }
public void LoadParing_LoadCommand_HexNumberNoPrefix() { var sourceCode = " LD B,AA"; var parser = new Z80LineParser("", ""); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(0xAA, actualSourceOperand.ImmediateValue); Assert.AreEqual(Register.B, actualDestinationOperand.Register); }
public void LoadParing_LoadCommand_EightBitImmediate() { var sourceCode = " LD B,132"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(132, actualSourceOperand.ImmediateValue); Assert.AreEqual(Register.B, actualDestinationOperand.Register); }
public void ArithmeticParing_CompareCommand() { var sourceCode = " CP (IX-#7f)"; var parser = new Z80LineParser("#", ""); var actualCommand = AssertExtension.IsCorrectCommandType <CompareCommand>(parser.ParseLine(sourceCode)); var actualOperand = AssertExtension.IsCorrectOperandType <DisplacementOperand>(actualCommand.Operand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.CP, actualCommand.OpCode); Assert.AreEqual(ExtendedRegister.IX, actualOperand.Register); Assert.AreEqual(-127, actualOperand.Displacement); }
public void LoadParing_LoadCommand_IndirectRegisterOperand() { var sourceCode = " LD (HL),47h"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <IndirectRegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(0x47, actualSourceOperand.ImmediateValue); Assert.AreEqual(ExtendedRegister.HL, actualDestinationOperand.Register); }
public void LoadParsing_LowerCaseRegisters() { var sourceCode = " LD b,c"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.LD, actualCommand.OpCode); Assert.AreEqual(Register.C, actualSourceOperand.Register); Assert.AreEqual(Register.B, actualDestinationOperand.Register); }
public void TwoOperandParsing_OutCommand_ToCIndirect() { var sourceCode = " OUT (c),b"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <OutCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <IndirectShortRegOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.OUT, actualCommand.OpCode); Assert.AreEqual(Register.B, actualSourceOperand.Register); Assert.AreEqual(Register.C, actualDestinationOperand.Register); }
public void ArithmeticParing_AddCommand() { var sourceCode = " ADD A,0x47"; var parser = new Z80LineParser("0x", ""); var actualCommand = AssertExtension.IsCorrectCommandType <AddCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ImmediateOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.ADD, actualCommand.OpCode); Assert.AreEqual(0x47, actualSourceOperand.ImmediateValue); Assert.AreEqual(Register.A, actualDestinationOperand.Register); }
public void LoadParing_LoadCommand_ExtraneousSpace() { var sourceCode = " LD BC, 132"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <ImmediateExtendedOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.LD, actualCommand.OpCode); Assert.AreEqual(132, actualSourceOperand.ImmediateValue); Assert.AreEqual(ExtendedRegister.BC, actualDestinationOperand.Register); }
public void LoadParing_LoadCommand_LabeledImmediate() { var sourceCode = " LD HL,currentScore"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <LabeledImmediateOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterExtendedOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual("currentScore", actualSourceOperand.Label); Assert.AreEqual("currentScore", actualSourceOperand.DisplayValue); Assert.AreEqual(ExtendedRegister.HL, actualDestinationOperand.Register); }
public void Jump_Conditional_Labeled() { var sourceCode = " JP NC,toplace"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <ConditionalJumpCommand>(parser.ParseLine(sourceCode)); var conditionOperand = AssertExtension.IsCorrectOperandType <ConditionOperand>(actualCommand.ConditionOperand); var addressOperand = AssertExtension.IsCorrectOperandType <LabeledAddressWithoutParenthesisOperand>(actualCommand.AddressOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(JumpConditions.NC, conditionOperand.Condition); Assert.AreEqual(OpCode.JP, actualCommand.OpCode); Assert.AreEqual("toplace", addressOperand.Label); }
public void TwoOperandParsing_OutCommand_FromAccumulator() { var sourceCode = " OUT (34),A"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <OutCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <ExtendedAddressOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual(OpCode.OUT, actualCommand.OpCode); Assert.AreEqual(Register.A, actualSourceOperand.Register); Assert.AreEqual(34, actualDestinationOperand.MemoryAddress); }
public void LoadParing_LoadCommand_LabeledAddress() { var sourceCode = " LD E,(curScore)"; var parser = new Z80LineParser(); var actualCommand = AssertExtension.IsCorrectCommandType <LoadCommand>(parser.ParseLine(sourceCode)); var actualSourceOperand = AssertExtension.IsCorrectOperandType <LabeledAddressOperand>(actualCommand.SourceOperand); var actualDestinationOperand = AssertExtension.IsCorrectOperandType <RegisterOperand>(actualCommand.DestinationOperand); Assert.AreEqual(sourceCode, actualCommand.SourceText); Assert.AreEqual("curScore", actualSourceOperand.Label); Assert.AreEqual("(curScore)", actualSourceOperand.DisplayValue); Assert.AreEqual(Register.E, actualDestinationOperand.Register); }