Skip to content

Commit

Permalink
Consolidate test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsk2 committed Jun 24, 2023
1 parent 5fbcb17 commit e23d53c
Show file tree
Hide file tree
Showing 41 changed files with 108 additions and 148 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ feature of the F256) heck it should even run on the KIM-1. The following routine
- 8 by 8 bit unsigned multiplication with a 16 bit result
- 8, 16 and 32 bit divison of unsigned integers

General division is only implemented for 8, 16 or 32 bit *unisgned integers*. 32 bit divison is roughly 1.6 times
General division is only implemented for 8, 16 or 32 bit *unsigned* integers. 32 bit divison is roughly 1.6 times
slower than 32 bit multiplication (multiplication takes about 3000 clock cycles, division about 5000 cycles). Apart
from multiplication and squaring the routines do not care about where a decimal point (or comma depending on where you
live) is assumed to be and so the library also provides the above operations for fixed point numbers in the variants
mentioned above.
from multiplication, squaring and division the routines do not care about where a decimal point (or comma depending
on where you live) is assumed to be and so the library also provides the above operations for fixed point numbers in
the variants mentioned above.

The assembled binary has a size of about 1755 bytes in the default configuration (512 of which are part of a table
which is used for 16 bit multiplication) but you can customize the library to be as short as about 1200 bytes.
The assembled binary has a size of about 1800 bytes in the default configuration (512 of which are part of a table
which is used for 16 bit multiplication) but you can customize the library to be as short as about 1300 bytes. If you
enable all features the library has a size of about 2000 bytes.

# Building and customizing

Expand Down
4 changes: 2 additions & 2 deletions arith.a
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ divMod32BitUnsigned
.n3
lda div32_HELP+1
cmp div32_DIVISOR+1
.endCmp32
;+callFunc sub32SwitchedUnsigned, div32_DIVISOR, div32_HELP
.endCmp32
bcc .skip32
;+callFunc sub32SwitchedUnsigned, div32_DIVISOR, div32_HELP
sec
lda div32_HELP+1
sbc div32_DIVISOR+1
Expand Down
7 changes: 4 additions & 3 deletions tests/add1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(test_dir .. "arith_base")

valL = "-AAEEDDFF"
valR = "+FFDDEEAA"
opRes = "+54EF10AB"
test_data = {
[1] = {valL = "-AAEEDDFF", valR = "+FFDDEEAA", opRes = "+54EF10AB"},
}

14 changes: 11 additions & 3 deletions tests/arith_base.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
require(test_dir .. "conv")

iter_count = 0

function arrange()
set_memory(load_address+3, txt_to_mem(valL))
set_memory(load_address+8, txt_to_mem(valR))
iter_count = iter_count + 1
set_pc(load_address)
set_memory(load_address+3, txt_to_mem(test_data[iter_count].valL))
set_memory(load_address+8, txt_to_mem(test_data[iter_count].valR))
end

function num_iterations()
return #test_data
end

function assert()
op_res = mem_to_text(get_memory(load_address+8, 5))
res = (string.lower(op_res) == string.lower(opRes))
res = (string.lower(op_res) == string.lower(test_data[iter_count].opRes))
err_msg = ""

if not res then
Expand Down
12 changes: 10 additions & 2 deletions tests/arith_base_mono.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
require(test_dir .. "conv")

iter_count = 0

function arrange()
set_memory(load_address+3, txt_to_mem(valL))
iter_count = iter_count + 1
set_pc(load_address)
set_memory(load_address+3, txt_to_mem(test_data[iter_count].valL))
end

function num_iterations()
return #test_data
end

function assert()
op_res = mem_to_text(get_memory(load_address+3, 5))
res = (string.lower(op_res) == string.lower(opRes))
res = (string.lower(op_res) == string.lower(test_data[iter_count].opRes))
err_msg = ""

if not res then
Expand Down
8 changes: 6 additions & 2 deletions tests/double1.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require(test_dir .. "arith_base_mono")

valL = "-00000001"
opRes = "-00000002"
test_data = {
[1] = {valL = "-00000001", opRes = "-00000002"},
[2] = {valL = "-80000000", opRes = "-00000000"},
[3] = {valL = "-00000080", opRes = "-00000100"}
}

5 changes: 0 additions & 5 deletions tests/double2.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/double2.lua

This file was deleted.

5 changes: 0 additions & 5 deletions tests/double3.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/double3.lua

This file was deleted.

7 changes: 4 additions & 3 deletions tests/fixed161.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(test_dir .. "arith_base")

valL = "-00038000"
valR = "+00048000"
opRes = "-000FC000"
test_data = {
[1] = {valL = "-00038000", valR = "+00048000", opRes = "-000FC000"},
}

5 changes: 3 additions & 2 deletions tests/fixed162.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require(test_dir .. "arith_base_mono")

valL = "-00038000"
opRes = "+000C4000"
test_data = {
[1] = {valL = "-00038000", opRes = "+000C4000"},
}
8 changes: 5 additions & 3 deletions tests/fixed241.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require(test_dir .. "arith_base")

