Helper macros
Get absolute value of a signed 8-bits integer
Get absolute value of a signed 16-bits integer
Get absolute value of a signed 32-bits integer
Invert sign of a signed integer
Merge two 4 bits value into a 8 bits integer
Merge two 8 bits value into a 16 bits integer
Get the power-of-2 modulo of a integer (ie. "MOD_POW2(100, 32)")
Clamp a 8-bits value into a interval
Clamp a 16-bits value into a interval
Find highest value
Find lowest value
Quick math routines
| i8 Math_Div10( |
| ) __FASTCALL __PRESERVES(a, b, c, iyl, iyh) |
8-bits fast 10 times division
| val i8 | Value to divide by 10 |
val / 10
| i16 Math_Div10_16b( |
| ) __FASTCALL __PRESERVES(b, d, e, iyl, iyh) |
16-bits fast 10 times division
| val i16 | Value to divide by 10 |
val / 10
| u8 Math_Mod10( |
| ) __PRESERVES(b, c, d, e, iyl, iyh) |
8-bits fast modulo-10
| val u8 | Value to module by 10 |
val % 10
| u8 Math_Mod10_16b( |
| ) __FASTCALL __PRESERVES(b, c, d, e, iyl, iyh) |
16-bits fast modulo-10
| val u16 | Value to module by 10 |
val % 10
| u8 Math_Flip( |
| ) __PRESERVES(c, d, e, h, l, iyl, iyh) |
Bits flip routine
| val u8 | Value to flip |
Bits flipped value
| u16 Math_Flip_16b( |
| ) __PRESERVES(c, iyl, iyh) |
Bits flip routine
| val u16 | Value to flip |
Bits flipped value
| inline i8 Math_Negative( |
| ) |
Get the negative (additive inverse) of a 8-bit register
| i16 Math_Negative16( |
| ) __FASTCALL __PRESERVES(b, c, d, e, iyl, iyh) |
Get the negative (additive inverse) of a 16-bit register
| u16 Math_Swap( |
| ) __PRESERVES(a, b, c, iyl, iyh) |
Swap MSB and LSB bytes
| i8 Math_SignedDiv2( |
| ) __naked __PRESERVES(b, c, d, e, h, l, iyl, iyh) |
Divide a signed 8-bits integer by 2 using shift
| i8 Math_SignedDiv4( |
| ) __naked __PRESERVES(b, c, d, e, h, l, iyl, iyh) |
Divide a signed 8-bits integer by 4 using shift
| i8 Math_SignedDiv8( |
| ) __naked __PRESERVES(b, c, d, e, h, l, iyl, iyh) |
Divide a signed 8-bits integer by 8 using shift
| i8 Math_SignedDiv16( |
| ) __naked __PRESERVES(b, c, d, e, h, l, iyl, iyh) |
Divide a signed 8-bits integer by 16 using shift
| i8 Math_SignedDiv32( |
| ) __naked __PRESERVES(b, c, d, e, h, l, iyl, iyh) |
Divide a signed 8-bits integer by 32 using shift
| inline u8 Math_Abs( |
| ) |
Get absolute value of a signed 8-bits integer
| inline u16 Math_Abs_16b( |
| ) |
Get absolute value of a signed 16-bits integer
| inline u32 Math_Abs_32b( |
| ) |
Get absolute value of a signed 32-bits integer
Random routines
| void Math_SetRandomSeed8( |
| ) |
Initialize random generator seed
| seed u8 | Initial seed value for the generator |
Generates 8-bit pseudorandom numbers
A pseudorandom value between 0 and 255. (Maximum value is 127 for RANDOM_8_REGISTER and RANDOM_8_RACC methods)
| inline u8 Math_GetRandomMax8( |
| ) |
Generates 8-bit pseudorandom numbers between 0 and max-1 value.
| max u8 | Maximum value of the pseudorandom number (not included in the range). |
A pseudorandom value between 0 and max-1.
| inline u8 Math_GetRandomRange8( |
| ) |
Generates 8-bit pseudorandom numbers between min and max-1 value.
| min u8 | Minimum value of the pseudorandom number. |
| max u8 | Maximum value of the pseudorandom number (not included in the range). |
A pseudorandom value between min and max-1.
| void Math_SetRandomSeed16( |
| ) |
Initialize random generator seed
| seed u16 | Initial seed value for the generator |
Generates 16-bit pseudorandom numbers
A pseudorandom value between 0 and 65535.
| inline u16 Math_GetRandomMax16( |
| ) |
Generates 16-bit pseudorandom numbers between 0 and max-1 value.
| max u16 | Maximum value of the pseudorandom number (not included in the range). |
A pseudorandom value between 0 and max-1.
| inline u16 Math_GetRandomRange16( |
| ) |
Generates 16-bit pseudorandom numbers between min and max-1 value.
| min u16 | Minimum value of the pseudorandom number. |
| max u16 | Maximum value of the pseudorandom number (not included in the range). |
A pseudorandom value between min and max-1.