Retrieving 32bit Multiply Result


Results 1 to 40 of 43

Threaded View

  1. #34


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel,

    Sorry for the delay. I had some hardware problems which I had to fix.
    Also I’m using a USB to serial interface to communicate with HT and every now and then Windows will see my device as a mouse.
    Here is what I have so far:
    I am able to count down and send out the big_number. I made few changes to your code to format the output as a 8 digit number (kept the leading zeros).
    I’m also receiving the big_number as two 4 digit decimal numbers.
    The only thing left is to make one big_number from the two word size variable (in_high and in_low).
    I was thinking to use your PutMultResult?D macro Din but I’m not quite sure how to do it.
    Here is the latest working code:

    INCLUDE "modedefs.bas"
    @ device pic16F876a,hs_osc,pwrt_on, protect_on
    DEFINE OSC 16
    DEFINE LOADER_USED 1
    DEFIne HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 4800
    define HSER_CLROERR 1

    HighDigits VAR WORD
    LowDigits VAR WORD
    big_number VAR WORD[2] ; 32-bit variable
    in_low var word
    in_high var word
    led var PORTA.2

    ADCON1=6
    CMCON=7

    ASM
    MOVE?CN macro Cin, Nout
    MOVE?CW Cin & 0xFFFF, Nout ; Low Word
    MOVE?CW (Cin >> 16), Nout + 2 ; High Word
    endm
    ENDASM
    ASM
    PutMulResult?N macro Nin
    MOVE?WW Nin, R2
    MOVE?WW Nin + 2, R0
    endm
    ENDASM
    pause 10000 ' Allow for the USB device to enumerate
    hserout [13,10,"Waiting for Big_number",13,10] ' Add time out later
    hserin [dec4 in_high,dec4 in_low]
    main:
    @ MOVE?CN 20000, _big_number
    WHILE (big_number[1] > 0) OR (big_number[0] > 0)
    big_number[0] = big_number[0] - 1
    IF big_number[0] = $ffff THEN big_number[1] = big_number[1] - 1
    @ PutMulResult?N _big_number
    GOSUB SendBigNum
    toggle led ' Show if any action
    WEND
    pause 5000
    goto main
    SendBigNum:
    HighDigits = DIV32 10000
    LowDigits = R2
    'IF (HighDigits > 0) THEN
    HSEROUT [DEC4 HighDigits, DEC4 LowDigits," and ",dec4 in_high,dec4 in_low,13,10]
    'ELSE
    'HSEROUT [DEC4 LowDigits,13,10]
    'ENDIF
    RETURN

    End

    Thanks again for your patience.

    Nick

    BTW: I'm practising to post code the right way.
    Last edited by Nicmus; - 26th January 2008 at 17:02. Reason: Posting code practice

Similar Threads

  1. Strugling without floating point
    By pjsmith in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th March 2011, 07:29
  2. Math help please!!!
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th August 2007, 15:45
  3. 32-bit Variables and DIV32, Hourmeter 99999.9
    By Darrel Taylor in forum Code Examples
    Replies: 9
    Last Post: - 23rd November 2006, 08:23
  4. PBP 16-bit ADC result math
    By sonic in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 13th March 2005, 15:21
  5. Retrieving Div32 Remainder
    By Darrel Taylor in forum Code Examples
    Replies: 4
    Last Post: - 20th August 2003, 04:53

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