And here's the other side of the coin.
Suppose you want to put a 32 bit number in the PBP system vars where it can be used by DIV32.
But you don't want to have to multiply two numbers together to get it.
This allows you to enter a constant, up to 2,147,483,648 which can then be used by DIV32.
Code:
W1 var word
ASM
PutMulResult macro Const32
MOVE?CB low Const32, R2
MOVE?CB low (Const32 >> 8), R2 + 1
MOVE?CB low (Const32 >> 16), R0
MOVE?CB low (Const32 >> 24), R0 + 1
endm
ENDASM
@ PutMulResult 1000000 ; Load PBP internal vars - Max= 2,147,483,648
W1 = DIV32 300 ; Divide 1000000/300
' W1 will now contain 3333
@ PutMulResult 10562010
W1 = DiV32 1000 ; Divide 10562010/1000
' W1 is now 10562
-OR-
If the number is contained in a 2 word variable. You can load the "MUL result" like this...
Code:
Asm
PutMulResult?D macro Din
MOVE?BB Din, R2
MOVE?BB Din + 1 , R2 + 1
MOVE?BB Din + 2, R0
MOVE?BB Din + 3, R0 + 1
RST?RP
endm
EndAsm
DWord VAR WORD[2] ; holds a 31-bit value
@ PutMulResult?D _DWord ; Load PBP internal vars - Max= 2,147,483,648
W1 = DIV32 10000 ; 31-bit value / 10,000
The possibilties, are endless
HTH,
Darrel Taylor
Bookmarks