> Hello all:
>
> I haven't been messing around with pics for a while....but just
> picked it back up again a couple of weeks ago and forgot how much fun it
> was.
> Now, onto the plea for help....
>
> I admit...I've ALWAYS been scared of floating point routines, but
> the time has come where I MUST use them....the Microchip routines scare
> me worse than any of them....but maybe I'm just being stupid and
> ignorant of binary math...in any case...I've found these routines which
> look good to me and I think I can use. What I'm trying to do is
> multiply the 10-bit A/D value that I obtained from my F876 by
> 0.0048828125 to get the resultant voltage...the only thing I don't know
> how to do is get the A/D value (an integer) into floating point
> notation, actually, I guess I don't know how to get the 0.0048828 value
> into floating point notation either, but that's just a constant...how
> would I convert an integer to a float? the float routines that I'm
> using use two 16-bit arguments with an 8-bit mantissa and an extra sign
> byte (which I don't know what does yet) here's one of the routines (some
> call statements may be missing...I just gave a snippit):
>
> ;*******************************************************************
> ; Binary Floating Point Multiplication :
> ; ACCb(16 bits)EXP(b) * ACCa(16 bits)EXPa -> ACCb(16 bits)EXPb
>
> F_mpy: call S_SIGN
> call setup
> mloop: bcf STATUS,C ; clear carry bit ??????????
> rrf ACCdHI,F ;rotate d right
> rrf ACCdLO,F
> btfsc STATUS,C ;need to add?
> call D_add
> rrf ACCbHI,F
> rrf ACCbLO,F
> rrf ACCcHI,F
> rrf ACCcLO,F
> decfsz temp, F ;loop until all bits checked
> goto mloop
>
> movf EXPa,W
> addwf EXPb, F
>
> IF Mode16
> movf ACCbHI, F
> btfss STATUS,Z
> goto finup ; if ACCbHI != 0
> movf ACCbLO, F
> btfss STATUS,Z
> goto Shft08 ; if ACCbLO != 0 && ACCbHI == 0
>
> movf ACCcHI,W
> movwf ACCbHI ; if ACCb == 0, then move ACCc to ACCb
> movf ACCcLO,W
> movwf ACCbLO
> movlw .16
> addwf EXPb, F
> goto finup
>
> Shft08: movf ACCbLO,W
> movwf ACCbHI
> movf ACCcHI,W
> movwf ACCbLO
> movlw .8
> addwf EXPb,F
>
> ENDIF ; matching endif for IF Mode16
>
> finup: btfss sign,MSB
> goto F_norm
>
> decf ACCcLO,F ; negate ACCc
> comf ACCcLO,F
> btfsc STATUS,Z
> decf ACCcHI,F
> comf ACCcHI,F
> btfsc STATUS,Z
>
> neg_B: decf ACCbLO,F ; negate ACCb
> comf ACCbLO,F
> btfsc STATUS,Z
> decf ACCbHI,F
> comf ACCbHI,F
>
> goto F_norm
>
> thanks for your time!
>
> --
>
http://www.piclist.com hint: PICList Posts must start with ONE topic:
> [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads