C code ???? Yuck!
And you're still missing Henrik's point. The Float goes in AARG (starting at AARGB2) not Aint which starts at AARGB3.
Code:
;----[Variables]----------------------------------------------------------------
A VAR LONG
B VAR LONG
A_Float VAR LONG EXT : @A_Float = AARGB2 ;
B_Float VAR LONG EXT : @B_Float = BARGB2 ;
;----[macro Converts IEEE to Microchip FP format]-------------------------------
ASM
IEEEtoMCHIP?NN macro Nin, Nout
MOVE?BB Nin, Nout
MOVE?BB Nin+1, Nout+1
MOVE?BB Nin+2, Nout+2
MOVE?TT Nin+3,7, Nin+2,7
MOVE?BA Nin+3
RLNCF WREG,W
MOVE?AB Nout+3
MOVE?TT Nin+2,7, Nout+3,0
endm
ENDASM
;----[Test IEEE to Microchip conversion]---------------------------------------
A = $42480000 ; 50 - IEEE
GOSUB ShowConversion
A = $C1CCF5C3 ; -25.62 - IEEE
GOSUB ShowConversion
STOP
;----[Show conversion via HSEROUT]---------------------------------------------
ShowConversion:
HSEROUT ["IEEE = ",HEX8 A,13,10]
@ IEEEtoMCHIP?NN _A, _B
HSEROUT ["Mchip= ",HEX8 B,13,10]
A_Float = B
GOSUB FtoIA
HSEROUT ["Aint = ",SDEC Aint,13,10]
A = Aint
A_Float = B ; with 1 decimal place
Bint = 10
GOSUB ItoFB
GOSUB fpmul
GOSUB FtoIA
HSEROUT [" ",SDEC Aint/10,".",DEC1 ABS(Aint),13,10]
A_Float = B ; with 2 decimal places
Bint = 100
GOSUB ItoFB
GOSUB fpmul
GOSUB FtoIA
HSEROUT [" ",SDEC Aint/100,".",DEC2 ABS(Aint),13,10,13,10]
RETURN
Bookmarks