PowTen db 0x92,0x74,0x24,0x00 ;Floating point representation of 1000000 db 0x8F,0x43,0x50,0x00 ;100000 db 0x8C,0x1C,0x40,0x00 ;10000 db 0x88,0x7A,0x00,0x00 ;1000 db 0x85,0x48,0x00,0x00 ;100 db 0x82,0x20,0x00,0x00 ;10 db 0x7F,0x00,0x00,0x00 ;1 db 0x7b,0x4c,0xcc,0xcd ;0.1 ; Figure 14-8 PowTen table. ;;;;;;; Normalize subroutine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; This subroutine normalizes AARG to a floating point representation of its ; decimal equivalent with the decimal point moved to the right of a seven-digit ; number (i.e., a decimal number between 1,000,000 and 9,999,999). It is ; assumed that the decimal equivalent of the actual number is less than ; 9,999,999 and more than 0.1000000. ; The location of the actual decimal point is returned in TMP0 with TMP0=0 ; representing a number with no digits to the left of the decimal point. ; For example, if AARG is initially the floating point representation of ; 12.34567, then this subroutine will return with AARG holding the floating ; point representation of 1234567 and with TMP0 =2. Normalize MOVLF high PowTen, TBLPTRH ;Point to first table entry MOVLF low PowTen, TBLPTRL MOVLF 8,TMP0 ;Initialize return parameter ;REPEAT_ L1 decf TMP0,F TBLRD*+ movff TABLAT,BEXP ;First move table entry to BARG TBLRD*+ movff TABLAT,BARGB0 TBLRD*+ movff TABLAT,BARGB1 TBLRD*+ movff TABLAT,BARGB2 movf AARGB2,W ;Subtract AARG from power of ten subwf BARGB2,W movf AARGB1,W subwfb BARGB1,W movf AARGB0,W subwfb BARGB0,W movf AEXP,W subwfb BEXP,W ;UNTIL_ .NC. ;Continue until AARG is larger than power of ten bc L1 RL1 ;Form TBLPTR = PowTen + 4(TMP0) MOVLF upper PowTen, TBLPTRU MOVLF high PowTen, TBLPTRH MOVLF low PowTen, TBLPTRL decf TMP0,W bcf STATUS,C rlcf WREG,F rlcf WREG,F addwf TBLPTRL,F clrf WREG addwfc TBLPTRH,F addwfc TBLPTRU,F ;Now retrieve this power of ten to BARG TBLRD*+ movff TABLAT,BEXP TBLRD*+ movff TABLAT,BARGB0 TBLRD*+ movff TABLAT,BARGB1 TBLRD*+ movff TABLAT,BARGB2 rcall FPM32 ;Multiply AARG by this power of ten ; to get a value greater than 1,000,000 call INT3224 ; and convert it to a three-byte integer return ; Figure 14-9 Normalize subroutine.