Display 2 WORDs as a 32bit integer


Results 1 to 14 of 14

Threaded View

  1. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,645


    Did you find this post helpful? Yes | No

    Default Re: Display 2 WORDs as a 32bit integer

    maybe something like this old gem

    Code:
    Hours     VAR WORD[2]    ; 32-bit (Dword) Holds up to 99999.9 hoursHoursH    VAR Hours(1)
    HoursL    Var Hours(0)
    
    
    Result    Var Word
    Remainder Var Word
    
    
    ;----[Load a 32-bit (Dword) variable into PBP registers, Prior to DIV32]--------
    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
    
    
    ;====[Simple loop to test the HourMeter]========================================
    MainLoop:
        gosub AddHourTenth
        Gosub ShowHourMeter
    goto MainLoop    ;============================================================
    
    
    
    
    ;----[Add 1 tenth of an hour to the hourmeter]----------------------------------
    AddHourTenth:
        HoursL = HoursL + 1
        IF HoursL = 0 then HoursH = HoursH + 1
        if (HoursH = $F) and (HoursL = $4240) then   ; Roll over at 1,000,000
            HoursH = 0                               ;            99999.9 + .1
            HoursL = 0
        endif
    return
    
    
    ;----[Display hourmeter using LCDOUT]-------------------------------------------
    ShowHourMeter:
    @   PutMulResult?D  _Hours
        Result = DIV32 1000
        Remainder = R2
        LCDOUT $FE, 2            ; Home Cursor
        IF Result > 0 then
            LCDOUT Dec Result, DEC2 Remainder/10,".",DEC1 Remainder//10
        else
            LCDOUT DEC Remainder/10,".",DEC1 Remainder//10
        endif   
    return



    the other way is n-bit math
    like post #23 here
    Last edited by richard; - 30th November 2024 at 22:42.
    Warning I'm not a teacher

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, 16:49
  2. IEEE 754 32bit floating point value.
    By shawn in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th December 2010, 12:32
  3. Signed 32bit to ASCII?
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th May 2010, 22:13
  4. Retrieving 32bit Multiply Result
    By Darrel Taylor in forum Code Examples
    Replies: 42
    Last Post: - 28th January 2008, 15: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, 01:11

Members who have read this thread : 18

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