| 1 | # This test verifies arithmetic IMP remainder. |
| 2 | |
| 3 | # First, verify basic function with two positive numbers. |
| 4 | SSSTTSSSSTSN | ST: Push +194 |
| 5 | SSSTSSSSSSTN | ST: Push +128 |
| 6 | TSTT | MA: Remainder |
| 7 | TNSS | IO: Output character |
| 8 | |
| 9 | # The VVS modulo function should always return a positive value. |
| 10 | # C-derived languages (among others) do not share this convention. |
| 11 | |
| 12 | # This test verifies that -3 mod 2 = 1. |
| 13 | SSTTTN | ST: Push -3 |
| 14 | SSSTSN | ST: Push +2 |
| 15 | TSTT | MA: Remainder |
| 16 | TNST | IO: Output digit |
| 17 | |
| 18 | # This test verifies that -3 mod -2 = 1. |
| 19 | SSTTTN | ST: Push -3 |
| 20 | SSTTSN | ST: Push -2 |
| 21 | TSTT | MA: Remainder |
| 22 | TNST | IO: Output digit |
| 23 | |
| 24 | # This test verifies that -3 mod -(2^63) = 3. |
| 25 | SSTTTN | ST: Push -3 |
| 26 | SSTTSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSN | PUSH -(2^63) |
| 27 | TSTT | MA: Remainder |
| 28 | TNST | IO: Output digit |
| 29 | |
| 30 | # All done |
| 31 | NNN | FC: Terminate program |