Display 2 WORDs as a 32bit integer


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Display 2 WORDs as a 32bit integer

    Richard,
    Just wanted to thank you once again, the code is now incorporated in my project and I can display my two 32bit variables nicely.
    I hardcoded the divisor to 100k and got rid of the Divisor variable. It grew the codebase by 230bytes and 34bytes of RAM out of which 11 is an array to which I write the result
    Code:
    DWORDtoString:
        CALL DivBy100k
    
        ' QUOTL top word, Remainder low word.
        ' Get Remainder into PBP system variables in preparation for DIV32
        ASM
            MOVE?BB   Remainder, R2
            MOVE?BB   Remainder + 1 , R2 + 1
            MOVE?BB   Remainder + 2, R0
            MOVE?CB   0, R0 + 1
            RST?RP
        ENDASM
    
        Result = DIV32 10000
        Remains = R2
        
        IF QUOTL THEN
            ARRAYWRITE DWordString, [DEC QUOTL, DEC Result, DEC4 Remains, 0]
        ELSEIF Result THEN
            ARRAYWRITE DWordString, [DEC Result, DEC4 Remains, 0]
        ELSE
            ARRAYWRITE DWordString, [DEC Remains, 0]
        ENDIF

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Display 2 WORDs as a 32bit integer

    Is it possible to describe the method or algorithm to get the decimal from the possible 8 hexadecimal of 32 bit number.... the conversion itself is pretty straight forward but the 8 bit manipulations are confusing...
    .
    .Name:  hex.JPG
Views: 796
Size:  53.3 KB

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,698


    Did you find this post helpful? Yes | No

    Default Re: Display 2 WORDs as a 32bit integer

    Just wanted to thank you once again

    No problem
    Henrik glad you could make it work for you. its good to exercise the grey matter occasionally



    @amgen
    the conversion itself is pretty straight forward but the 8 bit manipulations are confusing...
    to which 8bit manipulations do you refer ?
    Warning I'm not a teacher

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    971


    Did you find this post helpful? Yes | No

    Default Re: Display 2 WORDs as a 32bit integer

    Quote Originally Posted by amgen View Post
    Is it possible to describe the method or algorithm to get the decimal from the possible 8 hexadecimal of 32 bit number.... the conversion itself is pretty straight forward but the 8 bit manipulations are confusing...
    .
    .Attachment 9870

    Consider this code.

    Code:
    dim array[8] as byte                        ' your hex bytes ($00-$0F) are input here from MSN to LSNibble
    decimal  as long                             ' 32 bit value
    
         decimal = 0
         for i = 0 to 7
               decimal = decimal * 16             ' nibble max value is 16, so multiply the existing value by 16 to move decimal value one nibble to the left
               decimal = decimal + array[i]     ' add in the new nibble
         next
         
         ' at this point, decimal contains the converted value of the hex digits
    Is this what you're looking for?

Similar Threads

  1. Microchip 32bit floating point to integer conversion
    By timmers in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st February 2011, 17:49
  2. IEEE 754 32bit floating point value.
    By shawn in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th December 2010, 13:32
  3. Signed 32bit to ASCII?
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th May 2010, 23:13
  4. Retrieving 32bit Multiply Result
    By Darrel Taylor in forum Code Examples
    Replies: 42
    Last Post: - 28th January 2008, 16:15
  5. Newbee How to get LCD to display 4-6 var words
    By emmett brown in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th August 2006, 02:11

Members who have read this thread : 5

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