In case anybody gets enthusiastic enough about this to start assembling code, here are my test cases. (And do let me know if you see any coverage missing.)
Code:
@pytest.mark.parametrize('signed, value', [
( 0, [0x03]), (-1, [0xFD]),
(-1, [0xF4]), # min 1 byte input
(-1, [0x0C]), # max 1 byte input
( 0, [0x19]), # max 1 byte input (unsigned)
(-1, [0xFF, 0xF3]),
(-1, [0xF3, 0x34]), # min 2 byte input
(-1, [0x0C, 0xCC]), # max 2 byte input
( 0, [0x19, 0x99]), # max 2 byte input (unsigned)
(-1, [0xFF, 0x87, 0x65, 0x43, 0x21]), # -20 million and a bit
(-1, [0x02, 0xab, 0xcd, 0xef, 0x10]), # 11 billion or so
(-1, [0xF4] + [0x00]*254), # max length, approaching min value
(-1, [0x0B] + [0xFF]*254), # max length, approaching max value
( 0, [0x18] + [0xFF]*254), # max length, (unsigned)
])
The expected output is calculated for each test using standard Python 3 functions, along the lines of:
Code:
decval = int.from_bytes(value, byteorder='big', signed=signed)
expected = (decval*10).to_bytes(len(value), byteorder='big', signed=signed)
These cases include both signed and unsigned multiplies (as explained earlier in this thread, the current routine doesn't know the difference, only the caller does), but I don't see any particular reason off-hand to support unsigned if that makes life more difficult.
Of course, if you don't already have a testing framework in which to plop these cases, you may find it easier just to grab
0cjs/8bitdev from GitHub and just replace my routine in
src/bigint.a65 with your own. The test cases are in
src/bigint_test.py, and anything you
print() will be shown if the test case fails. (You can force failure with
assert False.)