7.8 KiB
7.8 KiB
Disk 4: Basic Math and Pseudorandom Numbers
The Basic Math collection contains macros and subroutines dedicated to addition, subtraction, multiplication and division operations, as well as a 16-bit comparison routine and several macros for generating pseudorandom numbers. These are grouped into several macro files, as such:
- MAC.D8BY.ASM
- This group contains macros that are used to divide an 8-bit number by a fixed constant between 2 and 10.
- MAC.M8BY.ASM
- This group contains macros that are used to multiply an 8-bit number by a fixed constant between 2 and 10.
- MAC.M16BY.ASM
- This group contains macros that are used to multiply a 16-bit number by a fixed constant between 2 and 10, as well as by 100.
- MAC.MATH8.ASM
- This group contains macros for adding, subtracting, multiplying and dividing 8-bit numbers.
- MAC.MATH16.ASM
- This group contains macros for adding, subtracting, multiplying and dividing 16-bit numbers. It also includes a macro for 16-bit comparison.
- MAC.MATHRND.ASM
- This group contains macros for managing and generating pseudorandom numbers.
MAC.D8BY.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
D8BY2 |
none | none | Divide an 8-bit number by two | NZCV | 6 | 4 |
D8BY3 |
none | none | Divide an 8-bit number by three | NZCV | 29 | 19 |
D8BY4 |
none | none | Divide an 8-bit number by four | NZCV | 8 | 5 |
D8BY5 |
none | none | Divide an 8-bit number by five | NZCV | 34 | 21 |
D8BY6 |
none | none | Divide an 8-bit number by six | NZCV | 36 | 21 |
D8BY7 |
none | none | Divide an 8-bit number by seven | NZCV | 33 | 19 |
D8BY8 |
none | none | Divide an 8-bit number by eight | NZCV | 10 | 6 |
D8BY9 |
none | none | Divide an 8-bit number by nine | NZCV | 36 | 21 |
D8BY10 |
none | none | Divide an 8-bit number by ten | NZCV | 36 | 21 |
MAC.M8BY.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
M8BY2 |
none | none | Multiply an 8-bit number by two | NZCV | 6 | 4 |
M8BY3 |
none | none | Multiply an 8-bit number by three | NZCV | 6 | 4 |
M8BY4 |
none | none | Multiply an 8-bit number by four | NZCV | 8 | 5 |
M8BY5 |
none | none | Multiply an 8-bit number by five | NZCV | 15 | 10 |
M8BY6 |
none | none | Multiply an 8-bit number by six | NZCV | 15 | 10 |
M8BY7 |
none | none | Multiply an 8-bit number by seven | NZCV | 33 | 20 |
M8BY8 |
none | none | Multiply an 8-bit number by eight | NZCV | 10 | 6 |
M8BY9 |
none | none | Multiply an 8-bit number by nine | NZCV | 18 | 11 |
M8BY10 |
none | none | Multiply an 8-bit number by ten | NZCV | 18 | 11 |
MAC.M16BY.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
M16BY2 |
none | none | Multiply a 16-bit number by two | NZCV | 20 | 13 |
M16BY3 |
none | none | Multiply a 16-bit number by three | NZCV | 47 | 32 |
M16BY4 |
none | none | Multiply a 16-bit number by four | NZCV | 37 | 24 |
M16BY5 |
none | none | Multiply a 16-bit number by five | NZCV | 46 | 30 |
M16BY6 |
none | none | Multiply a 16-bit number by six | NZCV | 58 | 38 |
M16BY7 |
none | none | Multiply a 16-bit number by seven | NZCV | 72 | 47 |
M16BY8 |
none | none | Multiply a 16-bit number by eight | NZCV | 34 | 21 |
M16BY9 |
none | none | Multiply a 16-bit number by nine | NZCV | 62 | 36 |
M16BY10 |
none | none | Multiply a 16-bit number by ten | NZCV | 66 | 39 |
M16BY1H |
none | none | Multiply a 16-bit number by one hundred | NZCV | 124 | 70 |
MAC.MATH8.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
ADD8 |
none | ]1 = number to add ]2 = number to add |
Add two 8-bit numbers | NZCV | 21 | 15 |
SUB8 |
none | ]1 = Minuend ]2 = Subtrahend |
Subtract one 8-bit number from another | NZCV | 21 | 15 |
MUL8 |
MULTU8 |
]1 = Multiplicand ]2 = Multiplier |
Multiply two 8-bit numbers | NZCV | 97 | 56 |
DIV8 |
DIVDU8 |
]1 = Dividend ]2 = Divisor |
Divide one 8-bit number by another | NZCV | 75 | 43 |
MAC.MATH16.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
ADD16 |
ADDIT16 |
]1 = First number to add ]2 = Second number to add |
Add two 16-bit numbers | NZCV | 78 | 51 |
SUB16 |
SUBT16 |
]1 = Minuend ]2 = Subtrahend |
Subtract one 16-bit number from another | NZCV | 79 | 51 |
MUL16 |
MULTU16 |
]1 = Multiplier ]2 = Multiplicand |
Multiply two 16-bit numbers | NZCV | 144 | 91 |
DIV16 |
DIVDU16 |
]1 = Dividend ]2 = Divisor |
Divide one 16-bit number by another | NZCV | 133 | 81 |
CMP16 |
COMP16 |
]1 = First Comparison Number ]2 = Second Comparison Number |
Compare one 16-bit number to another | NZCV | 100 | 53 |
MAC.MATHRND.ASM
MACRO | DEPENDENCY | PARAMETERS | ACTION | DESTROYS | CYCLES | BYTES |
---|---|---|---|---|---|---|
RNDEOR |
none | ]1 = Seed ]2 = EOR Index |
Set the seed and magic number value | NZCV | 30 | 22 |
RNDMZ |
none | ]1 = Seed ]2 = EOR Magic Number |
Set the seed and set the magic number index | NZCV | 56 | 35 |
RND8 |
RAND8 |
none | Generate a value between 0 and 255 | NZCV | 51 | 30 |
RAND |
RANDB |
]1 = Low bounds ]2 = High bounds |
Generate a value between a given low value and high value | NZCV | 263 | 171 |
RND16 |
RAND16 |
none | Generate a value between 0 and 65,355 | NZCV | 101 | 63 |