View Full Version : dividing 24 bit constant
kasapo
- 10th February 2005, 08:37
hi,
how can i divide 24 or 32 bit constant value.
for example
hword= 0032
Lword=69cc
dividerW=0150
result ?
Ingvar
- 10th February 2005, 08:51
DIV32 does exactly that, it's in your manual.
kasapo
- 10th February 2005, 09:39
i know div32 do it.
but i don't know how use it.
as far as i read i cannot assign a constant to div32
div32 = 0032 69CC
the only way is getting the constant value by multiplying by two words then divide it.
constant = x*y
result = div32 z
am i right ?
Acetronics2
- 10th February 2005, 10:34
No !!!
Mel has already given the solution here, in this forum !!!
Alain from Mel's fan club ...
kasapo
- 10th February 2005, 11:29
hi again,
acetronics can you tell me how can i do that or what is the subject of the threat that my question's answer is given.
i search but i cannot find
Acetronics2
- 10th February 2005, 12:01
Hi, kasapo
Here it is :
'************************************************* *****************************
'MACRO 32 bits
'************************************************* *****************************
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
and when needed :
@ putmulresult 60000000 or else ...
Vitesse = DIV32 dureetot
Vitesse = Vitesse / coeff
or sth ...looking like that !!!
I do not find anymore the thread nor ....
Alain
Dwayne
- 10th February 2005, 14:39
Hello Kaspo,
Here is a link:
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=24&highlight=DIV32
and
http://www.picbasic.co.uk/forum/showthread.php?s=&threadid=184&highlight=DIV32
Dwayne
Acetronics2
- 10th February 2005, 15:58
Just one thing ...
It worked pretty well on a 16F84, but NOT Well on a 16F628 ...
a paging problem somewhere ???
Alain
kasapo
- 27th February 2005, 22:35
thanks for your help.
in my application sometimes result is greater than 16 bit . so i can not get the expected result. i get FFFF
for example
@ putmulresult 2236920 or else ...
resultw = DIV32 xxxx
if xxx smaller than 35 resultw is greater than 16 bit.
how can i solve this problem ?
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.