Here's an easy way to get the remainder or Modulus result after a Div32 statement.
This result is not directly available thru PBP commands, but is contained in PBP system var R2.
To retrieve it only takes 1 line and a place to put the word value.
The variable Remainder now contains the Modulus of the Div32Code:Remainder Var Word @ MOVE?WW R2, _Remainder ; Get remainder of Div32
Here's an example
And this is the output via HyperTerminalCode:Define LOADER_USED 1 ' SetUp Hardware USART DEFINE HSER_TXSTA 24h DEFINE HSER_SPBRG 25 ' 9600 Baud @ 4mhz Result Var Word Remainder Var Word DivideBy Var Word hserout ["Value = 1,000,000",13,10] hserout ["DivideBy = ", Dec DivideBy,13,10] DivideBy = 55 Result = 1000 Result = Result * Result ' create 1,000,000 for Div32 Result = Div32 DivideBy @ MOVE?WW R2, _Remainder ; Get remainder of Div32 hserout ["Result = ", dec Result,13,10] hserout ["Remainder = ", dec Remainder,13,10] ' Change remainder to Decimals Remainder = Remainder * 10000 ' Multiply remainder * 10,000 Remainder = div32 DivideBy ' Divide remainder by original divisor ' Display result with 4 decimal places Hserout ["Decimal = ", Dec Result,".",dec4 Remainder,13,10,10] stop
HTH,Code:Value = 1,000,000 DivideBy = 55 Result = 18181 Remainder = 45 Decimal = 18181.8181
Darrel Taylor




Bookmarks