dividing 24 bit constant


Closed Thread
Results 1 to 9 of 9
  1. #1
    kasapo's Avatar
    kasapo Guest

    Question dividing 24 bit constant

    hi,

    how can i divide 24 or 32 bit constant value.

    for example
    hword= 0032
    Lword=69cc

    dividerW=0150

    result ?

  2. #2
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    DIV32 does exactly that, it's in your manual.

  3. #3
    kasapo's Avatar
    kasapo Guest


    Did you find this post helpful? Yes | No

    Default

    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 ?

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Thumbs down

    No !!!

    Mel has already given the solution here, in this forum !!!

    Alain from Mel's fan club ...

  5. #5
    kasapo's Avatar
    kasapo Guest


    Did you find this post helpful? Yes | No

    Smile

    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

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    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
    Last edited by Acetronics2; - 10th February 2005 at 12:03.

  7. #7
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Last edited by Dwayne; - 10th February 2005 at 14:41.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Unhappy

    Just one thing ...

    It worked pretty well on a 16F84, but NOT Well on a 16F628 ...

    a paging problem somewhere ???

    Alain

  9. #9
    kasapo's Avatar
    kasapo Guest


    Did you find this post helpful? Yes | No

    Unhappy

    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 ?

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  3. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 10:31
  4. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts