Division / modulo special optimizations

Division / modulo special optimizations

Language reference ›› Constants ››
Parent Previous Next

One thing that is frustrating / not optimal in standard Pascal is the need to perform two divides to extract the quotient and the remainder of an integer fraction (one DIV and one MOD). 

In PMP, the remainder of the last divide operation may be available through a read only pseudo-variable if not optimized out. It is up to you to store it somewhere before the next divide operation:


MOD8

Last BYTE divide modulo. MOD8 also returns the LSB of the last WORD, INTEGER or LONGINT / LONGWORD divide

MOD16

Last WORD (unsigned 16-bit) divide modulo. MOD16 also returns the LSW of the last LONGINT / LONGWORD divide.

MOD16S

Last INTEGER (signed 16-bit) divide modulo. MOD16S also returns the LSW of the last LONGINT / LONGWORD divide.

MOD32

Last LONGWORD (unsigned 32-bit) divide modulo.

MOD32S

Last LONGINT (signed 32-bit) divide modulo.