From 9aa405120fb5a81fc3558f407b8c47959f15ed5a Mon Sep 17 00:00:00 2001 From: jl7719 Date: Sat, 19 Dec 2020 05:37:54 +0000 Subject: [PATCH] Fix divu testcases and add divu-5 testcase Updated the edgecase ref file --- inputs/divu/divu-3.instr.txt | 8 +-- inputs/divu/divu-3.ref.txt | 2 +- inputs/divu/divu-4.instr.txt | 6 +-- inputs/divu/divu-4.ref.txt | 2 +- inputs/divu/divu-5.instr.txt | 9 ++++ inputs/divu/divu-5.ref.txt | 1 + reference/edgecases/divurefneedsfixing.txt | 63 +++++++++++----------- 7 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 inputs/divu/divu-5.instr.txt create mode 100644 inputs/divu/divu-5.ref.txt diff --git a/inputs/divu/divu-3.instr.txt b/inputs/divu/divu-3.instr.txt index 428201d..830eef1 100644 --- a/inputs/divu/divu-3.instr.txt +++ b/inputs/divu/divu-3.instr.txt @@ -1,7 +1,7 @@ -3c04ffff -34a4fffc +3c04FFFF +3484FFFC 3c05ffff -34a5fffe +34A5FFFE 0085001B -00001012 +00001010 00000008 \ No newline at end of file diff --git a/inputs/divu/divu-3.ref.txt b/inputs/divu/divu-3.ref.txt index d8263ee..77bd6fe 100644 --- a/inputs/divu/divu-3.ref.txt +++ b/inputs/divu/divu-3.ref.txt @@ -1 +1 @@ -2 \ No newline at end of file +4294967292 \ No newline at end of file diff --git a/inputs/divu/divu-4.instr.txt b/inputs/divu/divu-4.instr.txt index 1ce8c6a..9f75e09 100644 --- a/inputs/divu/divu-4.instr.txt +++ b/inputs/divu/divu-4.instr.txt @@ -1,6 +1,6 @@ 34040004 -3c05ffff -34a5fffe +3c05FFFF +34A5FFFC 0085001B -00001012 +00001010 00000008 \ No newline at end of file diff --git a/inputs/divu/divu-4.ref.txt b/inputs/divu/divu-4.ref.txt index d8263ee..bf0d87a 100644 --- a/inputs/divu/divu-4.ref.txt +++ b/inputs/divu/divu-4.ref.txt @@ -1 +1 @@ -2 \ No newline at end of file +4 \ No newline at end of file diff --git a/inputs/divu/divu-5.instr.txt b/inputs/divu/divu-5.instr.txt new file mode 100644 index 0000000..9c8b22a --- /dev/null +++ b/inputs/divu/divu-5.instr.txt @@ -0,0 +1,9 @@ +3404FF00 +3484FF04 +340500FF +34A500FF +0085001A +00002010 +00002812 +00851021 +00000008 \ No newline at end of file diff --git a/inputs/divu/divu-5.ref.txt b/inputs/divu/divu-5.ref.txt new file mode 100644 index 0000000..ddc17b2 --- /dev/null +++ b/inputs/divu/divu-5.ref.txt @@ -0,0 +1 @@ +260 \ No newline at end of file diff --git a/reference/edgecases/divurefneedsfixing.txt b/reference/edgecases/divurefneedsfixing.txt index acd723c..31af103 100644 --- a/reference/edgecases/divurefneedsfixing.txt +++ b/reference/edgecases/divurefneedsfixing.txt @@ -20,61 +20,63 @@ ref file = 2 00851021 00000008 -divu - 3 // -ve/-ve +divu - 3 // check if unsigned despite MSB=1 -lui $4, $0, 65535 -ori $4, $4, -4 -lui $5, $0, 65535 -ori $5, $0, -2 +lui $4, $0, 0xFFFF +ori $4, $4, 0xFFFC +lui $5, $0, 0xFFFF +ori $5, $5, 0xFFFE divu $4, $5 -mflo $2 +mfhi $2 // look at remainder jr $0 -reg file = 2 +reg file = 4294967292 (0xFFFFFFFC) -3c04ffff -34a4fffc +3c04FFFF +3484FFFC 3c05ffff -34a5fffe +34A5FFFE 0085001B -00001012 +00001010 00000008 -divu - 4 // +ve/-ve +divu - 4 // +ve/(-ve value if signed but unsigned div here) -ori $4, $0, 4 -lui $5, $0, 65535 (All 1s 16 bits) -ori $5, $5, -2 +ori $4, $0, 0x4 +lui $5, $0, 0xFFFF +ori $5, $5, 0xFFFC divu $4, $5 -mflo $2 +mfhi $2 jr $0 -reg file = -2 +reg file = 4 (0x4) 34040004 -3c05ffff -3405fffe -0085001A -00001012 +3c05FFFF +34A5FFFC +0085001B +00001010 00000008 -divu - 5 // is it seperating quotients & remainders correctly - when dealing with negatives +divu - 5 // is it seperating quotients & remainders correctly -ori $4, $0, 4 -lui $4, $4, 65535 -ori $5, $0, 3 -lui $5, $5, 65535 +lui $4, $0, 0xFF00 +ori $4, $4, 0xFF04 +lui $5, $0, 0x00FF +ori $5, $5, 0x00FF divu $4, $5 mfhi $4 mflo $5 addu $2,$4,$5 jr $0 -ref file = 2 - as we are adding -1 and -1 using addu +ref file = 256 (remainder) + 4 (quotient) -34040004 -34050003 +3404FF00 +3484FF04 +340500FF +34A500FF 0085001A 00002010 00002812 @@ -85,6 +87,3 @@ ref file = 2 - as we are adding -1 and -1 using addu - - -