Floating Point Display Problem (serial string out)


Closed Thread
Results 1 to 1 of 1
  1. #1
    Cash Olsen's Avatar
    Cash Olsen Guest

    Default Floating Point Display Problem (serial string out)

    While using the 4FUNC32.BAS routine I discovered that it did not display negative numbers correctly. The 4FUNCTN .BAS program does not seem to have the same problems.

    The errors consist of two catigories: 1) incomplete initialization and 2) improper truncation from 24 bit to 16 bit value.

    The floating point sign is tested (aargb0.7) and the minus sign is printed if the number is negative.

    IF aargb0.7 THEN ' Check the floating point sign bit
    HSEROUT ["-"]
    ASM
    bsf PCLATH, 3
    ; Gosub fpsub
    call FPS32 ; AARG = AARG - BARG
    bcf PCLATH, 3
    ENDASM
    ELSE
    ASM
    bsf PCLATH, 3
    ; Gosub fpadd
    call FPA32 ; AARG = AARG + BARG
    bcf PCLATH, 3
    ENDASM
    ENDIF


    When the routine:

    call INT3224 ; 32-bit float to 24-bit int

    is executed the floating point number is converted to a 24 bit integer, even though only the least significant 16 bits are used in the variable - ahold - the variable will only be valid if the sign is accounted for, in effect the absolute value of the variable calculated.


    IF (AARGB0.7) THEN
    ahold = (ahold ^ $FFFF ) + 1
    ENDIF


    The routine FLO2432 converts a 24 bit integer to a 32 bit floating point value, but the variable - aint - is a 16 bit word.

    AARGB0 = 0
    ASM
    bsf PCLATH, 3
    ; GOSUB itofa ' Convert integer back to float
    call FLO2432 ; 24-bit int to 32-bit float
    bcf PCLATH, 3
    ENDASM

    The assembly language is because I loaded the floating point routines in the second page of memory, ie. ORG $800
    Attached Files Attached Files

Similar Threads

  1. Replies: 2
    Last Post: - 14th July 2008, 22:11
  2. Replies: 14
    Last Post: - 26th September 2007, 05:41
  3. need help on display problem
    By sixty9sandals in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 30th March 2007, 03:57
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  5. 7-segment display blinking problem?
    By serdar_ozcan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2006, 14:43

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