valL = "-0000FF80"
valR = "+00014080"
opRes = "-013FDFC0"
test_data = {
[1] = {valL = "-0000FF80", valR = "+00014080", opRes = "-013FDFC0"},
}


5 changes: 3 additions & 2 deletions tests/fixed242.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require(test_dir .. "arith_base_mono")

valL = "-0002CDC0"
opRes = "+07DC5D10"
test_data = {
[1] = {valL = "-0002CDC0", opRes = "+07DC5D10"},
}
7 changes: 4 additions & 3 deletions tests/fixed81.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(test_dir .. "arith_base")

valL = "-03800000"
valR = "+04800000"
opRes = "-0FC00000"
test_data = {
[1] = {valL = "-03800000", valR = "+04800000", opRes = "-0FC00000"},
}

5 changes: 3 additions & 2 deletions tests/fixed82.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require(test_dir .. "arith_base_mono")

valL = "-03800000"
opRes = "+0C400000"
test_data = {
[1] = {valL = "-03800000", opRes = "+0C400000"},
}
6 changes: 4 additions & 2 deletions tests/halve1.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require(test_dir .. "arith_base_mono")

valL = "+80000000"
opRes = "+40000000"
test_data = {
[1] = {valL = "+80000000", opRes = "+40000000"},
[2] = {valL = "+00010000", opRes = "+00008000"}
}
5 changes: 0 additions & 5 deletions tests/halve2.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/halve2.lua

This file was deleted.

8 changes: 6 additions & 2 deletions tests/iszero1.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require(test_dir .. "mono_test")

valL = "-00000000"
refVal = true
test_data = {
[1] = {valL = "-00000000", refVal = true},
[2] = {valL = "+00000000", refVal = true},
[3] = {valL = "+00000001", refVal = false},
[4] = {valL = "+01000000", refVal = false}
}
5 changes: 0 additions & 5 deletions tests/iszero2.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/iszero2.lua

This file was deleted.

5 changes: 0 additions & 5 deletions tests/iszero3.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/iszero3.lua

This file was deleted.

5 changes: 0 additions & 5 deletions tests/iszero4.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/iszero4.lua

This file was deleted.

12 changes: 10 additions & 2 deletions tests/mono_test.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
require(test_dir .. "conv")

iter_count = 0

function arrange()
set_memory(load_address+3, txt_to_mem(valL))
iter_count = iter_count + 1
set_pc(load_address)
set_memory(load_address+3, txt_to_mem(test_data[iter_count].valL))
end

function num_iterations()
return #test_data
end

function assert()
err_msg = ""
res = contains_flag("Z") == refVal
res = contains_flag("Z") == test_data[iter_count].refVal

if not res then
err_msg = "Zero flag does not have expected value"
Expand Down
7 changes: 4 additions & 3 deletions tests/move1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(test_dir .. "arith_base")

valL = "-AAEEDDFF"
valR = "+00000000"
opRes = "-AAEEDDFF"
test_data = {
[1] = {valL = "-AAEEDDFF", valR = "+00000000", opRes = "-AAEEDDFF"},
}

10 changes: 7 additions & 3 deletions tests/mul1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require(test_dir .. "arith_base")

valL = "-AAEEDDFF"
valR = "+FFDDEEAA"
opRes = "-3B257D56"
test_data = {
[1] = {valL = "-AAEEDDFF", valR = "+FFDDEEAA", opRes = "-3B257D56"},
[2] = {valL = "-00000001", valR = "+FFDDEEAA", opRes = "-FFDDEEAA"},
[3] = {valL = "-00000000", valR = "+FFDDEEAA", opRes = "-00000000"},
[4] = {valL = "-ABFE2651", valR = "-7B6549ED", opRes = "+BC2B91FD"},
}

5 changes: 0 additions & 5 deletions tests/mul2.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/mul2.lua

This file was deleted.

5 changes: 0 additions & 5 deletions tests/mul3.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/mul3.lua

This file was deleted.

5 changes: 0 additions & 5 deletions tests/mul4.json

This file was deleted.

5 changes: 0 additions & 5 deletions tests/mul4.lua

This file was deleted.

7 changes: 4 additions & 3 deletions tests/mulsquare1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require(test_dir .. "arith_base")

valL = "-17EEFB98"
valR = "-17EEFB98"
opRes = "+15E36A40"
test_data = {
[1] = {valL = "-17EEFB98", valR = "-17EEFB98", opRes = "+15E36A40"},
}

6 changes: 4 additions & 2 deletions tests/neg1.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require(test_dir .. "arith_base_mono")

valL = "+80000000"
opRes = "-80000000"
test_data = {
[1] = {valL = "+80000000", opRes = "-80000000"},
[2] = {valL = "-00050000", opRes = "+00050000"}
}
5 changes: 0 additions & 5 deletions tests/neg2.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/neg2.lua

This file was deleted.

Loading

0 comments on commit e23d53c

Please sign in to comment.