-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 8 bit by 8 bit unsigned division as preparation for 32 bit by 32 …
…bit division
- Loading branch information
Showing
6 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
* = $0800 | ||
|
||
jmp main | ||
|
||
!source "zeropage.a" | ||
!source "arith.a" | ||
|
||
main | ||
jsr divMod8Bit | ||
brk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Name": "8 by 8 bit division 1", | ||
"TestDriverSource": "div81.a", | ||
"TestScript": "div81.lua" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
test_data = { | ||
[1] = {val1 = 35, val2 = 2}, | ||
[2] = {val1 = 255, val2 = 255}, | ||
[3] = {val1 = 0, val2 = 255}, | ||
[4] = {val1 = 173, val2 = 12}, | ||
[5] = {val1 = 12, val2 = 173}, | ||
[6] = {val1 = 173, val2 = 255}, | ||
[7] = {val1 = 1, val2 = 183}, | ||
[8] = {val1 = 64, val2 = 32}, | ||
[9] = {val1 = 122, val2 = 10}, | ||
[10] = {val1 = 122, val2 = 122} | ||
} | ||
|
||
function num_iterations() | ||
return #test_data | ||
end | ||
|
||
iter_count = 0 | ||
|
||
function arrange() | ||
iter_count = iter_count + 1 | ||
set_pc(load_address) | ||
set_accu(test_data[iter_count].val1) | ||
set_xreg(test_data[iter_count].val2) | ||
end | ||
|
||
function assert() | ||
in1 = test_data[iter_count].val1 | ||
in2 = test_data[iter_count].val2 | ||
|
||
correct_mod = in1 % in2 | ||
res_mod = (get_xreg() == correct_mod) | ||
if not res_mod then | ||
return false, string.format("Unexpected value: %d mod %d is not %d (should be %d)", in1, in2, get_xreg(), correct_mod) | ||
end | ||
|
||
correct_div = math.floor(in1 / in2) | ||
res_div = (get_accu() == correct_div) | ||
if not res_div then | ||
return false, string.format("Unexpected value: %d div %d is not %d (should be %d)", in1, in2, get_accu(), correct_div) | ||
end | ||
|
||
return true, "All OK" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters