I used a lookup table for the first math formula I posted and again a great idea. Amazing how simple things work so much better than complicated ones.

This is my first shot using the FP routines and I am trying to sort out an overflow problem. First off, I have MSP 3.0.0.5, compilier PBP 2.60L and an 18F4620 PIC.

Maybe I am interpreting the readme file in the FP.zip file incorrectly. The way I understand it is when using the FP1832L.BAS file I can use numbers larger than 65535. If that is correct I have something wrong with the code below because when the result of a fpmul routine is larger than 65535 the numbers start again at zero.

Code:
define osc 20
Include "modedefs.bas"	' Mode definitions for Serout
include "fp1832l.bas"   ' Include file for 18xxxx (32-bit, PBPL.EXE)

Prefix          con      $FE             ' needed before each command
LcdCls          CON      $51             ' clear LCD (use PAUSE 5 after)
LcdLine1        CON      $00             ' move cursor to line 1
LcdLine2        con      $40             ' move curson to line 2
LcdLine3        con      $14             ' move curson to line 3
lcdLine4        con      $54             ' move curson to line 4
LcdCol1         con      $00             ' move cursor to column 1
LcdCol2         con      $07             ' move cursor to column 7
LcdCR           CON      $0D             ' move pos 0 of next line 
LcdOn           CON      $41             ' LCD on; cursor off, blink off 
LcdHome         con      $46
Backlight       con      $53             ' Backlighting 1-8
Contrast        con      $52             ' Contrast 1-50
CursorPS        con      $45             'Cursor Position
CursorOn        con      $47             'Cursof On
CursorOff       con      $48             'Cursor Off
BackSpace       CON      $4E             'Backspace 
UnderlineOn     con      $47  
UnderlineOff    con     $48

LCD             VAR      PortC.6         'LCD output

Inlet           var      word
RH              Var      word
RH1             var      Word            'Used for math purposes
Baro            var      word
Baro1           var      word            'Used for math purposes
Temp            var      word
Temp2           var      word            'Used for math purposes
CurPos          var      word
SAP             var      word            'Saturation Pressure
AVP             var      word            'Actual Vapor Pressure
DAVP            var      word            'Dry Ait Vapor Pressure
WAVP            var      word            'Wet Air Vapor Pressure
DAD             var      word            'Dry Air Density
WVD             var      word            'Water Vapor Density
WAD             var      word            'Wet Air Density


Serout2 LCD, 84, [Prefix,LcdCLS]
Temp = 500
Temp2 = (Temp/10)-50
Lookup2 Temp2,[1227,1274,1322,1371,1422,1475,1530,1586,1644,1704,1766,1830,1896,1964,2034,2107, _
               2181,2258,2337,2419,2503,2590,2679,2771,2866,2963,3064,3167,3273,3383,3496,3612, _
               3731,3854,3980,4110,4243,4380,4522,4667,4816,4969,5126,5288,5454,5625,5800,5980, _
               6165,6355,6550,6750,6955,7166,7383,7605,7833,8066,8306,8553],SAP 

RH = 600
RH1 = RH/10
aint = RH1
Gosub itofa     ' Convert int to float
bint = SAP
Gosub itofb     ' Convert int to float
Gosub fpmul 
Gosub ftoia
AVP = aint      'AVP = ((RH)*SAP)          
          'RH1   SAP    AVP(code)    AVP(real)      
'Results  600    1227   8084         73620
         '500    1227   61350        61350

Serout LCD, T9600,[Prefix,CursorPS,0,#RH1, " ", #SAP, " ", #AVP]
stop