public virtual void TestAddrRegs() { for (int r = 0; r < 7; r++) { cpu.SetAddrRegisterByte(r, 0xaa); Assert.Equal(0xaa, cpu.GetAddrRegisterByte(r)); Assert.Equal(0xaa, cpu.GetAddrRegisterWord(r)); Assert.Equal(0xaa, cpu.GetAddrRegisterLong(r)); Assert.Equal(-86, cpu.GetAddrRegisterByteSigned(r)); Assert.Equal(170, cpu.GetAddrRegisterWordSigned(r)); cpu.SetAddrRegisterWord(r, 0xa5a5); Assert.Equal(0xa5, cpu.GetAddrRegisterByte(r)); Assert.Equal(0xa5a5, cpu.GetAddrRegisterWord(r)); Assert.Equal(0xa5a5, cpu.GetAddrRegisterLong(r)); Assert.Equal(-91, cpu.GetAddrRegisterByteSigned(r)); Assert.Equal(-23131, cpu.GetAddrRegisterWordSigned(r)); cpu.SetAddrRegisterLong(r, -2054847099); Assert.Equal(0x85, cpu.GetAddrRegisterByte(r)); Assert.Equal(0x8585, cpu.GetAddrRegisterWord(r)); Assert.Equal(-2054847099, cpu.GetAddrRegisterLong(r)); Assert.Equal(-123, cpu.GetAddrRegisterByteSigned(r)); Assert.Equal(-31355, cpu.GetAddrRegisterWordSigned(r)); cpu.SetAddrRegisterLong(r, 305419896); Assert.Equal(0x78, cpu.GetAddrRegisterByte(r)); Assert.Equal(0x5678, cpu.GetAddrRegisterWord(r)); Assert.Equal(305419896, cpu.GetAddrRegisterLong(r)); Assert.Equal(0x78, cpu.GetAddrRegisterByteSigned(r)); Assert.Equal(0x5678, cpu.GetAddrRegisterWordSigned(r)); } }
protected void HandleAddrRegs(string[] tokens) { if (tokens is null) { throw new ArgumentNullException(nameof(tokens)); } string reg = tokens[0].Trim(); if (reg.Length != 2) { writer.WriteLine($"Bad identifier [{reg}]"); return; } var r = reg[1] - '0'; if (r < 0 || r > 7) { writer.WriteLine($"Bad identifier [{reg}]"); return; } if (tokens.Length == 2) { int value; try { value = ParseInt(tokens[1]); } catch (FormatException) { writer.WriteLine($"Bad value [{tokens[1]}]"); return; } cpu.SetAddrRegisterLong(r, value); } else { writer.WriteLine("A{0}: {1}", r, cpu.GetAddrRegisterLong(r).ToString("x8", CultureInfo.InvariantCulture)); } }