Fixed Array.Copy.

This commit is contained in:
José Pedro 2017-10-27 22:45:31 +01:00
parent a12e7ff875
commit 3b6cade435
2 changed files with 19 additions and 10 deletions

View file

@ -38,12 +38,28 @@ namespace Cosmos.Compiler.Tests.Bcl.System.Collections.Generic
Assert.AreEqual(1, xList[2], "List<int>.Insert: xList[2] != 1");
Assert.AreEqual(2, xList[3], "List<int>.Insert: xList[3] != 2");
xList.Insert(0, 7);
Assert.AreEqual(7, xList[0], "List<int>.Insert: xList[0] != 7");
Assert.AreEqual(0, xList[1], "List<int>.Insert: xList[1] != 0");
Assert.AreEqual(5, xList[2], "List<int>.Insert: xList[2] != 5");
Assert.AreEqual(1, xList[3], "List<int>.Insert: xList[3] != 1");
Assert.AreEqual(2, xList[4], "List<int>.Insert: xList[4] != 2");
xList.RemoveAt(2);
Assert.AreEqual(7, xList[0], "List<int>.RemoveAt: xList[0] != 7");
Assert.AreEqual(0, xList[1], "List<int>.RemoveAt: xList[1] != 0");
Assert.AreEqual(1, xList[2], "List<int>.RemoveAt: xList[2] != 1");
Assert.AreEqual(2, xList[3], "List<int>.RemoveAt: xList[3] != 2");
xList.RemoveAt(0);
Assert.AreEqual(0, xList[0], "List<int>.RemoveAt: xList[0] != 0");
Assert.AreEqual(5, xList[1], "List<int>.RemoveAt: xList[1] != 5");
Assert.AreEqual(1, xList[1], "List<int>.RemoveAt: xList[1] != 1");
Assert.AreEqual(2, xList[2], "List<int>.RemoveAt: xList[2] != 2");
// Commented tests depend on #583
//xList.AddRange(new List<int>() { 3, 4, 5 });

View file

@ -71,22 +71,15 @@ namespace Cosmos.Core_Asm
XS.Multiply(EDX);
XS.Set(ECX, EAX);
// if source and destination are equal, jump to end
XS.Set(EAX, ESI);
XS.Add(EAX, ECX);
XS.Compare(EDI, EAX);
XS.Jump(ConditionalTestEnum.Equal, xArrayCopyEndLabel);
XS.Jump(ConditionalTestEnum.LessThanOrEqualTo, xArrayCopyReverseLabel);
XS.Compare(EDI, ESI);
XS.Jump(ConditionalTestEnum.GreaterThan, xArrayCopyReverseLabel);
new Movs { Size = 8, Prefixes = InstructionPrefixes.Repeat };
XS.Jump(xArrayCopyEndLabel);
// source ptr + size >= destination ptr
XS.Label(xArrayCopyReverseLabel);
XS.Comment("Array Reverse Copy: source ptr + size >= destination ptr");
XS.Add(ESI, ECX);
XS.Add(EDI, ECX);