--- C:\Program Files\HI-TECH Software\PICC\9.80\sources\altoft.c ------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: 11: // Convert signed int to float 12: 13: #ifdef _OLDLIB 14: #define f1_as_mant1 (*(unsigned short long *)&f1) 15: float 16: __altoft(signed long int c) 17: { 18: float f1; 19: unsigned char exp, sign; 20: 21: if(c == 0) 22: return 0.0; 23: sign = 0; 24: if(c < 0) { 25: c = -c; 26: sign = 1; 27: } 28: exp = 127+15; 29: // normalize 32 bits to 24 first 30: while(c & ~0xFFFFFFUL) { 31: *(unsigned long int *)&c >>= 1; 32: exp++; 33: } 34: f1_as_mant1 = c; 35: __ftpack(&f1_as_mant1, exp); 36: if(sign) 37: f1 = -f1; 38: return f1; 39: } 40: #else 41: float 42: __altoft(signed long int c) 43: { 44: unsigned char exp, sign; 45: sign = 0; DC3 1003 BCF 0x3, 0 DC4 3000 MOVLW 0 DC5 1803 BTFSC 0x3, 0 DC6 3001 MOVLW 0x1 DC7 1283 BCF 0x3, 0x5 DC8 1303 BCF 0x3, 0x6 DC9 00A7 MOVWF 0x27 46: exp = 127+15; DCA 308E MOVLW 0x8e DCB 00A4 MOVWF 0x24 DCC 0824 MOVF 0x24, W DCD 00A6 MOVWF 0x26 47: if (c < 0) { DCE 1FA3 BTFSS 0x23, 0x7 DCF 2DD1 GOTO 0x5d1 DD0 2DD2 GOTO 0x5d2 DD1 2DF0 GOTO 0x5f0 48: c = -c; DD2 09A0 COMF 0x20, F DD3 09A1 COMF 0x21, F DD4 09A2 COMF 0x22, F DD5 09A3 COMF 0x23, F DD6 0AA0 INCF 0x20, F DD7 1903 BTFSC 0x3, 0x2 DD8 0AA1 INCF 0x21, F DD9 1903 BTFSC 0x3, 0x2 DDA 0AA2 INCF 0x22, F DDB 1903 BTFSC 0x3, 0x2 DDC 0AA3 INCF 0x23, F 49: sign = 1; DDD 01A7 CLRF 0x27 DDE 1403 BSF 0x3, 0 DDF 0DA7 RLF 0x27, F DE0 2DF0 GOTO 0x5f0 50: } 51: // normalize 32 bits to 24 first 52: while(c & ~0xFFFFFFUL) { DE1 2DF0 GOTO 0x5f0 DF0 30FF MOVLW 0xff DF1 0523 ANDWF 0x23, W DF2 1D03 BTFSS 0x3, 0x2 DF3 2DF5 GOTO 0x5f5 DF4 2DF6 GOTO 0x5f6 DF5 2DE2 GOTO 0x5e2 DF6 2DF7 GOTO 0x5f7 53: *(unsigned long int *)&c >>= 1; DE2 3001 MOVLW 0x1 DE3 1003 BCF 0x3, 0 DE4 0CA3 RRF 0x23, F DE5 0CA2 RRF 0x22, F DE6 0CA1 RRF 0x21, F DE7 0CA0 RRF 0x20, F DE8 3EFF ADDLW 0xff DE9 1D03 BTFSS 0x3, 0x2 DEA 2DE3 GOTO 0x5e3 54: exp++; DEB 3001 MOVLW 0x1 DEC 00A4 MOVWF 0x24 DED 0824 MOVF 0x24, W DEE 07A6 ADDWF 0x26, F DEF 2DF0 GOTO 0x5f0 55: } 56: return __ftpack((unsigned short long)c, exp, sign); DF7 0820 MOVF 0x20, W DF8 00F0 MOVWF 0x70 DF9 0821 MOVF 0x21, W DFA 00F1 MOVWF 0x71 DFB 0822 MOVF 0x22, W DFC 00F2 MOVWF 0x72 DFD 0826 MOVF 0x26, W DFE 00A4 MOVWF 0x24 DFF 0824 MOVF 0x24, W E00 00F3 MOVWF 0x73 E01 0827 MOVF 0x27, W E02 00A5 MOVWF 0x25 E03 0825 MOVF 0x25, W E04 00F4 MOVWF 0x74 E05 158A BSF 0xa, 0x3 E06 26E9 CALL 0x6e9 E07 158A BSF 0xa, 0x3 E08 0870 MOVF 0x70, W E09 1283 BCF 0x3, 0x5 E0A 1303 BCF 0x3, 0x6 E0B 00A0 MOVWF 0x20 E0C 0871 MOVF 0x71, W E0D 00A1 MOVWF 0x21 E0E 0872 MOVF 0x72, W E0F 00A2 MOVWF 0x22 E10 2E11 GOTO 0x611 57: } E11 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\awtoft.c ------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: 11: // Convert signed int to float 12: 13: #ifdef _OLDLIB 14: #define f1_as_mant1 (*(unsigned short long *)&f1) 15: float 16: __awtoft(signed int c) 17: { 18: float f1; 19: 20: if(c == 0) 21: return 0.0; 22: f1_as_mant1 = (signed short long)c; 23: if(c < 0) 24: f1_as_mant1 = -f1_as_mant1; 25: __ftpack(&f1_as_mant1, 127+15); 26: if(c < 0) 27: f1 = -f1; 28: return f1; 29: } 30: #else 31: float 32: __awtoft(signed int c) 33: { 34: unsigned char sign; 35: 36: sign = 0; D1B 1003 BCF 0x3, 0 D1C 3000 MOVLW 0 D1D 1803 BTFSC 0x3, 0 D1E 3001 MOVLW 0x1 D1F 00FD MOVWF 0x7d 37: if (c < 0) { D20 1FF9 BTFSS 0x79, 0x7 D21 2D23 GOTO 0x523 D22 2D24 GOTO 0x524 D23 2D2D GOTO 0x52d 38: c = -c; D24 09F8 COMF 0x78, F D25 09F9 COMF 0x79, F D26 0AF8 INCF 0x78, F D27 1903 BTFSC 0x3, 0x2 D28 0AF9 INCF 0x79, F 39: sign = 1; D29 01FD CLRF 0x7d D2A 1403 BSF 0x3, 0 D2B 0DFD RLF 0x7d, F D2C 2D2D GOTO 0x52d 40: } 41: return __ftpack((unsigned int)c, 127+15, sign); D2D 0878 MOVF 0x78, W D2E 00F0 MOVWF 0x70 D2F 0879 MOVF 0x79, W D30 00F1 MOVWF 0x71 D31 01F2 CLRF 0x72 D32 308E MOVLW 0x8e D33 00FB MOVWF 0x7b D34 087B MOVF 0x7b, W D35 00F3 MOVWF 0x73 D36 087D MOVF 0x7d, W D37 00FC MOVWF 0x7c D38 087C MOVF 0x7c, W D39 00F4 MOVWF 0x74 D3A 158A BSF 0xa, 0x3 D3B 26E9 CALL 0x6e9 D3C 158A BSF 0xa, 0x3 D3D 0870 MOVF 0x70, W D3E 00F8 MOVWF 0x78 D3F 0871 MOVF 0x71, W D40 00F9 MOVWF 0x79 D41 0872 MOVF 0x72, W D42 00FA MOVWF 0x7a D43 2D44 GOTO 0x544 42: } D44 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\bmul.c --------------------------------- 1: unsigned char 2: __bmul(unsigned char multiplier, unsigned char multiplicand) 3: { CE1 00F3 MOVWF 0x73 4: unsigned char product = 0; CE2 1003 BCF 0x3, 0 CE3 3000 MOVLW 0 CE4 1803 BTFSC 0x3, 0 CE5 3001 MOVLW 0x1 CE6 00F2 MOVWF 0x72 CE7 2CE8 GOTO 0x4e8 5: 6: do { 7: if(multiplier & 1) CE8 1C73 BTFSS 0x73, 0 CE9 2CEB GOTO 0x4eb CEA 2CEC GOTO 0x4ec CEB 2CF1 GOTO 0x4f1 8: product += multiplicand; CEC 0870 MOVF 0x70, W CED 00F1 MOVWF 0x71 CEE 0871 MOVF 0x71, W CEF 07F2 ADDWF 0x72, F CF0 2CF1 GOTO 0x4f1 9: multiplicand <<= 1; CF1 1003 BCF 0x3, 0 CF2 0DF0 RLF 0x70, F 10: multiplier >>= 1; CF3 1003 BCF 0x3, 0 CF4 0CF3 RRF 0x73, F 11: } while(multiplier != 0); CF5 08F3 MOVF 0x73, F CF6 1D03 BTFSS 0x3, 0x2 CF7 2CF9 GOTO 0x4f9 CF8 2CFA GOTO 0x4fa CF9 2CE8 GOTO 0x4e8 CFA 2CFB GOTO 0x4fb 12: return product; CFB 0872 MOVF 0x72, W CFC 2CFD GOTO 0x4fd 13: } CFD 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\evalpoly.c ----------------------------- 1: #include 2: 3: double 4: eval_poly(double x, const double * d, int n) 5: { 6: double res; 7: 8: res = d[n]; E12 3003 MOVLW 0x3 E13 1283 BCF 0x3, 0x5 E14 1303 BCF 0x3, 0x6 E15 00CD MOVWF 0x4d E16 084D MOVF 0x4d, W E17 00F0 MOVWF 0x70 E18 084B MOVF 0x4b, W E19 158A BSF 0xa, 0x3 E1A 24E1 CALL 0x4e1 E1B 158A BSF 0xa, 0x3 E1C 1283 BCF 0x3, 0x5 E1D 1303 BCF 0x3, 0x6 E1E 074A ADDWF 0x4a, W E1F 0084 MOVWF 0x4 E20 158A BSF 0xa, 0x3 E21 2000 CALL 0 E22 158A BSF 0xa, 0x3 E23 00CE MOVWF 0x4e E24 158A BSF 0xa, 0x3 E25 2000 CALL 0 E26 158A BSF 0xa, 0x3 E27 00CF MOVWF 0x4f E28 158A BSF 0xa, 0x3 E29 2000 CALL 0 E2A 158A BSF 0xa, 0x3 E2B 00D0 MOVWF 0x50 9: while(n) E2C 2E6E GOTO 0x66e E6E 084C MOVF 0x4c, W E6F 044B IORWF 0x4b, W E70 1D03 BTFSS 0x3, 0x2 E71 2E73 GOTO 0x673 E72 2E74 GOTO 0x674 E73 2E2D GOTO 0x62d E74 2E75 GOTO 0x675 10: res = x * res + d[--n]; E2D 3003 MOVLW 0x3 E2E 00CD MOVWF 0x4d E2F 084D MOVF 0x4d, W E30 00F0 MOVWF 0x70 E31 30FF MOVLW 0xff E32 07CB ADDWF 0x4b, F E33 1803 BTFSC 0x3, 0 E34 0ACC INCF 0x4c, F E35 30FF MOVLW 0xff E36 07CC ADDWF 0x4c, F E37 084B MOVF 0x4b, W E38 158A BSF 0xa, 0x3 E39 24E1 CALL 0x4e1 E3A 158A BSF 0xa, 0x3 E3B 1283 BCF 0x3, 0x5 E3C 1303 BCF 0x3, 0x6 E3D 074A ADDWF 0x4a, W E3E 0084 MOVWF 0x4 E3F 158A BSF 0xa, 0x3 E40 2000 CALL 0 E41 158A BSF 0xa, 0x3 E42 00B0 MOVWF 0x30 E43 158A BSF 0xa, 0x3 E44 2000 CALL 0 E45 158A BSF 0xa, 0x3 E46 00B1 MOVWF 0x31 E47 158A BSF 0xa, 0x3 E48 2000 CALL 0 E49 158A BSF 0xa, 0x3 E4A 00B2 MOVWF 0x32 E4B 084E MOVF 0x4e, W E4C 00A0 MOVWF 0x20 E4D 084F MOVF 0x4f, W E4E 00A1 MOVWF 0x21 E4F 0850 MOVF 0x50, W E50 00A2 MOVWF 0x22 E51 0847 MOVF 0x47, W E52 00A3 MOVWF 0x23 E53 0848 MOVF 0x48, W E54 00A4 MOVWF 0x24 E55 0849 MOVF 0x49, W E56 00A5 MOVWF 0x25 E57 118A BCF 0xa, 0x3 E58 2384 CALL 0x384 E59 158A BSF 0xa, 0x3 E5A 1283 BCF 0x3, 0x5 E5B 1303 BCF 0x3, 0x6 E5C 0820 MOVF 0x20, W E5D 00B3 MOVWF 0x33 E5E 0821 MOVF 0x21, W E5F 00B4 MOVWF 0x34 E60 0822 MOVF 0x22, W E61 00B5 MOVWF 0x35 E62 118A BCF 0xa, 0x3 E63 2567 CALL 0x567 E64 158A BSF 0xa, 0x3 E65 1283 BCF 0x3, 0x5 E66 1303 BCF 0x3, 0x6 E67 0830 MOVF 0x30, W E68 00CE MOVWF 0x4e E69 0831 MOVF 0x31, W E6A 00CF MOVWF 0x4f E6B 0832 MOVF 0x32, W E6C 00D0 MOVWF 0x50 E6D 2E6E GOTO 0x66e 11: return res; E75 084E MOVF 0x4e, W E76 00C7 MOVWF 0x47 E77 084F MOVF 0x4f, W E78 00C8 MOVWF 0x48 E79 0850 MOVF 0x50, W E7A 00C9 MOVWF 0x49 E7B 2E7C GOTO 0x67c 12: } E7C 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\exp.c ---------------------------------- 1: #include 2: #include 3: #include 4: 5: #if sizeof(double)<=4 6: #define EXP_MAX 7.09782712893383973096e+02 7: #define EXP_MIN -7.45133219101941108420e+02 8: #endif 9: 10: 11: double 12: exp(double x) 13: { 14: int exp; 15: char sign; 16: 17: const static double coeff[] = 806 3400 RETLW 0 807 3480 RETLW 0x80 808 343F RETLW 0x3f 809 3472 RETLW 0x72 80A 3431 RETLW 0x31 80B 343F RETLW 0x3f 80C 34FE RETLW 0xfe 80D 3475 RETLW 0x75 80E 343E RETLW 0x3e 80F 3458 RETLW 0x58 810 3463 RETLW 0x63 811 343D RETLW 0x3d 812 3495 RETLW 0x95 813 341D RETLW 0x1d 814 343C RETLW 0x3c 815 34C5 RETLW 0xc5 816 34AE RETLW 0xae 817 343A RETLW 0x3a 818 3479 RETLW 0x79 819 3421 RETLW 0x21 81A 3439 RETLW 0x39 81B 3494 RETLW 0x94 81C 3480 RETLW 0x80 81D 3437 RETLW 0x37 81E 3493 RETLW 0x93 81F 34A7 RETLW 0xa7 820 3435 RETLW 0x35 821 3456 RETLW 0x56 822 3415 RETLW 0x15 823 3434 RETLW 0x34 18: { 19: 1.0000000000e+00, 20: 6.9314718056e-01, 21: 2.4022650695e-01, 22: 5.5504108945e-02, 23: 9.6181261779e-03, 24: 1.3333710529e-03, 25: 1.5399104432e-04, 26: 1.5327675257e-05, 27: 1.2485143336e-06, 28: 1.3908092221e-07, 29: }; 30: 31: if(x == 0.0) 6AF 1283 BCF 0x3, 0x5 6B0 1303 BCF 0x3, 0x6 6B1 0859 MOVF 0x59, W 6B2 0458 IORWF 0x58, W 6B3 0457 IORWF 0x57, W 6B4 1D03 BTFSS 0x3, 0x2 6B5 2EB7 GOTO 0x6b7 6B6 2EB8 GOTO 0x6b8 6B7 2EC0 GOTO 0x6c0 32: return 1.0; 6B8 3000 MOVLW 0 6B9 00D7 MOVWF 0x57 6BA 3080 MOVLW 0x80 6BB 00D8 MOVWF 0x58 6BC 303F MOVLW 0x3f 6BD 00D9 MOVWF 0x59 6BE 2FFF GOTO 0x7ff 6BF 2FFF GOTO 0x7ff 33: #if sizeof(double)<=4 34: if (x > EXP_MAX) { //too big? 6C0 3072 MOVLW 0x72 6C1 00F0 MOVWF 0x70 6C2 3031 MOVLW 0x31 6C3 00F1 MOVWF 0x71 6C4 3044 MOVLW 0x44 6C5 00F2 MOVWF 0x72 6C6 0857 MOVF 0x57, W 6C7 00F3 MOVWF 0x73 6C8 0858 MOVF 0x58, W 6C9 00F4 MOVWF 0x74 6CA 0859 MOVF 0x59, W 6CB 00F5 MOVWF 0x75 6CC 158A BSF 0xa, 0x3 6CD 267D CALL 0x67d 6CE 118A BCF 0xa, 0x3 6CF 1803 BTFSC 0x3, 0 6D0 2ED2 GOTO 0x6d2 6D1 2ED3 GOTO 0x6d3 6D2 2EED GOTO 0x6ed 35: errno = ERANGE; 6D3 3022 MOVLW 0x22 6D4 1683 BSF 0x3, 0x5 6D5 1303 BCF 0x3, 0x6 6D6 00BE MOVWF 0x3e 6D7 3000 MOVLW 0 6D8 00BF MOVWF 0x3f 36: return DBL_MAX; 6D9 2EE3 GOTO 0x6e3 6DA 3000 MOVLW 0 6DB 1283 BCF 0x3, 0x5 6DC 1303 BCF 0x3, 0x6 6DD 00D7 MOVWF 0x57 6DE 3080 MOVLW 0x80 6DF 00D8 MOVWF 0x58 6E0 307F MOVLW 0x7f 6E1 00D9 MOVWF 0x59 6E2 2FFF GOTO 0x7ff 6E3 30FF MOVLW 0xff 6E4 1283 BCF 0x3, 0x5 6E5 00D7 MOVWF 0x57 6E6 307F MOVLW 0x7f 6E7 00D8 MOVWF 0x58 6E8 307F MOVLW 0x7f 6E9 00D9 MOVWF 0x59 6EA 2FFF GOTO 0x7ff 6EB 2FFF GOTO 0x7ff 6EC 2FFF GOTO 0x7ff 37: } 38: if (x < EXP_MIN) { //too small? 6ED 1283 BCF 0x3, 0x5 6EE 1303 BCF 0x3, 0x6 6EF 0857 MOVF 0x57, W 6F0 00F0 MOVWF 0x70 6F1 0858 MOVF 0x58, W 6F2 00F1 MOVWF 0x71 6F3 0859 MOVF 0x59, W 6F4 00F2 MOVWF 0x72 6F5 3049 MOVLW 0x49 6F6 00F3 MOVWF 0x73 6F7 303A MOVLW 0x3a 6F8 00F4 MOVWF 0x74 6F9 30C4 MOVLW 0xc4 6FA 00F5 MOVWF 0x75 6FB 158A BSF 0xa, 0x3 6FC 267D CALL 0x67d 6FD 118A BCF 0xa, 0x3 6FE 1803 BTFSC 0x3, 0 6FF 2F01 GOTO 0x701 700 2F02 GOTO 0x702 701 2F12 GOTO 0x712 39: errno = ERANGE; 702 3022 MOVLW 0x22 703 1683 BSF 0x3, 0x5 704 1303 BCF 0x3, 0x6 705 00BE MOVWF 0x3e 706 3000 MOVLW 0 707 00BF MOVWF 0x3f 40: return 0.0; 708 3000 MOVLW 0 709 1283 BCF 0x3, 0x5 70A 1303 BCF 0x3, 0x6 70B 00D7 MOVWF 0x57 70C 3000 MOVLW 0 70D 00D8 MOVWF 0x58 70E 3000 MOVLW 0 70F 00D9 MOVWF 0x59 710 2FFF GOTO 0x7ff 711 2FFF GOTO 0x7ff 41: } 42: #endif 43: sign = x < 0.0; 712 1283 BCF 0x3, 0x5 713 1303 BCF 0x3, 0x6 714 0857 MOVF 0x57, W 715 00F0 MOVWF 0x70 716 0858 MOVF 0x58, W 717 00F1 MOVWF 0x71 718 0859 MOVF 0x59, W 719 00F2 MOVWF 0x72 71A 3000 MOVLW 0 71B 00F3 MOVWF 0x73 71C 3000 MOVLW 0 71D 00F4 MOVWF 0x74 71E 3000 MOVLW 0 71F 00F5 MOVWF 0x75 720 158A BSF 0xa, 0x3 721 267D CALL 0x67d 722 118A BCF 0xa, 0x3 723 3000 MOVLW 0 724 1C03 BTFSS 0x3, 0 725 3001 MOVLW 0x1 726 1283 BCF 0x3, 0x5 727 1303 BCF 0x3, 0x6 728 00DA MOVWF 0x5a 729 085A MOVF 0x5a, W 72A 00E0 MOVWF 0x60 44: if(sign) 72B 0860 MOVF 0x60, W 72C 1D03 BTFSS 0x3, 0x2 72D 2F2F GOTO 0x72f 72E 2F41 GOTO 0x741 45: x = -x; 72F 0857 MOVF 0x57, W 730 00F0 MOVWF 0x70 731 0858 MOVF 0x58, W 732 00F1 MOVWF 0x71 733 0859 MOVF 0x59, W 734 00F2 MOVWF 0x72 735 158A BSF 0xa, 0x3 736 24D5 CALL 0x4d5 737 118A BCF 0xa, 0x3 738 0870 MOVF 0x70, W 739 1283 BCF 0x3, 0x5 73A 1303 BCF 0x3, 0x6 73B 00D7 MOVWF 0x57 73C 0871 MOVF 0x71, W 73D 00D8 MOVWF 0x58 73E 0872 MOVF 0x72, W 73F 00D9 MOVWF 0x59 740 2F41 GOTO 0x741 46: x *= 1.4426950409; /* convert to log2 */ 741 30AA MOVLW 0xaa 742 00A0 MOVWF 0x20 743 30B8 MOVLW 0xb8 744 00A1 MOVWF 0x21 745 303F MOVLW 0x3f 746 00A2 MOVWF 0x22 747 0857 MOVF 0x57, W 748 00A3 MOVWF 0x23 749 0858 MOVF 0x58, W 74A 00A4 MOVWF 0x24 74B 0859 MOVF 0x59, W 74C 00A5 MOVWF 0x25 74D 118A BCF 0xa, 0x3 74E 2384 CALL 0x384 74F 118A BCF 0xa, 0x3 750 1283 BCF 0x3, 0x5 751 1303 BCF 0x3, 0x6 752 0820 MOVF 0x20, W 753 00D7 MOVWF 0x57 754 0821 MOVF 0x21, W 755 00D8 MOVWF 0x58 756 0822 MOVF 0x22, W 757 00D9 MOVWF 0x59 47: exp = (int)floor(x); 758 0857 MOVF 0x57, W 759 00BD MOVWF 0x3d 75A 0858 MOVF 0x58, W 75B 00BE MOVWF 0x3e 75C 0859 MOVF 0x59, W 75D 00BF MOVWF 0x3f 75E 158A BSF 0xa, 0x3 75F 2764 CALL 0x764 760 118A BCF 0xa, 0x3 761 1283 BCF 0x3, 0x5 762 1303 BCF 0x3, 0x6 763 083D MOVF 0x3d, W 764 00F0 MOVWF 0x70 765 083E MOVF 0x3e, W 766 00F1 MOVWF 0x71 767 083F MOVF 0x3f, W 768 00F2 MOVWF 0x72 769 118A BCF 0xa, 0x3 76A 2092 CALL 0x92 76B 118A BCF 0xa, 0x3 76C 0871 MOVF 0x71, W 76D 1283 BCF 0x3, 0x5 76E 1303 BCF 0x3, 0x6 76F 01DF CLRF 0x5f 770 07DF ADDWF 0x5f, F 771 0870 MOVF 0x70, W 772 01DE CLRF 0x5e 773 07DE ADDWF 0x5e, F 48: x -= (double)exp; 774 085F MOVF 0x5f, W 775 01F9 CLRF 0x79 776 07F9 ADDWF 0x79, F 777 085E MOVF 0x5e, W 778 01F8 CLRF 0x78 779 07F8 ADDWF 0x78, F 77A 158A BSF 0xa, 0x3 77B 251B CALL 0x51b 77C 118A BCF 0xa, 0x3 77D 0878 MOVF 0x78, W 77E 1283 BCF 0x3, 0x5 77F 1303 BCF 0x3, 0x6 780 00BD MOVWF 0x3d 781 0879 MOVF 0x79, W 782 00BE MOVWF 0x3e 783 087A MOVF 0x7a, W 784 00BF MOVWF 0x3f 785 0857 MOVF 0x57, W 786 00C0 MOVWF 0x40 787 0858 MOVF 0x58, W 788 00C1 MOVWF 0x41 789 0859 MOVF 0x59, W 78A 00C2 MOVWF 0x42 78B 158A BSF 0xa, 0x3 78C 24FE CALL 0x4fe 78D 118A BCF 0xa, 0x3 78E 1283 BCF 0x3, 0x5 78F 1303 BCF 0x3, 0x6 790 083D MOVF 0x3d, W 791 00D7 MOVWF 0x57 792 083E MOVF 0x3e, W 793 00D8 MOVWF 0x58 794 083F MOVF 0x3f, W 795 00D9 MOVWF 0x59 49: x = ldexp(eval_poly(x, coeff, sizeof coeff/sizeof coeff[0] - 1), exp); 796 0857 MOVF 0x57, W 797 00C7 MOVWF 0x47 798 0858 MOVF 0x58, W 799 00C8 MOVWF 0x48 79A 0859 MOVF 0x59, W 79B 00C9 MOVWF 0x49 79C 3001 MOVLW 0x1 79D 00DA MOVWF 0x5a 79E 085A MOVF 0x5a, W 79F 00CA MOVWF 0x4a 7A0 3009 MOVLW 0x9 7A1 00CB MOVWF 0x4b 7A2 3000 MOVLW 0 7A3 00CC MOVWF 0x4c 7A4 158A BSF 0xa, 0x3 7A5 2612 CALL 0x612 7A6 118A BCF 0xa, 0x3 7A7 1283 BCF 0x3, 0x5 7A8 1303 BCF 0x3, 0x6 7A9 0847 MOVF 0x47, W 7AA 00BD MOVWF 0x3d 7AB 0848 MOVF 0x48, W 7AC 00BE MOVWF 0x3e 7AD 0849 MOVF 0x49, W 7AE 00BF MOVWF 0x3f 7AF 085F MOVF 0x5f, W 7B0 01C1 CLRF 0x41 7B1 07C1 ADDWF 0x41, F 7B2 085E MOVF 0x5e, W 7B3 01C0 CLRF 0x40 7B4 07C0 ADDWF 0x40, F 7B5 118A BCF 0xa, 0x3 7B6 2136 CALL 0x136 7B7 118A BCF 0xa, 0x3 7B8 1283 BCF 0x3, 0x5 7B9 1303 BCF 0x3, 0x6 7BA 083D MOVF 0x3d, W 7BB 00D7 MOVWF 0x57 7BC 083E MOVF 0x3e, W 7BD 00D8 MOVWF 0x58 7BE 083F MOVF 0x3f, W 7BF 00D9 MOVWF 0x59 50: if(sign) 7C0 0860 MOVF 0x60, W 7C1 1D03 BTFSS 0x3, 0x2 7C2 2FC4 GOTO 0x7c4 7C3 2FFF GOTO 0x7ff 51: { 52: if (x == DBL_MAX) 7C4 3000 MOVLW 0 7C5 00DB MOVWF 0x5b 7C6 3080 MOVLW 0x80 7C7 00DC MOVWF 0x5c 7C8 307F MOVLW 0x7f 7C9 00DD MOVWF 0x5d 7CA 30FF MOVLW 0xff 7CB 00DB MOVWF 0x5b 7CC 307F MOVLW 0x7f 7CD 00DC MOVWF 0x5c 7CE 307F MOVLW 0x7f 7CF 00DD MOVWF 0x5d 7D0 0859 MOVF 0x59, W 7D1 065D XORWF 0x5d, W 7D2 1D03 BTFSS 0x3, 0x2 7D3 2FDA GOTO 0x7da 7D4 0858 MOVF 0x58, W 7D5 065C XORWF 0x5c, W 7D6 1D03 BTFSS 0x3, 0x2 7D7 2FDA GOTO 0x7da 7D8 0857 MOVF 0x57, W 7D9 065B XORWF 0x5b, W 7DA 1D03 BTFSS 0x3, 0x2 7DB 2FDD GOTO 0x7dd 7DC 2FDE GOTO 0x7de 7DD 2FE6 GOTO 0x7e6 53: return 0.0; 7DE 3000 MOVLW 0 7DF 00D7 MOVWF 0x57 7E0 3000 MOVLW 0 7E1 00D8 MOVWF 0x58 7E2 3000 MOVLW 0 7E3 00D9 MOVWF 0x59 7E4 2FFF GOTO 0x7ff 7E5 2FFF GOTO 0x7ff 54: return 1.0/x; 7E6 0857 MOVF 0x57, W 7E7 00F8 MOVWF 0x78 7E8 0858 MOVF 0x58, W 7E9 00F9 MOVWF 0x79 7EA 0859 MOVF 0x59, W 7EB 00FA MOVWF 0x7a 7EC 3000 MOVLW 0 7ED 00FB MOVWF 0x7b 7EE 3080 MOVLW 0x80 7EF 00FC MOVWF 0x7c 7F0 303F MOVLW 0x3f 7F1 00FD MOVWF 0x7d 7F2 118A BCF 0xa, 0x3 7F3 21F7 CALL 0x1f7 7F4 118A BCF 0xa, 0x3 7F5 0878 MOVF 0x78, W 7F6 1283 BCF 0x3, 0x5 7F7 1303 BCF 0x3, 0x6 7F8 00D7 MOVWF 0x57 7F9 0879 MOVF 0x79, W 7FA 00D8 MOVWF 0x58 7FB 087A MOVF 0x7a, W 7FC 00D9 MOVWF 0x59 7FD 2FFF GOTO 0x7ff 7FE 2FFF GOTO 0x7ff 55: } 56: return x; 57: } 7FF 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\float.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: #include "ftarith.h" 7: 8: 9: // unpack the operand pointed to. Store the exponent into the location pointed to by exp, 10: // and return the sign (zero is positive) 11: 12: #ifdef _OLDLIB 13: 14: unsigned char 15: __ftunpack(unsigned short long * arg, unsigned char * exp) 16: { 17: unsigned char sign; 18: 19: *exp = sign = *arg >> 15; 20: if(sign == 0) { 21: *arg = 0; 22: return 0; 23: } 24: sign = 0; 25: *arg |= 0x8000; 26: if(*arg & 0x800000) 27: sign++; 28: *arg &= 0xFFFF; 29: return sign; 30: } 31: 32: // normalize and pack the supplied argument into floating point format 33: 34: void 35: __ftpack(unsigned short long * arg, unsigned char exp) 36: { 37: if(exp == 0 || *arg == 0) { 38: *arg = 0; 39: return; 40: } 41: while(*arg & 0xFE0000UL) { 42: exp++; 43: *arg >>= 1; 44: } 45: while(*arg & 0xFF0000UL) { 46: exp++; 47: (*arg)++; 48: *arg >>= 1; 49: } 50: while(!(*arg & 0x8000UL)) { 51: exp--; 52: *arg <<= 1; 53: } 54: if(!(exp & 1)) 55: *arg &= ~0x8000L; 56: exp >>= 1; 57: *arg |= (unsigned short long)exp << 16; 58: } 59: 60: #else 61: float 62: __ftpack(unsigned short long arg, unsigned char exp, unsigned char sign) 63: { 64: if(exp == 0 || arg == 0) EE9 0873 MOVF 0x73, W EEA 1D03 BTFSS 0x3, 0x2 EEB 2EED GOTO 0x6ed EEC 2EF5 GOTO 0x6f5 EED 0872 MOVF 0x72, W EEE 0471 IORWF 0x71, W EEF 0470 IORWF 0x70, W EF0 1D03 BTFSS 0x3, 0x2 EF1 2EF3 GOTO 0x6f3 EF2 2EF4 GOTO 0x6f4 EF3 2F0B GOTO 0x70b EF4 2EF5 GOTO 0x6f5 65: return 0.0; EF5 3000 MOVLW 0 EF6 00F0 MOVWF 0x70 EF7 3000 MOVLW 0 EF8 00F1 MOVWF 0x71 EF9 3000 MOVLW 0 EFA 00F2 MOVWF 0x72 EFB 2F63 GOTO 0x763 EFC 2F63 GOTO 0x763 66: while(arg & 0xFE0000UL) { EFD 2F0B GOTO 0x70b F0B 30FE MOVLW 0xfe F0C 0572 ANDWF 0x72, W F0D 1D03 BTFSS 0x3, 0x2 F0E 2F10 GOTO 0x710 F0F 2F11 GOTO 0x711 F10 2EFE GOTO 0x6fe F11 2F29 GOTO 0x729 67: exp++; EFE 3001 MOVLW 0x1 EFF 00F5 MOVWF 0x75 F00 0875 MOVF 0x75, W F01 07F3 ADDWF 0x73, F 68: arg >>= 1; F02 3001 MOVLW 0x1 F03 1003 BCF 0x3, 0 F04 0CF2 RRF 0x72, F F05 0CF1 RRF 0x71, F F06 0CF0 RRF 0x70, F F07 3EFF ADDLW 0xff F08 1D03 BTFSS 0x3, 0x2 F09 2F03 GOTO 0x703 F0A 2F0B GOTO 0x70b 69: } 70: while(arg & 0xFF0000UL) { F12 2F29 GOTO 0x729 F29 30FF MOVLW 0xff F2A 0572 ANDWF 0x72, W F2B 1D03 BTFSS 0x3, 0x2 F2C 2F2E GOTO 0x72e F2D 2F2F GOTO 0x72f F2E 2F13 GOTO 0x713 F2F 2F3C GOTO 0x73c 71: exp++; F13 3001 MOVLW 0x1 F14 00F5 MOVWF 0x75 F15 0875 MOVF 0x75, W F16 07F3 ADDWF 0x73, F 72: (arg)++; F17 3001 MOVLW 0x1 F18 07F0 ADDWF 0x70, F F19 3000 MOVLW 0 F1A 1803 BTFSC 0x3, 0 F1B 3001 MOVLW 0x1 F1C 07F1 ADDWF 0x71, F F1D 3000 MOVLW 0 F1E 1803 BTFSC 0x3, 0 F1F 3001 MOVLW 0x1 F20 07F2 ADDWF 0x72, F 73: arg >>= 1; F21 3001 MOVLW 0x1 F22 1003 BCF 0x3, 0 F23 0CF2 RRF 0x72, F F24 0CF1 RRF 0x71, F F25 0CF0 RRF 0x70, F F26 3EFF ADDLW 0xff F27 1D03 BTFSS 0x3, 0x2 F28 2F22 GOTO 0x722 74: } 75: while(!(arg & 0x8000UL)) { F30 2F3C GOTO 0x73c F3C 1FF1 BTFSS 0x71, 0x7 F3D 2F3F GOTO 0x73f F3E 2F40 GOTO 0x740 F3F 2F31 GOTO 0x731 76: exp--; F31 3001 MOVLW 0x1 F32 02F3 SUBWF 0x73, F 77: arg <<= 1; F33 3001 MOVLW 0x1 F34 1003 BCF 0x3, 0 F35 0DF0 RLF 0x70, F F36 0DF1 RLF 0x71, F F37 0DF2 RLF 0x72, F F38 3EFF ADDLW 0xff F39 1D03 BTFSS 0x3, 0x2 F3A 2F34 GOTO 0x734 F3B 2F3C GOTO 0x73c 78: } 79: if(!(exp & 1)) F40 1873 BTFSC 0x73, 0 F41 2F43 GOTO 0x743 F42 2F44 GOTO 0x744 F43 2F4A GOTO 0x74a 80: arg &= ~0x8000L; F44 30FF MOVLW 0xff F45 05F0 ANDWF 0x70, F F46 307F MOVLW 0x7f F47 05F1 ANDWF 0x71, F F48 30FF MOVLW 0xff F49 05F2 ANDWF 0x72, F 81: exp >>= 1; F4A 1003 BCF 0x3, 0 F4B 0CF3 RRF 0x73, F 82: arg |= (unsigned short long)exp << 16; F4C 0873 MOVF 0x73, W F4D 00F5 MOVWF 0x75 F4E 01F6 CLRF 0x76 F4F 01F7 CLRF 0x77 F50 3010 MOVLW 0x10 F51 1003 BCF 0x3, 0 F52 0DF5 RLF 0x75, F F53 0DF6 RLF 0x76, F F54 0DF7 RLF 0x77, F F55 3EFF ADDLW 0xff F56 1D03 BTFSS 0x3, 0x2 F57 2F51 GOTO 0x751 F58 0875 MOVF 0x75, W F59 04F0 IORWF 0x70, F F5A 0876 MOVF 0x76, W F5B 04F1 IORWF 0x71, F F5C 0877 MOVF 0x77, W F5D 04F2 IORWF 0x72, F 83: if (sign) F5E 0874 MOVF 0x74, W F5F 1D03 BTFSS 0x3, 0x2 F60 2F62 GOTO 0x762 F61 2F63 GOTO 0x763 84: arg |= 0x800000UL; F62 17F2 BSF 0x72, 0x7 85: return *(float*)&arg; 86: } F63 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\floor.c -------------------------------- 1: #include 2: #include 3: #include 4: 5: #if sizeof(double) <= sizeof(long) 6: #define _frndint(x) ((double)(long)(x)) 7: #else 8: extern double _frndint(double); 9: #endif 10: 11: 12: double 13: floor(double x) 14: { 15: double i; 16: int expon; 17: 18: frexp(x, &expon); F64 1283 BCF 0x3, 0x5 F65 1303 BCF 0x3, 0x6 F66 083D MOVF 0x3d, W F67 00F0 MOVWF 0x70 F68 083E MOVF 0x3e, W F69 00F1 MOVWF 0x71 F6A 083F MOVF 0x3f, W F6B 00F2 MOVWF 0x72 F6C 3044 MOVLW 0x44 F6D 00C0 MOVWF 0x40 F6E 0840 MOVF 0x40, W F6F 00F3 MOVWF 0x73 F70 158A BSF 0xa, 0x3 F71 2579 CALL 0x579 F72 158A BSF 0xa, 0x3 19: if(expon < 0) { F73 1283 BCF 0x3, 0x5 F74 1303 BCF 0x3, 0x6 F75 1FC5 BTFSS 0x45, 0x7 F76 2F78 GOTO 0x778 F77 2F79 GOTO 0x779 F78 2FA0 GOTO 0x7a0 20: if(x < 0.0) F79 083D MOVF 0x3d, W F7A 00F0 MOVWF 0x70 F7B 083E MOVF 0x3e, W F7C 00F1 MOVWF 0x71 F7D 083F MOVF 0x3f, W F7E 00F2 MOVWF 0x72 F7F 3000 MOVLW 0 F80 00F3 MOVWF 0x73 F81 3000 MOVLW 0 F82 00F4 MOVWF 0x74 F83 3000 MOVLW 0 F84 00F5 MOVWF 0x75 F85 158A BSF 0xa, 0x3 F86 267D CALL 0x67d F87 158A BSF 0xa, 0x3 F88 1803 BTFSC 0x3, 0 F89 2F8B GOTO 0x78b F8A 2F8C GOTO 0x78c F8B 2F96 GOTO 0x796 21: return -1.0; F8C 3000 MOVLW 0 F8D 1283 BCF 0x3, 0x5 F8E 1303 BCF 0x3, 0x6 F8F 00BD MOVWF 0x3d F90 3080 MOVLW 0x80 F91 00BE MOVWF 0x3e F92 30BF MOVLW 0xbf F93 00BF MOVWF 0x3f F94 2FFF GOTO 0x7ff F95 2FFF GOTO 0x7ff 22: return 0.0; F96 3000 MOVLW 0 F97 1283 BCF 0x3, 0x5 F98 1303 BCF 0x3, 0x6 F99 00BD MOVWF 0x3d F9A 3000 MOVLW 0 F9B 00BE MOVWF 0x3e F9C 3000 MOVLW 0 F9D 00BF MOVWF 0x3f F9E 2FFF GOTO 0x7ff F9F 2FFF GOTO 0x7ff 23: } 24: if((unsigned)expon > sizeof(double) * CHAR_BIT - 4) FA0 3000 MOVLW 0 FA1 0245 SUBWF 0x45, W FA2 3015 MOVLW 0x15 FA3 1903 BTFSC 0x3, 0x2 FA4 0244 SUBWF 0x44, W FA5 1C03 BTFSS 0x3, 0 FA6 2FA8 GOTO 0x7a8 FA7 2FA9 GOTO 0x7a9 FA8 2FAA GOTO 0x7aa 25: return x; /* already an integer */ FA9 2FFF GOTO 0x7ff 26: i = _frndint(x); FAA 083D MOVF 0x3d, W FAB 00F0 MOVWF 0x70 FAC 083E MOVF 0x3e, W FAD 00F1 MOVWF 0x71 FAE 083F MOVF 0x3f, W FAF 00F2 MOVWF 0x72 FB0 118A BCF 0xa, 0x3 FB1 2092 CALL 0x92 FB2 158A BSF 0xa, 0x3 FB3 0873 MOVF 0x73, W FB4 1283 BCF 0x3, 0x5 FB5 1303 BCF 0x3, 0x6 FB6 00A3 MOVWF 0x23 FB7 0872 MOVF 0x72, W FB8 00A2 MOVWF 0x22 FB9 0871 MOVF 0x71, W FBA 00A1 MOVWF 0x21 FBB 0870 MOVF 0x70, W FBC 00A0 MOVWF 0x20 FBD 158A BSF 0xa, 0x3 FBE 25C3 CALL 0x5c3 FBF 158A BSF 0xa, 0x3 FC0 1283 BCF 0x3, 0x5 FC1 1303 BCF 0x3, 0x6 FC2 0820 MOVF 0x20, W FC3 00C1 MOVWF 0x41 FC4 0821 MOVF 0x21, W FC5 00C2 MOVWF 0x42 FC6 0822 MOVF 0x22, W FC7 00C3 MOVWF 0x43 27: if(i > x) FC8 083D MOVF 0x3d, W FC9 00F0 MOVWF 0x70 FCA 083E MOVF 0x3e, W FCB 00F1 MOVWF 0x71 FCC 083F MOVF 0x3f, W FCD 00F2 MOVWF 0x72 FCE 0841 MOVF 0x41, W FCF 00F3 MOVWF 0x73 FD0 0842 MOVF 0x42, W FD1 00F4 MOVWF 0x74 FD2 0843 MOVF 0x43, W FD3 00F5 MOVWF 0x75 FD4 158A BSF 0xa, 0x3 FD5 267D CALL 0x67d FD6 158A BSF 0xa, 0x3 FD7 1803 BTFSC 0x3, 0 FD8 2FDA GOTO 0x7da FD9 2FDB GOTO 0x7db FDA 2FF6 GOTO 0x7f6 28: return i - 1.0; FDB 3000 MOVLW 0 FDC 1283 BCF 0x3, 0x5 FDD 1303 BCF 0x3, 0x6 FDE 00B0 MOVWF 0x30 FDF 3080 MOVLW 0x80 FE0 00B1 MOVWF 0x31 FE1 30BF MOVLW 0xbf FE2 00B2 MOVWF 0x32 FE3 0841 MOVF 0x41, W FE4 00B3 MOVWF 0x33 FE5 0842 MOVF 0x42, W FE6 00B4 MOVWF 0x34 FE7 0843 MOVF 0x43, W FE8 00B5 MOVWF 0x35 FE9 118A BCF 0xa, 0x3 FEA 2567 CALL 0x567 FEB 158A BSF 0xa, 0x3 FEC 1283 BCF 0x3, 0x5 FED 1303 BCF 0x3, 0x6 FEE 0830 MOVF 0x30, W FEF 00BD MOVWF 0x3d FF0 0831 MOVF 0x31, W FF1 00BE MOVWF 0x3e FF2 0832 MOVF 0x32, W FF3 00BF MOVWF 0x3f FF4 2FFF GOTO 0x7ff FF5 2FFF GOTO 0x7ff 29: return i; FF6 1283 BCF 0x3, 0x5 FF7 1303 BCF 0x3, 0x6 FF8 0841 MOVF 0x41, W FF9 00BD MOVWF 0x3d FFA 0842 MOVF 0x42, W FFB 00BE MOVWF 0x3e FFC 0843 MOVF 0x43, W FFD 00BF MOVWF 0x3f FFE 2FFF GOTO 0x7ff 30: } FFF 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\frexp.c -------------------------------- 1: /* Frexp/ldexp in C */ 2: #include 3: #include 4: #include 5: 6: 7: /* PIC32 definition */ 8: #ifdef __PICC32__ 9: #if sizeof(double) == 4 10: #define EXCESS 126 11: #define MAX_EXPONENT 255 12: #define __STRUCT32 13: typedef union both 14: { 15: struct flt 16: { 17: unsigned mant:16; 18: unsigned hmant:7; 19: unsigned exp:8; 20: unsigned sign:1; 21: } flt; 22: double fl; 23: } both_t; 24: #endif /* end 32-bit floating point */ 25: 26: #endif // __PICC32__ 27: 28: /* ARM-C definition */ 29: #if defined(__ARMC__) 30: /* For 32-bit floating point */ 31: #if sizeof(double) == 4 32: #define EXCESS 126 33: #define MAX_EXPONENT 255 34: #define __STRUCT32 35: typedef union both 36: { 37: struct flt 38: { 39: unsigned sign:1; 40: unsigned exp:8; 41: unsigned hmant:7; 42: unsigned mant:16; 43: } flt; 44: double fl; 45: } both_t; 46: #endif /* end 32-bit floating point */ 47: #endif /* end ARM-C */ 48: 49: /* PICC-18 definition */ 50: #if defined(__PICC18__) || defined(__PICCPRO__) 51: /* For 32-bit floating point */ 52: #if sizeof(double) == 4 53: #define EXCESS 126 54: #define MAX_EXPONENT 255 55: #define __STRUCT32 56: typedef union both 57: { 58: struct flt 59: { 60: unsigned char mant[2]; 61: unsigned hmant:7; 62: unsigned lexp:1; 63: unsigned hexp:7; 64: unsigned sign:1; 65: } flt; 66: double fl; 67: } both_t; 68: #endif /* end 32-bit floating point */ 69: #if sizeof(double) == 3 70: #define EXCESS 126 71: #define MAX_EXPONENT 255 72: #define __STRUCT24 73: typedef union both 74: { 75: struct flt 76: { 77: unsigned char mant[1]; 78: unsigned hmant:7; 79: unsigned lexp:1; 80: unsigned hexp:7; 81: unsigned sign:1; 82: } flt; 83: double fl; 84: } both_t; 85: #endif /* end 24-bit floating point */ 86: #endif /* end PICC-18-C / PICC PRO */ 87: 88: /* dsPICC definition */ 89: #if defined(__DSPICC__) 90: /* For 32-bit floating point */ 91: #if sizeof(double) == 4 92: #define EXCESS 126 93: #define MAX_EXPONENT 255 94: #define __STRUCT32 95: typedef union both 96: { 97: struct flt 98: { 99: unsigned mant:16; 100: unsigned sign:1; 101: unsigned exp:8; 102: unsigned hmant:7; 103: } flt; 104: double fl; 105: } both_t; 106: #endif /* end 32-bit floating point */ 107: #endif /* end dsPICC */ 108: 109: /* PSOC definition */ 110: #if defined(_PSOC_) 111: /* For 32-bit floating point */ 112: #if sizeof(double) == 4 113: #define EXCESS 126 114: #define MAX_EXPONENT 255 115: #define __STRUCT32 116: typedef union both 117: { 118: struct flt 119: { 120: unsigned sign:1; 121: unsigned exp:8; 122: unsigned hmant:7; 123: unsigned char mant[2]; 124: } flt; 125: double fl; 126: } both_t; 127: #endif /* end 32-bit floating point */ 128: 129: #if sizeof(double) == 3 130: #define EXCESS 126 131: #define MAX_EXPONENT 255 132: #define __STRUCT24 133: typedef union both 134: { 135: struct flt 136: { 137: unsigned sign:1; 138: unsigned exp:8; 139: unsigned hmant:7; 140: unsigned char mant[1]; 141: } flt; 142: double fl; 143: } both_t; 144: #endif /* end 24-bit floating point */ 145: #endif /* end PSOC */ 146: 147: 148: /* MSP430 definition */ 149: #if defined(__MSP430C__) 150: /* For 32-bit floating point */ 151: #if sizeof(double) == 4 152: #define EXCESS 126 153: #define MAX_EXPONENT 255 154: #define __STRUCT32 155: typedef union both 156: { 157: struct flt 158: { 159: unsigned char mant[2]; 160: unsigned hmant:7; 161: unsigned exp:8; 162: unsigned sign:1; 163: } flt; 164: double fl; 165: } both_t; 166: #endif /* end 32-bit floating point */ 167: #endif /* end MSP430 */ 168: 169: /* Z80 definition */ 170: #if z80 171: #if sizeof(double) == 4 172: #define EXCESS 64 173: #define __STRUCT32 174: typedef union both 175: { 176: struct flt 177: { 178: unsigned char mant[2]; 179: unsigned hmant:8; 180: unsigned exp:7; 181: unsigned sign:1; 182: } flt; 183: double fl; 184: } both_t; 185: #endif 186: #endif /* end Z80 */ 187: 188: 189: #if sizeof(double) == 4 && !defined(__STRUCT32) 190: #warning Using generic 32-bit structure definition. A compiler-specific one should be defined 191: #define __STRUCT32 192: #if defined(_XA_) || defined(i8096) || defined(i8086) 193: #define LITTLE_ENDIAN 194: #endif 195: 196: typedef union both 197: { 198: struct flt 199: { 200: #define EXCESS 126 201: #define MAX_EXPONENT 255 202: #ifdef LITTLE_ENDIAN 203: unsigned char mant[2]; 204: unsigned hmant:7; 205: unsigned exp:8; 206: unsigned sign:1; 207: #else 208: unsigned sign:1; 209: unsigned exp:8; 210: unsigned hmant:7; 211: unsigned char mant[2]; 212: #endif 213: } flt; 214: double fl; 215: } both_t; 216: 217: #endif 218: 219: 220: #if sizeof(double) == 8 && !defined(__STRUCT64) 221: #warning Using generic 64-bit structure definition. A compiler-specific one should be defined 222: #define __STRUCT64 223: #if defined(_XA_) || defined(i8096) || defined(i8086) 224: #define LITTLE_ENDIAN 225: #endif 226: #define EXCESS 1022 227: #define MAX_EXPONENT 2047 228: typedef union both 229: { 230: struct flt 231: { 232: #ifdef LITTLE_ENDIAN 233: unsigned char mant[6]; 234: unsigned hmant:4; 235: unsigned exp:11; 236: unsigned sign:1; 237: #else 238: unsigned sign:1; 239: unsigned exp:11; 240: unsigned hmant:4; 241: unsigned char mant[6]; 242: #endif 243: } flt; 244: double fl; 245: } both_t; 246: #endif 247: 248: 249: #if !defined(__STRUCT32) && !defined(__STRUCT64) && !defined(__STRUCT24) 250: #error No floating point structure definition created for this compiler 251: #endif 252: 253: double 254: frexp(double value, int * eptr) 255: { 256: if (value == 0.0) { D79 0872 MOVF 0x72, W D7A 0471 IORWF 0x71, W D7B 0470 IORWF 0x70, W D7C 1D03 BTFSS 0x3, 0x2 D7D 2D7F GOTO 0x57f D7E 2D80 GOTO 0x580 D7F 2D90 GOTO 0x590 257: *eptr = 0; D80 0873 MOVF 0x73, W D81 0084 MOVWF 0x4 D82 3000 MOVLW 0 D83 1383 BCF 0x3, 0x7 D84 0080 MOVWF 0 D85 0A84 INCF 0x4, F D86 3000 MOVLW 0 D87 0080 MOVWF 0 258: return 0.0; D88 3000 MOVLW 0 D89 00F0 MOVWF 0x70 D8A 3000 MOVLW 0 D8B 00F1 MOVWF 0x71 D8C 3000 MOVLW 0 D8D 00F2 MOVWF 0x72 D8E 2DC2 GOTO 0x5c2 D8F 2DC2 GOTO 0x5c2 259: } 260: #if defined(__PICC18__) || defined(__PICCPRO__) 261: *eptr = ((both_t *)&value)->flt.hexp << 1; D90 0872 MOVF 0x72, W D91 397F ANDLW 0x7f D92 00F4 MOVWF 0x74 D93 01F5 CLRF 0x75 D94 3001 MOVLW 0x1 D95 00FF MOVWF 0x7f D96 1003 BCF 0x3, 0 D97 0DF4 RLF 0x74, F D98 0DF5 RLF 0x75, F D99 0BFF DECFSZ 0x7f, F D9A 2D96 GOTO 0x596 D9B 0873 MOVF 0x73, W D9C 0084 MOVWF 0x4 D9D 0874 MOVF 0x74, W D9E 1383 BCF 0x3, 0x7 D9F 0080 MOVWF 0 DA0 0A84 INCF 0x4, F DA1 0875 MOVF 0x75, W DA2 0080 MOVWF 0 262: *eptr |= ((both_t *)&value)->flt.lexp; DA3 0D71 RLF 0x71, W DA4 0D71 RLF 0x71, W DA5 3901 ANDLW 0x1 DA6 00F4 MOVWF 0x74 DA7 01F5 CLRF 0x75 DA8 0873 MOVF 0x73, W DA9 0084 MOVWF 0x4 DAA 0874 MOVF 0x74, W DAB 0480 IORWF 0, F DAC 0A84 INCF 0x4, F DAD 0875 MOVF 0x75, W DAE 0480 IORWF 0, F 263: *eptr -= EXCESS; DAF 0873 MOVF 0x73, W DB0 0084 MOVWF 0x4 DB1 3082 MOVLW 0x82 DB2 0780 ADDWF 0, F DB3 0F84 INCFSZ 0x4, F DB4 0800 MOVF 0, W DB5 1803 BTFSC 0x3, 0 DB6 0A00 INCF 0, W DB7 00FF MOVWF 0x7f DB8 30FF MOVLW 0xff DB9 077F ADDWF 0x7f, W DBA 0080 MOVWF 0 DBB 0384 DECF 0x4, F 264: #else 265: *eptr = ((both_t *)&value)->flt.exp - EXCESS; 266: #endif 267: #if defined(__PICC18__) || defined(__PICCPRO__) 268: ((both_t *)&value)->flt.hexp = EXCESS >> 1; DBC 0872 MOVF 0x72, W DBD 3980 ANDLW 0x80 DBE 383F IORLW 0x3f DBF 00F2 MOVWF 0x72 269: ((both_t *)&value)->flt.lexp = EXCESS & 0x01; DC0 13F1 BCF 0x71, 0x7 270: #else 271: ((both_t *)&value)->flt.exp = EXCESS; 272: #endif 273: return value; DC1 2DC2 GOTO 0x5c2 274: } DC2 0008 RETURN 275: 276: double 277: ldexp(double value, int newexp) 278: { 279: if (value == 0.0) 136 1283 BCF 0x3, 0x5 137 1303 BCF 0x3, 0x6 138 083F MOVF 0x3f, W 139 043E IORWF 0x3e, W 13A 043D IORWF 0x3d, W 13B 1D03 BTFSS 0x3, 0x2 13C 293E GOTO 0x13e 13D 293F GOTO 0x13f 13E 2947 GOTO 0x147 280: return 0.0; 13F 3000 MOVLW 0 140 00BD MOVWF 0x3d 141 3000 MOVLW 0 142 00BE MOVWF 0x3e 143 3000 MOVLW 0 144 00BF MOVWF 0x3f 145 29F6 GOTO 0x1f6 146 29F6 GOTO 0x1f6 281: #if defined(__PICC18__) || defined(__PICCPRO__) 282: newexp += ((both_t *)&value)->flt.hexp << 1; 147 083F MOVF 0x3f, W 148 397F ANDLW 0x7f 149 00C2 MOVWF 0x42 14A 01C3 CLRF 0x43 14B 3001 MOVLW 0x1 14C 00FF MOVWF 0x7f 14D 1003 BCF 0x3, 0 14E 0DC2 RLF 0x42, F 14F 0DC3 RLF 0x43, F 150 0BFF DECFSZ 0x7f, F 151 294D GOTO 0x14d 152 0842 MOVF 0x42, W 153 07C0 ADDWF 0x40, F 154 1803 BTFSC 0x3, 0 155 0AC1 INCF 0x41, F 156 0843 MOVF 0x43, W 157 07C1 ADDWF 0x41, F 283: newexp += ((both_t *)&value)->flt.lexp; 158 0D3E RLF 0x3e, W 159 0D3E RLF 0x3e, W 15A 3901 ANDLW 0x1 15B 00C2 MOVWF 0x42 15C 01C3 CLRF 0x43 15D 0842 MOVF 0x42, W 15E 07C0 ADDWF 0x40, F 15F 1803 BTFSC 0x3, 0 160 0AC1 INCF 0x41, F 161 0843 MOVF 0x43, W 162 07C1 ADDWF 0x41, F 284: #else 285: newexp += ((both_t *)&value)->flt.exp; 286: #endif 287: if (newexp < 0) { 163 1FC1 BTFSS 0x41, 0x7 164 2966 GOTO 0x166 165 2967 GOTO 0x167 166 2978 GOTO 0x178 288: errno = ERANGE; 167 3022 MOVLW 0x22 168 1683 BSF 0x3, 0x5 169 1303 BCF 0x3, 0x6 16A 00BE MOVWF 0x3e 16B 3000 MOVLW 0 16C 00BF MOVWF 0x3f 289: return 0.0; 16D 3000 MOVLW 0 16E 1283 BCF 0x3, 0x5 16F 1303 BCF 0x3, 0x6 170 00BD MOVWF 0x3d 171 3000 MOVLW 0 172 00BE MOVWF 0x3e 173 3000 MOVLW 0 174 00BF MOVWF 0x3f 175 29F6 GOTO 0x1f6 176 29F6 GOTO 0x1f6 290: } 177 29F5 GOTO 0x1f5 291: else if (newexp > MAX_EXPONENT) { 178 0841 MOVF 0x41, W 179 3A80 XORLW 0x80 17A 00FF MOVWF 0x7f 17B 3081 MOVLW 0x81 17C 027F SUBWF 0x7f, W 17D 1D03 BTFSS 0x3, 0x2 17E 2981 GOTO 0x181 17F 3000 MOVLW 0 180 0240 SUBWF 0x40, W 181 1C03 BTFSS 0x3, 0 182 2984 GOTO 0x184 183 2985 GOTO 0x185 184 29D7 GOTO 0x1d7 292: errno = ERANGE; 185 3022 MOVLW 0x22 186 1683 BSF 0x3, 0x5 187 1303 BCF 0x3, 0x6 188 00BE MOVWF 0x3e 189 3000 MOVLW 0 18A 00BF MOVWF 0x3f 293: if (value < 0.0) 18B 1283 BCF 0x3, 0x5 18C 1303 BCF 0x3, 0x6 18D 083D MOVF 0x3d, W 18E 00F0 MOVWF 0x70 18F 083E MOVF 0x3e, W 190 00F1 MOVWF 0x71 191 083F MOVF 0x3f, W 192 00F2 MOVWF 0x72 193 3000 MOVLW 0 194 00F3 MOVWF 0x73 195 3000 MOVLW 0 196 00F4 MOVWF 0x74 197 3000 MOVLW 0 198 00F5 MOVWF 0x75 199 158A BSF 0xa, 0x3 19A 267D CALL 0x67d 19B 118A BCF 0xa, 0x3 19C 1803 BTFSC 0x3, 0 19D 299F GOTO 0x19f 19E 29A0 GOTO 0x1a0 19F 29CB GOTO 0x1cb 294: return -DBL_MAX; 1A0 3000 MOVLW 0 1A1 1283 BCF 0x3, 0x5 1A2 1303 BCF 0x3, 0x6 1A3 00C4 MOVWF 0x44 1A4 3080 MOVLW 0x80 1A5 00C5 MOVWF 0x45 1A6 307F MOVLW 0x7f 1A7 00C6 MOVWF 0x46 1A8 30FF MOVLW 0xff 1A9 00C4 MOVWF 0x44 1AA 307F MOVLW 0x7f 1AB 00C5 MOVWF 0x45 1AC 307F MOVLW 0x7f 1AD 00C6 MOVWF 0x46 1AE 29AF GOTO 0x1af 1AF 0844 MOVF 0x44, W 1B0 00F0 MOVWF 0x70 1B1 0845 MOVF 0x45, W 1B2 00F1 MOVWF 0x71 1B3 0846 MOVF 0x46, W 1B4 00F2 MOVWF 0x72 1B5 158A BSF 0xa, 0x3 1B6 24D5 CALL 0x4d5 1B7 118A BCF 0xa, 0x3 1B8 0870 MOVF 0x70, W 1B9 1283 BCF 0x3, 0x5 1BA 1303 BCF 0x3, 0x6 1BB 00BD MOVWF 0x3d 1BC 0871 MOVF 0x71, W 1BD 00BE MOVWF 0x3e 1BE 0872 MOVF 0x72, W 1BF 00BF MOVWF 0x3f 1C0 29F6 GOTO 0x1f6 1C1 29F6 GOTO 0x1f6 1C2 29F5 GOTO 0x1f5 295: else 296: return DBL_MAX; 1C3 29CB GOTO 0x1cb 1C4 3000 MOVLW 0 1C5 00BD MOVWF 0x3d 1C6 3080 MOVLW 0x80 1C7 00BE MOVWF 0x3e 1C8 307F MOVLW 0x7f 1C9 00BF MOVWF 0x3f 1CA 29F6 GOTO 0x1f6 1CB 30FF MOVLW 0xff 1CC 1283 BCF 0x3, 0x5 1CD 1303 BCF 0x3, 0x6 1CE 00BD MOVWF 0x3d 1CF 307F MOVLW 0x7f 1D0 00BE MOVWF 0x3e 1D1 307F MOVLW 0x7f 1D2 00BF MOVWF 0x3f 1D3 29F6 GOTO 0x1f6 1D4 29F6 GOTO 0x1f6 1D5 29F6 GOTO 0x1f6 297: } 1D6 29F5 GOTO 0x1f5 298: else { 299: #if defined(__PICC18__) || defined(__PICCPRO__) 300: ((both_t *)&value)->flt.hexp = newexp >> 1; 1D7 1283 BCF 0x3, 0x5 1D8 1303 BCF 0x3, 0x6 1D9 0841 MOVF 0x41, W 1DA 00C3 MOVWF 0x43 1DB 0840 MOVF 0x40, W 1DC 00C2 MOVWF 0x42 1DD 3001 MOVLW 0x1 1DE 00FF MOVWF 0x7f 1DF 0D43 RLF 0x43, W 1E0 0CC3 RRF 0x43, F 1E1 0CC2 RRF 0x42, F 1E2 0BFF DECFSZ 0x7f, F 1E3 29DF GOTO 0x1df 1E4 083F MOVF 0x3f, W 1E5 0642 XORWF 0x42, W 1E6 3980 ANDLW 0x80 1E7 0642 XORWF 0x42, W 1E8 00BF MOVWF 0x3f 301: ((both_t *)&value)->flt.lexp = newexp & 0x01; 1E9 0840 MOVF 0x40, W 1EA 3901 ANDLW 0x1 1EB 00C2 MOVWF 0x42 1EC 0CC2 RRF 0x42, F 1ED 0CC2 RRF 0x42, F 1EE 083E MOVF 0x3e, W 1EF 0642 XORWF 0x42, W 1F0 397F ANDLW 0x7f 1F1 0642 XORWF 0x42, W 1F2 00BE MOVWF 0x3e 1F3 29F5 GOTO 0x1f5 302: #else 303: ((both_t *)&value)->flt.exp = newexp; 304: #endif 305: } 1F4 29F5 GOTO 0x1f5 306: return value; 1F5 29F6 GOTO 0x1f6 307: } 1F6 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftadd.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define f1_as_mant1 (*(unsigned short long *)&f1) 11: #define f2_as_mant2 (*(unsigned short long *)&f2) 12: 13: // floating addition 14: #ifdef _OLDLIB 15: float 16: __ftadd(float f1, float f2) 17: { 18: unsigned char exp1, exp2, sign1, sign2, cntr; 19: 20: if(sizeof(f1_as_mant1) != 3) 21: return 0; 22: sign1 = __ftunpack(&f1_as_mant1, &exp1); 23: if(exp1 == 0) 24: return f2; 25: sign2 = __ftunpack(&f2_as_mant2, &exp2); 26: if(exp2 != 0) { 27: cntr = 6; 28: // determine the smaller number. 29: if(exp1 < exp2) { 30: if((unsigned char)(exp2-exp1) > sizeof(f1)*8) { 31: // return f2 32: f1_as_mant1 = 0; 33: exp1 = exp2; 34: sign1 = sign2; 35: } else { 36: // f1 has the smaller exponent - we can shift f2_as_mant2 up to 6 bits 37: // left, decrementing exp2. 38: do { 39: f2_as_mant2 <<= 1; 40: exp2--; 41: } while(exp2 != exp1 && --cntr != 0); 42: while(exp1 != exp2) { 43: f1_as_mant1 >>= 1; 44: exp1++; 45: } 46: } 47: } else if(exp1 != exp2) { 48: if((unsigned char)(exp1-exp2) > sizeof(f1)*8) 49: f2_as_mant2 = 0; 50: else { 51: // f2 has the smaller exponent - we can shift f1_as_mant1 up to 6 bits 52: // left, decrementing exp2. 53: do { 54: f1_as_mant1 <<= 1; 55: exp1--; 56: } while(exp2 != exp1 && --cntr != 0); 57: while(exp1 != exp2) { 58: f2_as_mant2 >>= 1; 59: exp2++; 60: } 61: } 62: } 63: if(sign1 != 0) { 64: f1_as_mant1 ^= 0xFFFFFF; 65: f1_as_mant1++; 66: } 67: if(sign2 != 0) { 68: f2_as_mant2 ^= 0xFFFFFF; 69: f2_as_mant2++; 70: } 71: sign1 = 0; 72: f1_as_mant1 += f2_as_mant2; 73: if(f1_as_mant1 & 0x800000) { 74: f1_as_mant1 ^= 0xFFFFFF; 75: f1_as_mant1++; 76: sign1 = 1; 77: } 78: } 79: __ftpack(&f1_as_mant1, exp1); 80: if(sign1) 81: f1_as_mant1 ^= 0x800000; 82: return f1; 83: } 84: #else 85: float 86: __ftadd(float f1, float f2) 87: { 88: unsigned char exp1, exp2, sign; 89: 90: exp1 = f1_as_mant1 >> 15; 567 1283 BCF 0x3, 0x5 568 1303 BCF 0x3, 0x6 569 0830 MOVF 0x30, W 56A 00B6 MOVWF 0x36 56B 0831 MOVF 0x31, W 56C 00B7 MOVWF 0x37 56D 0832 MOVF 0x32, W 56E 00B8 MOVWF 0x38 56F 1003 BCF 0x3, 0 570 0D37 RLF 0x37, W 571 0D38 RLF 0x38, W 572 00B9 MOVWF 0x39 573 0839 MOVF 0x39, W 574 00BC MOVWF 0x3c 91: exp2 = f2_as_mant2 >> 15; 575 0833 MOVF 0x33, W 576 00B6 MOVWF 0x36 577 0834 MOVF 0x34, W 578 00B7 MOVWF 0x37 579 0835 MOVF 0x35, W 57A 00B8 MOVWF 0x38 57B 1003 BCF 0x3, 0 57C 0D37 RLF 0x37, W 57D 0D38 RLF 0x38, W 57E 00B9 MOVWF 0x39 57F 0839 MOVF 0x39, W 580 00BB MOVWF 0x3b 92: if(exp1 == 0 || exp1 < exp2 && (unsigned char)(exp2-exp1) > sizeof(f1)*8) 581 083C MOVF 0x3c, W 582 1D03 BTFSS 0x3, 0x2 583 2D85 GOTO 0x585 584 2D96 GOTO 0x596 585 083B MOVF 0x3b, W 586 023C SUBWF 0x3c, W 587 1803 BTFSC 0x3, 0 588 2D8A GOTO 0x58a 589 2D8B GOTO 0x58b 58A 2D9E GOTO 0x59e 58B 033C DECF 0x3c, W 58C 3AFF XORLW 0xff 58D 073B ADDWF 0x3b, W 58E 00B6 MOVWF 0x36 58F 3019 MOVLW 0x19 590 0236 SUBWF 0x36, W 591 1C03 BTFSS 0x3, 0 592 2D94 GOTO 0x594 593 2D95 GOTO 0x595 594 2D9E GOTO 0x59e 595 2D96 GOTO 0x596 93: return f2; 596 0833 MOVF 0x33, W 597 00B0 MOVWF 0x30 598 0834 MOVF 0x34, W 599 00B1 MOVWF 0x31 59A 0835 MOVF 0x35, W 59B 00B2 MOVWF 0x32 59C 2EAE GOTO 0x6ae 59D 2EAE GOTO 0x6ae 94: if(exp2 == 0 || exp1 > exp2 && (unsigned char)(exp1-exp2) > sizeof(f1)*8) 59E 083B MOVF 0x3b, W 59F 1D03 BTFSS 0x3, 0x2 5A0 2DA2 GOTO 0x5a2 5A1 2DB2 GOTO 0x5b2 5A2 083C MOVF 0x3c, W 5A3 023B SUBWF 0x3b, W 5A4 1803 BTFSC 0x3, 0 5A5 2DA7 GOTO 0x5a7 5A6 2DA8 GOTO 0x5a8 5A7 2DB3 GOTO 0x5b3 5A8 033B DECF 0x3b, W 5A9 3AFF XORLW 0xff 5AA 073C ADDWF 0x3c, W 5AB 00B6 MOVWF 0x36 5AC 3019 MOVLW 0x19 5AD 0236 SUBWF 0x36, W 5AE 1C03 BTFSS 0x3, 0 5AF 2DB1 GOTO 0x5b1 5B0 2DB2 GOTO 0x5b2 5B1 2DB3 GOTO 0x5b3 95: return f1; 5B2 2EAE GOTO 0x6ae 96: sign = 6; 5B3 3006 MOVLW 0x6 5B4 00B6 MOVWF 0x36 5B5 0836 MOVF 0x36, W 5B6 00BA MOVWF 0x3a 97: if(f1_as_mant1 & 0x800000L) 5B7 1FB2 BTFSS 0x32, 0x7 5B8 2DBA GOTO 0x5ba 5B9 2DBB GOTO 0x5bb 5BA 2DBC GOTO 0x5bc 98: sign |= 0x80; 5BB 17BA BSF 0x3a, 0x7 99: if(f2_as_mant2 & 0x800000L) 5BC 1FB5 BTFSS 0x35, 0x7 5BD 2DBF GOTO 0x5bf 5BE 2DC0 GOTO 0x5c0 5BF 2DC1 GOTO 0x5c1 100: sign |= 0x40; 5C0 173A BSF 0x3a, 0x6 101: f1_as_mant1 |= 0x8000UL; 5C1 17B1 BSF 0x31, 0x7 102: f1_as_mant1 &= 0xFFFFUL; 5C2 30FF MOVLW 0xff 5C3 05B0 ANDWF 0x30, F 5C4 30FF MOVLW 0xff 5C5 05B1 ANDWF 0x31, F 5C6 3000 MOVLW 0 5C7 05B2 ANDWF 0x32, F 103: f2_as_mant2 |= 0x8000UL; 5C8 17B4 BSF 0x34, 0x7 104: f2_as_mant2 &= 0xFFFFUL; 5C9 30FF MOVLW 0xff 5CA 05B3 ANDWF 0x33, F 5CB 30FF MOVLW 0xff 5CC 05B4 ANDWF 0x34, F 5CD 3000 MOVLW 0 5CE 05B5 ANDWF 0x35, F 105: // determine the smaller number. 106: if(exp1 < exp2) { 5CF 083B MOVF 0x3b, W 5D0 023C SUBWF 0x3c, W 5D1 1803 BTFSC 0x3, 0 5D2 2DD4 GOTO 0x5d4 5D3 2DD5 GOTO 0x5d5 5D4 2E06 GOTO 0x606 5D5 2DD6 GOTO 0x5d6 107: // f1 has the smaller exponent - we can shift f2_as_mant2 up to 6 bits 108: // left, decrementing exp2. 109: do { 110: f2_as_mant2 <<= 1; 5D6 3001 MOVLW 0x1 5D7 1003 BCF 0x3, 0 5D8 0DB3 RLF 0x33, F 5D9 0DB4 RLF 0x34, F 5DA 0DB5 RLF 0x35, F 5DB 3EFF ADDLW 0xff 5DC 1D03 BTFSS 0x3, 0x2 5DD 2DD7 GOTO 0x5d7 111: exp2--; 5DE 3001 MOVLW 0x1 5DF 02BB SUBWF 0x3b, F 112: } while(exp2 != exp1 && --sign & 7); 5E0 083B MOVF 0x3b, W 5E1 063C XORWF 0x3c, W 5E2 1903 BTFSC 0x3, 0x2 5E3 2DE5 GOTO 0x5e5 5E4 2DE6 GOTO 0x5e6 5E5 2DFE GOTO 0x5fe 5E6 3001 MOVLW 0x1 5E7 02BA SUBWF 0x3a, F 5E8 083A MOVF 0x3a, W 5E9 3907 ANDLW 0x7 5EA 1D03 BTFSS 0x3, 0x2 5EB 2DED GOTO 0x5ed 5EC 2DEE GOTO 0x5ee 5ED 2DD6 GOTO 0x5d6 5EE 2DFE GOTO 0x5fe 5EF 2DFE GOTO 0x5fe 113: while(exp1 != exp2) { 5F0 2DFE GOTO 0x5fe 5FE 083C MOVF 0x3c, W 5FF 063B XORWF 0x3b, W 600 1D03 BTFSS 0x3, 0x2 601 2E03 GOTO 0x603 602 2E04 GOTO 0x604 603 2DF1 GOTO 0x5f1 604 2E3D GOTO 0x63d 114: f1_as_mant1 >>= 1; 5F1 3001 MOVLW 0x1 5F2 1003 BCF 0x3, 0 5F3 0CB2 RRF 0x32, F 5F4 0CB1 RRF 0x31, F 5F5 0CB0 RRF 0x30, F 5F6 3EFF ADDLW 0xff 5F7 1D03 BTFSS 0x3, 0x2 5F8 2DF2 GOTO 0x5f2 115: exp1++; 5F9 3001 MOVLW 0x1 5FA 00B6 MOVWF 0x36 5FB 0836 MOVF 0x36, W 5FC 07BC ADDWF 0x3c, F 5FD 2DFE GOTO 0x5fe 116: } 117: } else if(exp1 > exp2) { 605 2E3D GOTO 0x63d 606 083C MOVF 0x3c, W 607 023B SUBWF 0x3b, W 608 1803 BTFSC 0x3, 0 609 2E0B GOTO 0x60b 60A 2E0C GOTO 0x60c 60B 2E3D GOTO 0x63d 60C 2E0D GOTO 0x60d 118: // f2 has the smaller exponent - we can shift f1_as_mant1 up to 6 bits 119: // left, decrementing exp2. 120: do { 121: f1_as_mant1 <<= 1; 60D 3001 MOVLW 0x1 60E 1003 BCF 0x3, 0 60F 0DB0 RLF 0x30, F 610 0DB1 RLF 0x31, F 611 0DB2 RLF 0x32, F 612 3EFF ADDLW 0xff 613 1D03 BTFSS 0x3, 0x2 614 2E0E GOTO 0x60e 122: exp1--; 615 3001 MOVLW 0x1 616 02BC SUBWF 0x3c, F 123: } while(exp2 != exp1 && --sign & 7); 617 083B MOVF 0x3b, W 618 063C XORWF 0x3c, W 619 1903 BTFSC 0x3, 0x2 61A 2E1C GOTO 0x61c 61B 2E1D GOTO 0x61d 61C 2E35 GOTO 0x635 61D 3001 MOVLW 0x1 61E 02BA SUBWF 0x3a, F 61F 083A MOVF 0x3a, W 620 3907 ANDLW 0x7 621 1D03 BTFSS 0x3, 0x2 622 2E24 GOTO 0x624 623 2E25 GOTO 0x625 624 2E0D GOTO 0x60d 625 2E35 GOTO 0x635 626 2E35 GOTO 0x635 124: while(exp1 != exp2) { 627 2E35 GOTO 0x635 635 083C MOVF 0x3c, W 636 063B XORWF 0x3b, W 637 1D03 BTFSS 0x3, 0x2 638 2E3A GOTO 0x63a 639 2E3B GOTO 0x63b 63A 2E28 GOTO 0x628 63B 2E3D GOTO 0x63d 63C 2E3D GOTO 0x63d 125: f2_as_mant2 >>= 1; 628 3001 MOVLW 0x1 629 1003 BCF 0x3, 0 62A 0CB5 RRF 0x35, F 62B 0CB4 RRF 0x34, F 62C 0CB3 RRF 0x33, F 62D 3EFF ADDLW 0xff 62E 1D03 BTFSS 0x3, 0x2 62F 2E29 GOTO 0x629 126: exp2++; 630 3001 MOVLW 0x1 631 00B6 MOVWF 0x36 632 0836 MOVF 0x36, W 633 07BB ADDWF 0x3b, F 634 2E35 GOTO 0x635 127: } 128: } 129: if(sign & 0x80) { 63D 1FBA BTFSS 0x3a, 0x7 63E 2E40 GOTO 0x640 63F 2E41 GOTO 0x641 640 2E52 GOTO 0x652 130: // complement and add 1 131: f1_as_mant1 ^= 0xFFFFFFUL; 641 30FF MOVLW 0xff 642 06B0 XORWF 0x30, F 643 30FF MOVLW 0xff 644 06B1 XORWF 0x31, F 645 30FF MOVLW 0xff 646 06B2 XORWF 0x32, F 132: f1_as_mant1++; 647 3001 MOVLW 0x1 648 07B0 ADDWF 0x30, F 649 3000 MOVLW 0 64A 1803 BTFSC 0x3, 0 64B 3001 MOVLW 0x1 64C 07B1 ADDWF 0x31, F 64D 3000 MOVLW 0 64E 1803 BTFSC 0x3, 0 64F 3001 MOVLW 0x1 650 07B2 ADDWF 0x32, F 651 2E52 GOTO 0x652 133: } 134: if(sign & 0x40) { 652 1F3A BTFSS 0x3a, 0x6 653 2E55 GOTO 0x655 654 2E56 GOTO 0x656 655 2E67 GOTO 0x667 135: // complement and add 1 136: f2_as_mant2 ^= 0xFFFFFFUL; 656 30FF MOVLW 0xff 657 06B3 XORWF 0x33, F 658 30FF MOVLW 0xff 659 06B4 XORWF 0x34, F 65A 30FF MOVLW 0xff 65B 06B5 XORWF 0x35, F 137: f2_as_mant2++; 65C 3001 MOVLW 0x1 65D 07B3 ADDWF 0x33, F 65E 3000 MOVLW 0 65F 1803 BTFSC 0x3, 0 660 3001 MOVLW 0x1 661 07B4 ADDWF 0x34, F 662 3000 MOVLW 0 663 1803 BTFSC 0x3, 0 664 3001 MOVLW 0x1 665 07B5 ADDWF 0x35, F 666 2E67 GOTO 0x667 138: } 139: sign = 0; 667 1003 BCF 0x3, 0 668 3000 MOVLW 0 669 1803 BTFSC 0x3, 0 66A 3001 MOVLW 0x1 66B 00BA MOVWF 0x3a 140: f2_as_mant2 += f1_as_mant1; 66C 0830 MOVF 0x30, W 66D 07B3 ADDWF 0x33, F 66E 0831 MOVF 0x31, W 66F 1103 BCF 0x3, 0x2 670 1803 BTFSC 0x3, 0 671 0A31 INCF 0x31, W 672 1903 BTFSC 0x3, 0x2 673 2E75 GOTO 0x675 674 07B4 ADDWF 0x34, F 675 0832 MOVF 0x32, W 676 1103 BCF 0x3, 0x2 677 1803 BTFSC 0x3, 0 678 0A32 INCF 0x32, W 679 1903 BTFSC 0x3, 0x2 67A 2E7C GOTO 0x67c 67B 07B5 ADDWF 0x35, F 141: if(f2_as_mant2 & 0x800000UL) { 67C 1FB5 BTFSS 0x35, 0x7 67D 2E7F GOTO 0x67f 67E 2E80 GOTO 0x680 67F 2E94 GOTO 0x694 142: f2_as_mant2 ^= 0xFFFFFFUL; 680 30FF MOVLW 0xff 681 06B3 XORWF 0x33, F 682 30FF MOVLW 0xff 683 06B4 XORWF 0x34, F 684 30FF MOVLW 0xff 685 06B5 XORWF 0x35, F 143: f2_as_mant2++; 686 3001 MOVLW 0x1 687 07B3 ADDWF 0x33, F 688 3000 MOVLW 0 689 1803 BTFSC 0x3, 0 68A 3001 MOVLW 0x1 68B 07B4 ADDWF 0x34, F 68C 3000 MOVLW 0 68D 1803 BTFSC 0x3, 0 68E 3001 MOVLW 0x1 68F 07B5 ADDWF 0x35, F 144: sign = 1; 690 01BA CLRF 0x3a 691 1403 BSF 0x3, 0 692 0DBA RLF 0x3a, F 693 2E94 GOTO 0x694 145: } 146: return __ftpack(f2_as_mant2, exp1, sign); 694 0833 MOVF 0x33, W 695 00F0 MOVWF 0x70 696 0834 MOVF 0x34, W 697 00F1 MOVWF 0x71 698 0835 MOVF 0x35, W 699 00F2 MOVWF 0x72 69A 083C MOVF 0x3c, W 69B 00B6 MOVWF 0x36 69C 0836 MOVF 0x36, W 69D 00F3 MOVWF 0x73 69E 083A MOVF 0x3a, W 69F 00B7 MOVWF 0x37 6A0 0837 MOVF 0x37, W 6A1 00F4 MOVWF 0x74 6A2 158A BSF 0xa, 0x3 6A3 26E9 CALL 0x6e9 6A4 118A BCF 0xa, 0x3 6A5 0870 MOVF 0x70, W 6A6 1283 BCF 0x3, 0x5 6A7 1303 BCF 0x3, 0x6 6A8 00B0 MOVWF 0x30 6A9 0871 MOVF 0x71, W 6AA 00B1 MOVWF 0x31 6AB 0872 MOVF 0x72, W 6AC 00B2 MOVWF 0x32 6AD 2EAE GOTO 0x6ae 147: 148: } 6AE 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftdiv.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define f1_as_dividend (*(unsigned short long *)&f1) 11: #define f2_as_divisor (*(unsigned short long *)&f2) 12: #define f3_as_quot (*(unsigned short long *)&f3) 13: 14: // floating addition 15: #ifdef _OLDLIB 16: #define cntr sign2 17: float 18: __ftdiv(float f2, float f1) 19: { 20: unsigned char exp1, exp2, sign1, sign2; 21: float f3; 22: 23: f3_as_quot = 0; 24: sign1 = __ftunpack(&f1_as_dividend, &exp1); 25: if(exp1 == 0) 26: return f3; 27: sign2 = __ftunpack(&f2_as_divisor, &exp2); 28: if(exp2 == 0) 29: return f3; 30: exp1 -= exp2-127+8; // compute new exponent 31: sign1 ^= sign2; 32: cntr = 16+8; 33: do { 34: f3_as_quot <<= 1; 35: if(f1_as_dividend >= f2_as_divisor) { 36: f1_as_dividend -= f2_as_divisor; 37: f3_as_quot |= 1; 38: } 39: f1_as_dividend <<= 1; 40: } while(--cntr != 0); 41: __ftpack(&f3_as_quot, exp1); 42: if(sign1) 43: f3_as_quot |= 0x800000; 44: return f3; 45: } 46: #else 47: #define exp2 sign 48: float 49: __ftdiv(float f2, float f1) 50: { 51: unsigned char exp, sign, cntr; 52: float f3; 53: 54: // unpack the operands 55: if((exp = f1_as_dividend >> 15) == 0) 1F7 087B MOVF 0x7b, W 1F8 1283 BCF 0x3, 0x5 1F9 1303 BCF 0x3, 0x6 1FA 00A0 MOVWF 0x20 1FB 087C MOVF 0x7c, W 1FC 00A1 MOVWF 0x21 1FD 087D MOVF 0x7d, W 1FE 00A2 MOVWF 0x22 1FF 1003 BCF 0x3, 0 200 0D21 RLF 0x21, W 201 0D22 RLF 0x22, W 202 00A3 MOVWF 0x23 203 0823 MOVF 0x23, W 204 00A8 MOVWF 0x28 205 08A8 MOVF 0x28, F 206 1D03 BTFSS 0x3, 0x2 207 2A09 GOTO 0x209 208 2A0A GOTO 0x20a 209 2A12 GOTO 0x212 56: return 0.0; 20A 3000 MOVLW 0 20B 00F8 MOVWF 0x78 20C 3000 MOVLW 0 20D 00F9 MOVWF 0x79 20E 3000 MOVLW 0 20F 00FA MOVWF 0x7a 210 2ABA GOTO 0x2ba 211 2ABA GOTO 0x2ba 57: if((exp2 = f2_as_divisor >> 15) == 0) 212 0878 MOVF 0x78, W 213 00A0 MOVWF 0x20 214 0879 MOVF 0x79, W 215 00A1 MOVWF 0x21 216 087A MOVF 0x7a, W 217 00A2 MOVWF 0x22 218 1003 BCF 0x3, 0 219 0D21 RLF 0x21, W 21A 0D22 RLF 0x22, W 21B 00A3 MOVWF 0x23 21C 0823 MOVF 0x23, W 21D 00A9 MOVWF 0x29 21E 08A9 MOVF 0x29, F 21F 1D03 BTFSS 0x3, 0x2 220 2A22 GOTO 0x222 221 2A23 GOTO 0x223 222 2A2B GOTO 0x22b 58: return 0.0; 223 3000 MOVLW 0 224 00F8 MOVWF 0x78 225 3000 MOVLW 0 226 00F9 MOVWF 0x79 227 3000 MOVLW 0 228 00FA MOVWF 0x7a 229 2ABA GOTO 0x2ba 22A 2ABA GOTO 0x2ba 59: f3_as_quot = 0; 22B 3000 MOVLW 0 22C 00A5 MOVWF 0x25 22D 3000 MOVLW 0 22E 00A6 MOVWF 0x26 22F 3000 MOVLW 0 230 00A7 MOVWF 0x27 60: exp -= exp2-127+8; // compute new exponent 231 3089 MOVLW 0x89 232 0729 ADDWF 0x29, W 233 00A0 MOVWF 0x20 234 0820 MOVF 0x20, W 235 02A8 SUBWF 0x28, F 61: sign = f1_as_dividend >> 16; 236 087B MOVF 0x7b, W 237 00A0 MOVWF 0x20 238 087C MOVF 0x7c, W 239 00A1 MOVWF 0x21 23A 087D MOVF 0x7d, W 23B 00A2 MOVWF 0x22 23C 3010 MOVLW 0x10 23D 1003 BCF 0x3, 0 23E 0CA2 RRF 0x22, F 23F 0CA1 RRF 0x21, F 240 0CA0 RRF 0x20, F 241 3EFF ADDLW 0xff 242 1D03 BTFSS 0x3, 0x2 243 2A3D GOTO 0x23d 244 0820 MOVF 0x20, W 245 00A3 MOVWF 0x23 246 0823 MOVF 0x23, W 247 00A9 MOVWF 0x29 62: sign ^= (unsigned char)(f2_as_divisor >> 16); 248 0878 MOVF 0x78, W 249 00A0 MOVWF 0x20 24A 0879 MOVF 0x79, W 24B 00A1 MOVWF 0x21 24C 087A MOVF 0x7a, W 24D 00A2 MOVWF 0x22 24E 3010 MOVLW 0x10 24F 1003 BCF 0x3, 0 250 0CA2 RRF 0x22, F 251 0CA1 RRF 0x21, F 252 0CA0 RRF 0x20, F 253 3EFF ADDLW 0xff 254 1D03 BTFSS 0x3, 0x2 255 2A4F GOTO 0x24f 256 0820 MOVF 0x20, W 257 00A3 MOVWF 0x23 258 0823 MOVF 0x23, W 259 06A9 XORWF 0x29, F 63: sign &= 0x80; 25A 3080 MOVLW 0x80 25B 00A0 MOVWF 0x20 25C 0820 MOVF 0x20, W 25D 05A9 ANDWF 0x29, F 64: f1_as_dividend |= 0x8000UL; 25E 17FC BSF 0x7c, 0x7 65: f1_as_dividend &= 0xFFFFUL; 25F 30FF MOVLW 0xff 260 05FB ANDWF 0x7b, F 261 30FF MOVLW 0xff 262 05FC ANDWF 0x7c, F 263 3000 MOVLW 0 264 05FD ANDWF 0x7d, F 66: f2_as_divisor |= 0x8000UL; 265 17F9 BSF 0x79, 0x7 67: f2_as_divisor &= 0xFFFFUL; 266 30FF MOVLW 0xff 267 05F8 ANDWF 0x78, F 268 30FF MOVLW 0xff 269 05F9 ANDWF 0x79, F 26A 3000 MOVLW 0 26B 05FA ANDWF 0x7a, F 68: cntr = 16+8; 26C 3018 MOVLW 0x18 26D 00A0 MOVWF 0x20 26E 0820 MOVF 0x20, W 26F 00A4 MOVWF 0x24 270 2A71 GOTO 0x271 69: do { 70: f3_as_quot <<= 1; 271 3001 MOVLW 0x1 272 1003 BCF 0x3, 0 273 0DA5 RLF 0x25, F 274 0DA6 RLF 0x26, F 275 0DA7 RLF 0x27, F 276 3EFF ADDLW 0xff 277 1D03 BTFSS 0x3, 0x2 278 2A72 GOTO 0x272 71: if(f1_as_dividend >= f2_as_divisor) { 279 087A MOVF 0x7a, W 27A 027D SUBWF 0x7d, W 27B 1D03 BTFSS 0x3, 0x2 27C 2A83 GOTO 0x283 27D 0879 MOVF 0x79, W 27E 027C SUBWF 0x7c, W 27F 1D03 BTFSS 0x3, 0x2 280 2A83 GOTO 0x283 281 0878 MOVF 0x78, W 282 027B SUBWF 0x7b, W 283 1C03 BTFSS 0x3, 0 284 2A86 GOTO 0x286 285 2A87 GOTO 0x287 286 2A93 GOTO 0x293 72: f1_as_dividend -= f2_as_divisor; 287 0878 MOVF 0x78, W 288 02FB SUBWF 0x7b, F 289 0879 MOVF 0x79, W 28A 1C03 BTFSS 0x3, 0 28B 0F79 INCFSZ 0x79, W 28C 02FC SUBWF 0x7c, F 28D 087A MOVF 0x7a, W 28E 1C03 BTFSS 0x3, 0 28F 0A7A INCF 0x7a, W 290 02FD SUBWF 0x7d, F 73: f3_as_quot |= 1; 291 1425 BSF 0x25, 0 292 2A93 GOTO 0x293 74: } 75: f1_as_dividend <<= 1; 293 3001 MOVLW 0x1 294 1003 BCF 0x3, 0 295 0DFB RLF 0x7b, F 296 0DFC RLF 0x7c, F 297 0DFD RLF 0x7d, F 298 3EFF ADDLW 0xff 299 1D03 BTFSS 0x3, 0x2 29A 2A94 GOTO 0x294 76: } while(--cntr != 0); 29B 3001 MOVLW 0x1 29C 02A4 SUBWF 0x24, F 29D 1D03 BTFSS 0x3, 0x2 29E 2AA0 GOTO 0x2a0 29F 2AA1 GOTO 0x2a1 2A0 2A71 GOTO 0x271 2A1 2AA2 GOTO 0x2a2 77: return __ftpack(f3_as_quot, exp, sign); 2A2 0825 MOVF 0x25, W 2A3 00F0 MOVWF 0x70 2A4 0826 MOVF 0x26, W 2A5 00F1 MOVWF 0x71 2A6 0827 MOVF 0x27, W 2A7 00F2 MOVWF 0x72 2A8 0828 MOVF 0x28, W 2A9 00A0 MOVWF 0x20 2AA 0820 MOVF 0x20, W 2AB 00F3 MOVWF 0x73 2AC 0829 MOVF 0x29, W 2AD 00A1 MOVWF 0x21 2AE 0821 MOVF 0x21, W 2AF 00F4 MOVWF 0x74 2B0 158A BSF 0xa, 0x3 2B1 26E9 CALL 0x6e9 2B2 118A BCF 0xa, 0x3 2B3 0870 MOVF 0x70, W 2B4 00F8 MOVWF 0x78 2B5 0871 MOVF 0x71, W 2B6 00F9 MOVWF 0x79 2B7 0872 MOVF 0x72, W 2B8 00FA MOVWF 0x7a 2B9 2ABA GOTO 0x2ba 78: } 2BA 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftge.c --------------------------------- 1: #define f1 (*(unsigned short long *)&ff1) 2: #define f2 (*(unsigned short long *)&ff2) 3: bit 4: __ftge(float ff1, float ff2) 5: { 6: if(f1 & 0x800000UL) E7D 1FF2 BTFSS 0x72, 0x7 E7E 2E80 GOTO 0x680 E7F 2E81 GOTO 0x681 E80 2EA7 GOTO 0x6a7 7: f1 = 0x800000UL - f1; E81 3000 MOVLW 0 E82 00F6 MOVWF 0x76 E83 3000 MOVLW 0 E84 00F7 MOVWF 0x77 E85 3080 MOVLW 0x80 E86 00F8 MOVWF 0x78 E87 0970 COMF 0x70, W E88 00F9 MOVWF 0x79 E89 0971 COMF 0x71, W E8A 00FA MOVWF 0x7a E8B 0972 COMF 0x72, W E8C 00FB MOVWF 0x7b E8D 0AF9 INCF 0x79, F E8E 1903 BTFSC 0x3, 0x2 E8F 0AFA INCF 0x7a, F E90 1903 BTFSC 0x3, 0x2 E91 0AFB INCF 0x7b, F E92 0879 MOVF 0x79, W E93 07F6 ADDWF 0x76, F E94 087A MOVF 0x7a, W E95 1803 BTFSC 0x3, 0 E96 0F7A INCFSZ 0x7a, W E97 2E99 GOTO 0x699 E98 2E9A GOTO 0x69a E99 07F7 ADDWF 0x77, F E9A 087B MOVF 0x7b, W E9B 1803 BTFSC 0x3, 0 E9C 0F7B INCFSZ 0x7b, W E9D 2E9F GOTO 0x69f E9E 2EA0 GOTO 0x6a0 E9F 07F8 ADDWF 0x78, F EA0 0876 MOVF 0x76, W EA1 00F0 MOVWF 0x70 EA2 0877 MOVF 0x77, W EA3 00F1 MOVWF 0x71 EA4 0878 MOVF 0x78, W EA5 00F2 MOVWF 0x72 EA6 2EA7 GOTO 0x6a7 8: if(f2 & 0x800000UL) EA7 1FF5 BTFSS 0x75, 0x7 EA8 2EAA GOTO 0x6aa EA9 2EAB GOTO 0x6ab EAA 2ED1 GOTO 0x6d1 9: f2 = 0x800000UL - f2; EAB 3000 MOVLW 0 EAC 00F6 MOVWF 0x76 EAD 3000 MOVLW 0 EAE 00F7 MOVWF 0x77 EAF 3080 MOVLW 0x80 EB0 00F8 MOVWF 0x78 EB1 0973 COMF 0x73, W EB2 00F9 MOVWF 0x79 EB3 0974 COMF 0x74, W EB4 00FA MOVWF 0x7a EB5 0975 COMF 0x75, W EB6 00FB MOVWF 0x7b EB7 0AF9 INCF 0x79, F EB8 1903 BTFSC 0x3, 0x2 EB9 0AFA INCF 0x7a, F EBA 1903 BTFSC 0x3, 0x2 EBB 0AFB INCF 0x7b, F EBC 0879 MOVF 0x79, W EBD 07F6 ADDWF 0x76, F EBE 087A MOVF 0x7a, W EBF 1803 BTFSC 0x3, 0 EC0 0F7A INCFSZ 0x7a, W EC1 2EC3 GOTO 0x6c3 EC2 2EC4 GOTO 0x6c4 EC3 07F7 ADDWF 0x77, F EC4 087B MOVF 0x7b, W EC5 1803 BTFSC 0x3, 0 EC6 0F7B INCFSZ 0x7b, W EC7 2EC9 GOTO 0x6c9 EC8 2ECA GOTO 0x6ca EC9 07F8 ADDWF 0x78, F ECA 0876 MOVF 0x76, W ECB 00F3 MOVWF 0x73 ECC 0877 MOVF 0x77, W ECD 00F4 MOVWF 0x74 ECE 0878 MOVF 0x78, W ECF 00F5 MOVWF 0x75 ED0 2ED1 GOTO 0x6d1 10: f1 ^= 0x800000UL; ED1 3080 MOVLW 0x80 ED2 06F2 XORWF 0x72, F 11: f2 ^= 0x800000UL; ED3 3080 MOVLW 0x80 ED4 06F5 XORWF 0x75, F 12: return f1 >= f2; ED5 0875 MOVF 0x75, W ED6 0272 SUBWF 0x72, W ED7 1D03 BTFSS 0x3, 0x2 ED8 2EDF GOTO 0x6df ED9 0874 MOVF 0x74, W EDA 0271 SUBWF 0x71, W EDB 1D03 BTFSS 0x3, 0x2 EDC 2EDF GOTO 0x6df EDD 0873 MOVF 0x73, W EDE 0270 SUBWF 0x70, W EDF 1803 BTFSC 0x3, 0 EE0 2EE2 GOTO 0x6e2 EE1 2EE3 GOTO 0x6e3 EE2 2EE5 GOTO 0x6e5 EE3 1003 BCF 0x3, 0 EE4 2EE8 GOTO 0x6e8 EE5 1403 BSF 0x3, 0 EE6 2EE8 GOTO 0x6e8 EE7 2EE8 GOTO 0x6e8 13: } EE8 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftmul.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define f1_as_plier (*(unsigned short long *)&f1) 11: #define f2_as_plicand (*(unsigned short long *)&f2) 12: 13: // floating addition 14: 15: #ifdef _OLDLIB 16: #define f3_as_product (*(unsigned short long *)&f3) 17: float 18: __ftmul(float f1, float f2) 19: { 20: unsigned char exp1, sign1, cntr; 21: float f3; 22: 23: f3_as_product = 0; 24: sign1 = __ftunpack(&f1_as_plier, &exp1); 25: sign1 ^= __ftunpack(&f2_as_plicand, &cntr); 26: if(cntr == 0 || exp1 == 0) 27: return f3; 28: exp1 += cntr-127-6; // compute new exponent 29: cntr = 7; 30: do { 31: if(f1_as_plier & 1) 32: f3_as_product += f2_as_plicand; 33: f1_as_plier >>= 1; 34: f2_as_plicand <<= 1; 35: } while(--cntr != 0); 36: cntr = 9; 37: do { 38: if(f1_as_plier & 1) 39: f3_as_product += f2_as_plicand; 40: f1_as_plier >>= 1; 41: f3_as_product >>= 1; 42: } while(--cntr != 0); 43: __ftpack(&f3_as_product, exp1); 44: if(sign1) 45: f3_as_product |= 0x800000; 46: return f3; 47: } 48: #else 49: #define exp2 sign 50: float 51: __ftmul(float f1, float f2) 52: { 53: unsigned char exp, sign, cntr; 54: unsigned short long f3_as_product; 55: 56: if((exp = f1_as_plier >> 15) == 0) 384 1283 BCF 0x3, 0x5 385 1303 BCF 0x3, 0x6 386 0820 MOVF 0x20, W 387 00A6 MOVWF 0x26 388 0821 MOVF 0x21, W 389 00A7 MOVWF 0x27 38A 0822 MOVF 0x22, W 38B 00A8 MOVWF 0x28 38C 1003 BCF 0x3, 0 38D 0D27 RLF 0x27, W 38E 0D28 RLF 0x28, W 38F 00A9 MOVWF 0x29 390 0829 MOVF 0x29, W 391 00AA MOVWF 0x2a 392 08AA MOVF 0x2a, F 393 1D03 BTFSS 0x3, 0x2 394 2B96 GOTO 0x396 395 2B97 GOTO 0x397 396 2B9F GOTO 0x39f 57: return 0.0; 397 3000 MOVLW 0 398 00A0 MOVWF 0x20 399 3000 MOVLW 0 39A 00A1 MOVWF 0x21 39B 3000 MOVLW 0 39C 00A2 MOVWF 0x22 39D 2C6F GOTO 0x46f 39E 2C6F GOTO 0x46f 58: if((exp2 = f2_as_plicand >> 15) == 0) 39F 0823 MOVF 0x23, W 3A0 00A6 MOVWF 0x26 3A1 0824 MOVF 0x24, W 3A2 00A7 MOVWF 0x27 3A3 0825 MOVF 0x25, W 3A4 00A8 MOVWF 0x28 3A5 1003 BCF 0x3, 0 3A6 0D27 RLF 0x27, W 3A7 0D28 RLF 0x28, W 3A8 00A9 MOVWF 0x29 3A9 0829 MOVF 0x29, W 3AA 00AF MOVWF 0x2f 3AB 08AF MOVF 0x2f, F 3AC 1D03 BTFSS 0x3, 0x2 3AD 2BAF GOTO 0x3af 3AE 2BB0 GOTO 0x3b0 3AF 2BB8 GOTO 0x3b8 59: return 0.0; 3B0 3000 MOVLW 0 3B1 00A0 MOVWF 0x20 3B2 3000 MOVLW 0 3B3 00A1 MOVWF 0x21 3B4 3000 MOVLW 0 3B5 00A2 MOVWF 0x22 3B6 2C6F GOTO 0x46f 3B7 2C6F GOTO 0x46f 60: exp += exp2-127-6; // compute new exponent 3B8 082F MOVF 0x2f, W 3B9 3E7B ADDLW 0x7b 3BA 00A6 MOVWF 0x26 3BB 0826 MOVF 0x26, W 3BC 07AA ADDWF 0x2a, F 61: sign = f1_as_plier >> 16; 3BD 0820 MOVF 0x20, W 3BE 00A6 MOVWF 0x26 3BF 0821 MOVF 0x21, W 3C0 00A7 MOVWF 0x27 3C1 0822 MOVF 0x22, W 3C2 00A8 MOVWF 0x28 3C3 3010 MOVLW 0x10 3C4 1003 BCF 0x3, 0 3C5 0CA8 RRF 0x28, F 3C6 0CA7 RRF 0x27, F 3C7 0CA6 RRF 0x26, F 3C8 3EFF ADDLW 0xff 3C9 1D03 BTFSS 0x3, 0x2 3CA 2BC4 GOTO 0x3c4 3CB 0826 MOVF 0x26, W 3CC 00A9 MOVWF 0x29 3CD 0829 MOVF 0x29, W 3CE 00AF MOVWF 0x2f 62: sign ^= (unsigned char)(f2_as_plicand >> 16); 3CF 0823 MOVF 0x23, W 3D0 00A6 MOVWF 0x26 3D1 0824 MOVF 0x24, W 3D2 00A7 MOVWF 0x27 3D3 0825 MOVF 0x25, W 3D4 00A8 MOVWF 0x28 3D5 3010 MOVLW 0x10 3D6 1003 BCF 0x3, 0 3D7 0CA8 RRF 0x28, F 3D8 0CA7 RRF 0x27, F 3D9 0CA6 RRF 0x26, F 3DA 3EFF ADDLW 0xff 3DB 1D03 BTFSS 0x3, 0x2 3DC 2BD6 GOTO 0x3d6 3DD 0826 MOVF 0x26, W 3DE 00A9 MOVWF 0x29 3DF 0829 MOVF 0x29, W 3E0 06AF XORWF 0x2f, F 63: sign &= 0x80; 3E1 3080 MOVLW 0x80 3E2 00A6 MOVWF 0x26 3E3 0826 MOVF 0x26, W 3E4 05AF ANDWF 0x2f, F 64: f1_as_plier |= 0x8000UL; 3E5 17A1 BSF 0x21, 0x7 65: //f1_as_plier &= 0xFFFFUL; // not required 66: f2_as_plicand |= 0x8000UL; 3E6 17A4 BSF 0x24, 0x7 67: f2_as_plicand &= 0xFFFFUL; 3E7 30FF MOVLW 0xff 3E8 05A3 ANDWF 0x23, F 3E9 30FF MOVLW 0xff 3EA 05A4 ANDWF 0x24, F 3EB 3000 MOVLW 0 3EC 05A5 ANDWF 0x25, F 68: f3_as_product = 0; 3ED 3000 MOVLW 0 3EE 00AB MOVWF 0x2b 3EF 3000 MOVLW 0 3F0 00AC MOVWF 0x2c 3F1 3000 MOVLW 0 3F2 00AD MOVWF 0x2d 69: cntr = 7; 3F3 3007 MOVLW 0x7 3F4 00A6 MOVWF 0x26 3F5 0826 MOVF 0x26, W 3F6 00AE MOVWF 0x2e 3F7 2BF8 GOTO 0x3f8 70: do { 71: if(f1_as_plier & 1) 3F8 1C20 BTFSS 0x20, 0 3F9 2BFB GOTO 0x3fb 3FA 2BFC GOTO 0x3fc 3FB 2C0D GOTO 0x40d 72: f3_as_product += f2_as_plicand; 3FC 0823 MOVF 0x23, W 3FD 07AB ADDWF 0x2b, F 3FE 0824 MOVF 0x24, W 3FF 1103 BCF 0x3, 0x2 400 1803 BTFSC 0x3, 0 401 0A24 INCF 0x24, W 402 1903 BTFSC 0x3, 0x2 403 2C05 GOTO 0x405 404 07AC ADDWF 0x2c, F 405 0825 MOVF 0x25, W 406 1103 BCF 0x3, 0x2 407 1803 BTFSC 0x3, 0 408 0A25 INCF 0x25, W 409 1903 BTFSC 0x3, 0x2 40A 2C0C GOTO 0x40c 40B 07AD ADDWF 0x2d, F 40C 2C0D GOTO 0x40d 73: f1_as_plier >>= 1; 40D 3001 MOVLW 0x1 40E 1003 BCF 0x3, 0 40F 0CA2 RRF 0x22, F 410 0CA1 RRF 0x21, F 411 0CA0 RRF 0x20, F 412 3EFF ADDLW 0xff 413 1D03 BTFSS 0x3, 0x2 414 2C0E GOTO 0x40e 74: f2_as_plicand <<= 1; 415 3001 MOVLW 0x1 416 1003 BCF 0x3, 0 417 0DA3 RLF 0x23, F 418 0DA4 RLF 0x24, F 419 0DA5 RLF 0x25, F 41A 3EFF ADDLW 0xff 41B 1D03 BTFSS 0x3, 0x2 41C 2C16 GOTO 0x416 75: } while(--cntr != 0); 41D 3001 MOVLW 0x1 41E 02AE SUBWF 0x2e, F 41F 1D03 BTFSS 0x3, 0x2 420 2C22 GOTO 0x422 421 2C23 GOTO 0x423 422 2BF8 GOTO 0x3f8 423 2C24 GOTO 0x424 76: cntr = 9; 424 3009 MOVLW 0x9 425 00A6 MOVWF 0x26 426 0826 MOVF 0x26, W 427 00AE MOVWF 0x2e 428 2C29 GOTO 0x429 77: do { 78: if(f1_as_plier & 1) 429 1C20 BTFSS 0x20, 0 42A 2C2C GOTO 0x42c 42B 2C2D GOTO 0x42d 42C 2C3E GOTO 0x43e 79: f3_as_product += f2_as_plicand; 42D 0823 MOVF 0x23, W 42E 07AB ADDWF 0x2b, F 42F 0824 MOVF 0x24, W 430 1103 BCF 0x3, 0x2 431 1803 BTFSC 0x3, 0 432 0A24 INCF 0x24, W 433 1903 BTFSC 0x3, 0x2 434 2C36 GOTO 0x436 435 07AC ADDWF 0x2c, F 436 0825 MOVF 0x25, W 437 1103 BCF 0x3, 0x2 438 1803 BTFSC 0x3, 0 439 0A25 INCF 0x25, W 43A 1903 BTFSC 0x3, 0x2 43B 2C3D GOTO 0x43d 43C 07AD ADDWF 0x2d, F 43D 2C3E GOTO 0x43e 80: f1_as_plier >>= 1; 43E 3001 MOVLW 0x1 43F 1003 BCF 0x3, 0 440 0CA2 RRF 0x22, F 441 0CA1 RRF 0x21, F 442 0CA0 RRF 0x20, F 443 3EFF ADDLW 0xff 444 1D03 BTFSS 0x3, 0x2 445 2C3F GOTO 0x43f 81: f3_as_product >>= 1; 446 3001 MOVLW 0x1 447 1003 BCF 0x3, 0 448 0CAD RRF 0x2d, F 449 0CAC RRF 0x2c, F 44A 0CAB RRF 0x2b, F 44B 3EFF ADDLW 0xff 44C 1D03 BTFSS 0x3, 0x2 44D 2C47 GOTO 0x447 82: } while(--cntr != 0); 44E 3001 MOVLW 0x1 44F 02AE SUBWF 0x2e, F 450 1D03 BTFSS 0x3, 0x2 451 2C53 GOTO 0x453 452 2C54 GOTO 0x454 453 2C29 GOTO 0x429 454 2C55 GOTO 0x455 83: return __ftpack(f3_as_product, exp, sign); 455 082B MOVF 0x2b, W 456 00F0 MOVWF 0x70 457 082C MOVF 0x2c, W 458 00F1 MOVWF 0x71 459 082D MOVF 0x2d, W 45A 00F2 MOVWF 0x72 45B 082A MOVF 0x2a, W 45C 00A6 MOVWF 0x26 45D 0826 MOVF 0x26, W 45E 00F3 MOVWF 0x73 45F 082F MOVF 0x2f, W 460 00A7 MOVWF 0x27 461 0827 MOVF 0x27, W 462 00F4 MOVWF 0x74 463 158A BSF 0xa, 0x3 464 26E9 CALL 0x6e9 465 118A BCF 0xa, 0x3 466 0870 MOVF 0x70, W 467 1283 BCF 0x3, 0x5 468 1303 BCF 0x3, 0x6 469 00A0 MOVWF 0x20 46A 0871 MOVF 0x71, W 46B 00A1 MOVWF 0x21 46C 0872 MOVF 0x72, W 46D 00A2 MOVWF 0x22 46E 2C6F GOTO 0x46f 84: } 46F 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftneg.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define mant1 (*(unsigned short long *)&f1) 11: 12: // Negate a float 13: 14: float 15: __ftneg(float f1) 16: { 17: if(f1 != 0) CD5 0872 MOVF 0x72, W CD6 0471 IORWF 0x71, W CD7 0470 IORWF 0x70, W CD8 1903 BTFSC 0x3, 0x2 CD9 2CDB GOTO 0x4db CDA 2CDC GOTO 0x4dc CDB 2CDF GOTO 0x4df 18: mant1 ^= 0x800000UL; CDC 3080 MOVLW 0x80 CDD 06F2 XORWF 0x72, F CDE 2CDF GOTO 0x4df 19: return f1; CDF 2CE0 GOTO 0x4e0 20: } CE0 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\ftsub.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define f1_as_mant1 (*(unsigned short long *)&f1) 11: #define f2_as_mant2 (*(unsigned short long *)&f2) 12: 13: // floating addition 14: 15: float 16: __ftsub(float f2, float f1) 17: { 18: f2_as_mant2 ^= 0x800000; CFE 3080 MOVLW 0x80 CFF 1283 BCF 0x3, 0x5 D00 1303 BCF 0x3, 0x6 D01 06BF XORWF 0x3f, F 19: return __ftadd(f1, f2); D02 0840 MOVF 0x40, W D03 00B0 MOVWF 0x30 D04 0841 MOVF 0x41, W D05 00B1 MOVWF 0x31 D06 0842 MOVF 0x42, W D07 00B2 MOVWF 0x32 D08 083D MOVF 0x3d, W D09 00B3 MOVWF 0x33 D0A 083E MOVF 0x3e, W D0B 00B4 MOVWF 0x34 D0C 083F MOVF 0x3f, W D0D 00B5 MOVWF 0x35 D0E 118A BCF 0xa, 0x3 D0F 2567 CALL 0x567 D10 158A BSF 0xa, 0x3 D11 1283 BCF 0x3, 0x5 D12 1303 BCF 0x3, 0x6 D13 0830 MOVF 0x30, W D14 00BD MOVWF 0x3d D15 0831 MOVF 0x31, W D16 00BE MOVWF 0x3e D17 0832 MOVF 0x32, W D18 00BF MOVWF 0x3f D19 2D1A GOTO 0x51a 20: } D1A 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\fttol.c -------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: #define f1_as_mant1 (*(unsigned short long *)&f1) 11: 12: // Convert float to long 13: 14: #ifdef _OLDLIB 15: long 16: __fttol(float f1) 17: { 18: unsigned char sign1, exp1; 19: unsigned long lval; 20: 21: sign1 = __ftunpack(&f1_as_mant1, &exp1); 22: lval = f1_as_mant1; 23: exp1 -= 127+15; 24: if((signed char)exp1 < 0) { 25: if((signed char)exp1 < -15) 26: return 0; 27: do 28: lval >>= 1; 29: while(++exp1 != 0); 30: } else { 31: if(exp1 >= 32) 32: return 00; 33: while(exp1 != 0) { 34: lval <<= 1; 35: exp1--; 36: } 37: } 38: if(sign1) 39: lval = -lval; 40: return lval; 41: } 42: #else 43: long 44: __fttol(float f1) 45: { 46: unsigned char sign1, exp1; 47: unsigned long lval; 48: 49: if((exp1 = f1_as_mant1 >> 15) == 0) 092 0870 MOVF 0x70, W 093 00F4 MOVWF 0x74 094 0871 MOVF 0x71, W 095 00F5 MOVWF 0x75 096 0872 MOVF 0x72, W 097 00F6 MOVWF 0x76 098 1003 BCF 0x3, 0 099 0D75 RLF 0x75, W 09A 0D76 RLF 0x76, W 09B 00F7 MOVWF 0x77 09C 0877 MOVF 0x77, W 09D 00FD MOVWF 0x7d 09E 08FD MOVF 0x7d, F 09F 1D03 BTFSS 0x3, 0x2 0A0 28A2 GOTO 0xa2 0A1 28A3 GOTO 0xa3 0A2 28AD GOTO 0xad 50: return 0; 0A3 3000 MOVLW 0 0A4 00F3 MOVWF 0x73 0A5 3000 MOVLW 0 0A6 00F2 MOVWF 0x72 0A7 3000 MOVLW 0 0A8 00F1 MOVWF 0x71 0A9 3000 MOVLW 0 0AA 00F0 MOVWF 0x70 0AB 2935 GOTO 0x135 0AC 2935 GOTO 0x135 51: sign1 = f1_as_mant1 >> 23; 0AD 0870 MOVF 0x70, W 0AE 00F4 MOVWF 0x74 0AF 0871 MOVF 0x71, W 0B0 00F5 MOVWF 0x75 0B1 0872 MOVF 0x72, W 0B2 00F6 MOVWF 0x76 0B3 3017 MOVLW 0x17 0B4 1003 BCF 0x3, 0 0B5 0CF6 RRF 0x76, F 0B6 0CF5 RRF 0x75, F 0B7 0CF4 RRF 0x74, F 0B8 3EFF ADDLW 0xff 0B9 1D03 BTFSS 0x3, 0x2 0BA 28B4 GOTO 0xb4 0BB 0874 MOVF 0x74, W 0BC 00F7 MOVWF 0x77 0BD 0877 MOVF 0x77, W 0BE 00F8 MOVWF 0x78 52: f1_as_mant1 |= 0x8000UL; 0BF 17F1 BSF 0x71, 0x7 53: f1_as_mant1 &= 0xFFFFUL; 0C0 30FF MOVLW 0xff 0C1 05F0 ANDWF 0x70, F 0C2 30FF MOVLW 0xff 0C3 05F1 ANDWF 0x71, F 0C4 3000 MOVLW 0 0C5 05F2 ANDWF 0x72, F 54: lval = f1_as_mant1; 0C6 0870 MOVF 0x70, W 0C7 00F9 MOVWF 0x79 0C8 0871 MOVF 0x71, W 0C9 00FA MOVWF 0x7a 0CA 0872 MOVF 0x72, W 0CB 00FB MOVWF 0x7b 0CC 01FC CLRF 0x7c 55: exp1 -= 127+15; 0CD 308E MOVLW 0x8e 0CE 02FD SUBWF 0x7d, F 56: if((signed char)exp1 < 0) { 0CF 1FFD BTFSS 0x7d, 0x7 0D0 28D2 GOTO 0xd2 0D1 28D3 GOTO 0xd3 0D2 28F8 GOTO 0xf8 57: if((signed char)exp1 < -15) 0D3 087D MOVF 0x7d, W 0D4 3A80 XORLW 0x80 0D5 3E8F ADDLW 0x8f 0D6 1803 BTFSC 0x3, 0 0D7 28D9 GOTO 0xd9 0D8 28DA GOTO 0xda 0D9 28E5 GOTO 0xe5 58: return 0; 0DA 3000 MOVLW 0 0DB 00F3 MOVWF 0x73 0DC 3000 MOVLW 0 0DD 00F2 MOVWF 0x72 0DE 3000 MOVLW 0 0DF 00F1 MOVWF 0x71 0E0 3000 MOVLW 0 0E1 00F0 MOVWF 0x70 0E2 2935 GOTO 0x135 0E3 2935 GOTO 0x135 0E4 28E5 GOTO 0xe5 59: do 60: lval >>= 1; 0E5 3001 MOVLW 0x1 0E6 1003 BCF 0x3, 0 0E7 0CFC RRF 0x7c, F 0E8 0CFB RRF 0x7b, F 0E9 0CFA RRF 0x7a, F 0EA 0CF9 RRF 0x79, F 0EB 3EFF ADDLW 0xff 0EC 1D03 BTFSS 0x3, 0x2 0ED 28E6 GOTO 0xe6 61: while(++exp1 != 0); 0EE 3001 MOVLW 0x1 0EF 00F4 MOVWF 0x74 0F0 0874 MOVF 0x74, W 0F1 07FD ADDWF 0x7d, F 0F2 1D03 BTFSS 0x3, 0x2 0F3 28F5 GOTO 0xf5 0F4 28F6 GOTO 0xf6 0F5 28E5 GOTO 0xe5 0F6 291C GOTO 0x11c 62: } else { 0F7 291C GOTO 0x11c 63: if(exp1 >= 24) 0F8 3018 MOVLW 0x18 0F9 027D SUBWF 0x7d, W 0FA 1C03 BTFSS 0x3, 0 0FB 28FD GOTO 0xfd 0FC 28FE GOTO 0xfe 0FD 2915 GOTO 0x115 64: return 0; 0FE 3000 MOVLW 0 0FF 00F3 MOVWF 0x73 100 3000 MOVLW 0 101 00F2 MOVWF 0x72 102 3000 MOVLW 0 103 00F1 MOVWF 0x71 104 3000 MOVLW 0 105 00F0 MOVWF 0x70 106 2935 GOTO 0x135 107 2935 GOTO 0x135 65: while(exp1 != 0) { 108 2915 GOTO 0x115 115 08FD MOVF 0x7d, F 116 1D03 BTFSS 0x3, 0x2 117 2919 GOTO 0x119 118 291A GOTO 0x11a 119 2909 GOTO 0x109 11A 291C GOTO 0x11c 11B 291C GOTO 0x11c 66: lval <<= 1; 109 3001 MOVLW 0x1 10A 00F4 MOVWF 0x74 10B 1003 BCF 0x3, 0 10C 0DF9 RLF 0x79, F 10D 0DFA RLF 0x7a, F 10E 0DFB RLF 0x7b, F 10F 0DFC RLF 0x7c, F 110 0BF4 DECFSZ 0x74, F 111 290B GOTO 0x10b 67: exp1--; 112 3001 MOVLW 0x1 113 02FD SUBWF 0x7d, F 114 2915 GOTO 0x115 68: } 69: } 70: if(sign1) 11C 0878 MOVF 0x78, W 11D 1D03 BTFSS 0x3, 0x2 11E 2920 GOTO 0x120 11F 292C GOTO 0x12c 71: lval = -lval; 120 09F9 COMF 0x79, F 121 09FA COMF 0x7a, F 122 09FB COMF 0x7b, F 123 09FC COMF 0x7c, F 124 0AF9 INCF 0x79, F 125 1903 BTFSC 0x3, 0x2 126 0AFA INCF 0x7a, F 127 1903 BTFSC 0x3, 0x2 128 0AFB INCF 0x7b, F 129 1903 BTFSC 0x3, 0x2 12A 0AFC INCF 0x7c, F 12B 292C GOTO 0x12c 72: return lval; 12C 087C MOVF 0x7c, W 12D 00F3 MOVWF 0x73 12E 087B MOVF 0x7b, W 12F 00F2 MOVWF 0x72 130 087A MOVF 0x7a, W 131 00F1 MOVWF 0x71 132 0879 MOVF 0x79, W 133 00F0 MOVWF 0x70 134 2935 GOTO 0x135 73: } 135 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\lltoft.c ------------------------------- 1: /* Floating point routines. 2: 3: Copyright (C) 2006 HI-TECH Software 4: */ 5: 6: // this is bigendian code right now. Need to parameterise it. 7: 8: #include "ftarith.h" 9: 10: 11: // Convert unsigned long int to float 12: 13: #ifdef _OLDLIB 14: #define f1_as_mant1 (*(unsigned short long *)&f1) 15: float 16: __lltoft(unsigned long int c) 17: { 18: float f1; 19: unsigned char exp; 20: 21: if(c == 0) 22: return 0.0; 23: exp = 127+15; 24: // normalize 32 bits to 24 first 25: while(c & ~0xFFFFFFUL) { 26: c >>= 1; 27: exp++; 28: } 29: f1_as_mant1 = c; 30: __ftpack(&f1_as_mant1, exp); 31: return f1; 32: } 33: #else 34: float 35: __lltoft(unsigned long int c) 36: { 37: unsigned char exp; 38: exp = 127+15; D45 308E MOVLW 0x8e D46 00FC MOVWF 0x7c D47 087C MOVF 0x7c, W D48 00FD MOVWF 0x7d 39: 40: // normalize 32 bits to 24 first 41: while(c & ~0xFFFFFFUL) { D49 2D58 GOTO 0x558 D58 30FF MOVLW 0xff D59 057B ANDWF 0x7b, W D5A 1D03 BTFSS 0x3, 0x2 D5B 2D5D GOTO 0x55d D5C 2D5E GOTO 0x55e D5D 2D4A GOTO 0x54a D5E 2D5F GOTO 0x55f 42: c >>= 1; D4A 3001 MOVLW 0x1 D4B 1003 BCF 0x3, 0 D4C 0CFB RRF 0x7b, F D4D 0CFA RRF 0x7a, F D4E 0CF9 RRF 0x79, F D4F 0CF8 RRF 0x78, F D50 3EFF ADDLW 0xff D51 1D03 BTFSS 0x3, 0x2 D52 2D4B GOTO 0x54b 43: exp++; D53 3001 MOVLW 0x1 D54 00FC MOVWF 0x7c D55 087C MOVF 0x7c, W D56 07FD ADDWF 0x7d, F D57 2D58 GOTO 0x558 44: } 45: return __ftpack((unsigned short long)c, exp, 0); D5F 0878 MOVF 0x78, W D60 00F0 MOVWF 0x70 D61 0879 MOVF 0x79, W D62 00F1 MOVWF 0x71 D63 087A MOVF 0x7a, W D64 00F2 MOVWF 0x72 D65 087D MOVF 0x7d, W D66 00FC MOVWF 0x7c D67 087C MOVF 0x7c, W D68 00F3 MOVWF 0x73 D69 1003 BCF 0x3, 0 D6A 3000 MOVLW 0 D6B 1803 BTFSC 0x3, 0 D6C 3001 MOVLW 0x1 D6D 00F4 MOVWF 0x74 D6E 158A BSF 0xa, 0x3 D6F 26E9 CALL 0x6e9 D70 158A BSF 0xa, 0x3 D71 0870 MOVF 0x70, W D72 00F8 MOVWF 0x78 D73 0871 MOVF 0x71, W D74 00F9 MOVWF 0x79 D75 0872 MOVF 0x72, W D76 00FA MOVWF 0x7a D77 2D78 GOTO 0x578 46: } D78 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\log.c ---------------------------------- 1: #include 2: #include 3: 4: double 5: log(double x) 6: { 7: int exp; 8: 9: static const double coeff[] = 824 3400 RETLW 0 10: { 11: 0.0000000000, /* a0 */ 12: 0.9999964239, /* a1 */ 13: -0.4998741238, /* a2 */ 14: 0.3317990258, /* a3 */ 15: -0.2407338084, /* a4 */ 16: 0.1676540711, /* a5 */ 17: -0.0953293897, /* a6 */ 18: 0.0360884937, /* a7 */ 19: -0.0064535442, /* a8 */ 20: }; 21: 22: /* zero or -ve arguments are not defined */ 23: 24: if(x < 0.0) { 2BB 1283 BCF 0x3, 0x5 2BC 1303 BCF 0x3, 0x6 2BD 0851 MOVF 0x51, W 2BE 00F0 MOVWF 0x70 2BF 0852 MOVF 0x52, W 2C0 00F1 MOVWF 0x71 2C1 0853 MOVF 0x53, W 2C2 00F2 MOVWF 0x72 2C3 3000 MOVLW 0 2C4 00F3 MOVWF 0x73 2C5 3000 MOVLW 0 2C6 00F4 MOVWF 0x74 2C7 3000 MOVLW 0 2C8 00F5 MOVWF 0x75 2C9 158A BSF 0xa, 0x3 2CA 267D CALL 0x67d 2CB 118A BCF 0xa, 0x3 2CC 1803 BTFSC 0x3, 0 2CD 2ACF GOTO 0x2cf 2CE 2AD0 GOTO 0x2d0 2CF 2AE0 GOTO 0x2e0 25: errno = EDOM; 2D0 3021 MOVLW 0x21 2D1 1683 BSF 0x3, 0x5 2D2 1303 BCF 0x3, 0x6 2D3 00BE MOVWF 0x3e 2D4 3000 MOVLW 0 2D5 00BF MOVWF 0x3f 26: return 0.0; 2D6 3000 MOVLW 0 2D7 1283 BCF 0x3, 0x5 2D8 1303 BCF 0x3, 0x6 2D9 00D1 MOVWF 0x51 2DA 3000 MOVLW 0 2DB 00D2 MOVWF 0x52 2DC 3000 MOVLW 0 2DD 00D3 MOVWF 0x53 2DE 2B83 GOTO 0x383 2DF 2B83 GOTO 0x383 27: } 28: if(x == 0.0) { 2E0 1283 BCF 0x3, 0x5 2E1 1303 BCF 0x3, 0x6 2E2 0853 MOVF 0x53, W 2E3 0452 IORWF 0x52, W 2E4 0451 IORWF 0x51, W 2E5 1D03 BTFSS 0x3, 0x2 2E6 2AE8 GOTO 0x2e8 2E7 2AE9 GOTO 0x2e9 2E8 2AF9 GOTO 0x2f9 29: errno = ERANGE; 2E9 3022 MOVLW 0x22 2EA 1683 BSF 0x3, 0x5 2EB 1303 BCF 0x3, 0x6 2EC 00BE MOVWF 0x3e 2ED 3000 MOVLW 0 2EE 00BF MOVWF 0x3f 30: return 0.0; 2EF 3000 MOVLW 0 2F0 1283 BCF 0x3, 0x5 2F1 1303 BCF 0x3, 0x6 2F2 00D1 MOVWF 0x51 2F3 3000 MOVLW 0 2F4 00D2 MOVWF 0x52 2F5 3000 MOVLW 0 2F6 00D3 MOVWF 0x53 2F7 2B83 GOTO 0x383 2F8 2B83 GOTO 0x383 31: } 32: x = frexp(x, &exp) * 2.0 - 1.0; 2F9 3000 MOVLW 0 2FA 00B0 MOVWF 0x30 2FB 3080 MOVLW 0x80 2FC 00B1 MOVWF 0x31 2FD 30BF MOVLW 0xbf 2FE 00B2 MOVWF 0x32 2FF 3000 MOVLW 0 300 00A0 MOVWF 0x20 301 3000 MOVLW 0 302 00A1 MOVWF 0x21 303 3040 MOVLW 0x40 304 00A2 MOVWF 0x22 305 3055 MOVLW 0x55 306 00D4 MOVWF 0x54 307 0854 MOVF 0x54, W 308 00F3 MOVWF 0x73 309 0851 MOVF 0x51, W 30A 00F0 MOVWF 0x70 30B 0852 MOVF 0x52, W 30C 00F1 MOVWF 0x71 30D 0853 MOVF 0x53, W 30E 00F2 MOVWF 0x72 30F 158A BSF 0xa, 0x3 310 2579 CALL 0x579 311 118A BCF 0xa, 0x3 312 0870 MOVF 0x70, W 313 1283 BCF 0x3, 0x5 314 1303 BCF 0x3, 0x6 315 00A3 MOVWF 0x23 316 0871 MOVF 0x71, W 317 00A4 MOVWF 0x24 318 0872 MOVF 0x72, W 319 00A5 MOVWF 0x25 31A 118A BCF 0xa, 0x3 31B 2384 CALL 0x384 31C 118A BCF 0xa, 0x3 31D 1283 BCF 0x3, 0x5 31E 1303 BCF 0x3, 0x6 31F 0820 MOVF 0x20, W 320 00B3 MOVWF 0x33 321 0821 MOVF 0x21, W 322 00B4 MOVWF 0x34 323 0822 MOVF 0x22, W 324 00B5 MOVWF 0x35 325 118A BCF 0xa, 0x3 326 2567 CALL 0x567 327 118A BCF 0xa, 0x3 328 1283 BCF 0x3, 0x5 329 1303 BCF 0x3, 0x6 32A 0830 MOVF 0x30, W 32B 00D1 MOVWF 0x51 32C 0831 MOVF 0x31, W 32D 00D2 MOVWF 0x52 32E 0832 MOVF 0x32, W 32F 00D3 MOVWF 0x53 33: exp--; 330 30FF MOVLW 0xff 331 07D5 ADDWF 0x55, F 332 1803 BTFSC 0x3, 0 333 0AD6 INCF 0x56, F 334 30FF MOVLW 0xff 335 07D6 ADDWF 0x56, F 34: x = eval_poly(x, coeff, sizeof coeff/sizeof coeff[0] - 1); 336 0851 MOVF 0x51, W 337 00C7 MOVWF 0x47 338 0852 MOVF 0x52, W 339 00C8 MOVWF 0x48 33A 0853 MOVF 0x53, W 33B 00C9 MOVWF 0x49 33C 301F MOVLW 0x1f 33D 00D4 MOVWF 0x54 33E 0854 MOVF 0x54, W 33F 00CA MOVWF 0x4a 340 3008 MOVLW 0x8 341 00CB MOVWF 0x4b 342 3000 MOVLW 0 343 00CC MOVWF 0x4c 344 158A BSF 0xa, 0x3 345 2612 CALL 0x612 346 118A BCF 0xa, 0x3 347 1283 BCF 0x3, 0x5 348 1303 BCF 0x3, 0x6 349 0847 MOVF 0x47, W 34A 00D1 MOVWF 0x51 34B 0848 MOVF 0x48, W 34C 00D2 MOVWF 0x52 34D 0849 MOVF 0x49, W 34E 00D3 MOVWF 0x53 35: return x + 0.69314718055995 * exp; 34F 0851 MOVF 0x51, W 350 00B0 MOVWF 0x30 351 0852 MOVF 0x52, W 352 00B1 MOVWF 0x31 353 0853 MOVF 0x53, W 354 00B2 MOVWF 0x32 355 3072 MOVLW 0x72 356 00A0 MOVWF 0x20 357 3031 MOVLW 0x31 358 00A1 MOVWF 0x21 359 303F MOVLW 0x3f 35A 00A2 MOVWF 0x22 35B 0856 MOVF 0x56, W 35C 01F9 CLRF 0x79 35D 07F9 ADDWF 0x79, F 35E 0855 MOVF 0x55, W 35F 01F8 CLRF 0x78 360 07F8 ADDWF 0x78, F 361 158A BSF 0xa, 0x3 362 251B CALL 0x51b 363 118A BCF 0xa, 0x3 364 0878 MOVF 0x78, W 365 1283 BCF 0x3, 0x5 366 1303 BCF 0x3, 0x6 367 00A3 MOVWF 0x23 368 0879 MOVF 0x79, W 369 00A4 MOVWF 0x24 36A 087A MOVF 0x7a, W 36B 00A5 MOVWF 0x25 36C 118A BCF 0xa, 0x3 36D 2384 CALL 0x384 36E 118A BCF 0xa, 0x3 36F 1283 BCF 0x3, 0x5 370 1303 BCF 0x3, 0x6 371 0820 MOVF 0x20, W 372 00B3 MOVWF 0x33 373 0821 MOVF 0x21, W 374 00B4 MOVWF 0x34 375 0822 MOVF 0x22, W 376 00B5 MOVWF 0x35 377 118A BCF 0xa, 0x3 378 2567 CALL 0x567 379 118A BCF 0xa, 0x3 37A 1283 BCF 0x3, 0x5 37B 1303 BCF 0x3, 0x6 37C 0830 MOVF 0x30, W 37D 00D1 MOVWF 0x51 37E 0831 MOVF 0x31, W 37F 00D2 MOVWF 0x52 380 0832 MOVF 0x32, W 381 00D3 MOVWF 0x53 382 2B83 GOTO 0x383 36: } 383 0008 RETURN --- C:\Program Files\HI-TECH Software\PICC\9.80\sources\pow.c ---------------------------------- 1: #include 2: #include 3: 4: double 5: pow(double x, double y) 6: { 7: unsigned char sign = 0; 470 1003 BCF 0x3, 0 471 3000 MOVLW 0 472 1803 BTFSC 0x3, 0 473 3001 MOVLW 0x1 474 1283 BCF 0x3, 0x5 475 1303 BCF 0x3, 0x6 476 00EB MOVWF 0x6b 8: unsigned long yi; 9: 10: if(x == 0.0) { 477 0863 MOVF 0x63, W 478 0462 IORWF 0x62, W 479 0461 IORWF 0x61, W 47A 1D03 BTFSS 0x3, 0x2 47B 2C7D GOTO 0x47d 47C 2C7E GOTO 0x47e 47D 2CA1 GOTO 0x4a1 11: if (y <= 0.0) { 47E 3000 MOVLW 0 47F 00F0 MOVWF 0x70 480 3000 MOVLW 0 481 00F1 MOVWF 0x71 482 3000 MOVLW 0 483 00F2 MOVWF 0x72 484 0864 MOVF 0x64, W 485 00F3 MOVWF 0x73 486 0865 MOVF 0x65, W 487 00F4 MOVWF 0x74 488 0866 MOVF 0x66, W 489 00F5 MOVWF 0x75 48A 158A BSF 0xa, 0x3 48B 267D CALL 0x67d 48C 118A BCF 0xa, 0x3 48D 1C03 BTFSS 0x3, 0 48E 2C90 GOTO 0x490 48F 2C91 GOTO 0x491 490 2C97 GOTO 0x497 12: errno = EDOM; 491 3021 MOVLW 0x21 492 1683 BSF 0x3, 0x5 493 1303 BCF 0x3, 0x6 494 00BE MOVWF 0x3e 495 3000 MOVLW 0 496 00BF MOVWF 0x3f 13: } 14: return 0.0; 497 3000 MOVLW 0 498 1283 BCF 0x3, 0x5 499 1303 BCF 0x3, 0x6 49A 00E1 MOVWF 0x61 49B 3000 MOVLW 0 49C 00E2 MOVWF 0x62 49D 3000 MOVLW 0 49E 00E3 MOVWF 0x63 49F 2D66 GOTO 0x566 4A0 2D66 GOTO 0x566 15: } 16: if(y == 0.0) 4A1 0866 MOVF 0x66, W 4A2 0465 IORWF 0x65, W 4A3 0464 IORWF 0x64, W 4A4 1D03 BTFSS 0x3, 0x2 4A5 2CA7 GOTO 0x4a7 4A6 2CA8 GOTO 0x4a8 4A7 2CB0 GOTO 0x4b0 17: return 1.0; 4A8 3000 MOVLW 0 4A9 00E1 MOVWF 0x61 4AA 3080 MOVLW 0x80 4AB 00E2 MOVWF 0x62 4AC 303F MOVLW 0x3f 4AD 00E3 MOVWF 0x63 4AE 2D66 GOTO 0x566 4AF 2D66 GOTO 0x566 18: if(x < 0.0) { 4B0 0861 MOVF 0x61, W 4B1 00F0 MOVWF 0x70 4B2 0862 MOVF 0x62, W 4B3 00F1 MOVWF 0x71 4B4 0863 MOVF 0x63, W 4B5 00F2 MOVWF 0x72 4B6 3000 MOVLW 0 4B7 00F3 MOVWF 0x73 4B8 3000 MOVLW 0 4B9 00F4 MOVWF 0x74 4BA 3000 MOVLW 0 4BB 00F5 MOVWF 0x75 4BC 158A BSF 0xa, 0x3 4BD 267D CALL 0x67d 4BE 118A BCF 0xa, 0x3 4BF 1803 BTFSC 0x3, 0 4C0 2CC2 GOTO 0x4c2 4C1 2CC3 GOTO 0x4c3 4C2 2D1A GOTO 0x51a 19: yi = (unsigned long)y; 4C3 1283 BCF 0x3, 0x5 4C4 1303 BCF 0x3, 0x6 4C5 0864 MOVF 0x64, W 4C6 00F0 MOVWF 0x70 4C7 0865 MOVF 0x65, W 4C8 00F1 MOVWF 0x71 4C9 0866 MOVF 0x66, W 4CA 00F2 MOVWF 0x72 4CB 118A BCF 0xa, 0x3 4CC 2092 CALL 0x92 4CD 118A BCF 0xa, 0x3 4CE 0873 MOVF 0x73, W 4CF 1283 BCF 0x3, 0x5 4D0 1303 BCF 0x3, 0x6 4D1 00EF MOVWF 0x6f 4D2 0872 MOVF 0x72, W 4D3 00EE MOVWF 0x6e 4D4 0871 MOVF 0x71, W 4D5 00ED MOVWF 0x6d 4D6 0870 MOVF 0x70, W 4D7 00EC MOVWF 0x6c 20: if(yi != y) { 4D8 086F MOVF 0x6f, W 4D9 00FB MOVWF 0x7b 4DA 086E MOVF 0x6e, W 4DB 00FA MOVWF 0x7a 4DC 086D MOVF 0x6d, W 4DD 00F9 MOVWF 0x79 4DE 086C MOVF 0x6c, W 4DF 00F8 MOVWF 0x78 4E0 158A BSF 0xa, 0x3 4E1 2545 CALL 0x545 4E2 118A BCF 0xa, 0x3 4E3 1283 BCF 0x3, 0x5 4E4 1303 BCF 0x3, 0x6 4E5 0866 MOVF 0x66, W 4E6 067A XORWF 0x7a, W 4E7 1D03 BTFSS 0x3, 0x2 4E8 2CEF GOTO 0x4ef 4E9 0865 MOVF 0x65, W 4EA 0679 XORWF 0x79, W 4EB 1D03 BTFSS 0x3, 0x2 4EC 2CEF GOTO 0x4ef 4ED 0864 MOVF 0x64, W 4EE 0678 XORWF 0x78, W 4EF 1903 BTFSC 0x3, 0x2 4F0 2CF2 GOTO 0x4f2 4F1 2CF3 GOTO 0x4f3 4F2 2D03 GOTO 0x503 21: errno = EDOM; 4F3 3021 MOVLW 0x21 4F4 1683 BSF 0x3, 0x5 4F5 1303 BCF 0x3, 0x6 4F6 00BE MOVWF 0x3e 4F7 3000 MOVLW 0 4F8 00BF MOVWF 0x3f 22: return 0.0; 4F9 3000 MOVLW 0 4FA 1283 BCF 0x3, 0x5 4FB 1303 BCF 0x3, 0x6 4FC 00E1 MOVWF 0x61 4FD 3000 MOVLW 0 4FE 00E2 MOVWF 0x62 4FF 3000 MOVLW 0 500 00E3 MOVWF 0x63 501 2D66 GOTO 0x566 502 2D66 GOTO 0x566 23: } 24: sign = yi & 1; 503 086C MOVF 0x6c, W 504 3901 ANDLW 0x1 505 00E7 MOVWF 0x67 506 0867 MOVF 0x67, W 507 00EB MOVWF 0x6b 25: x = -x; 508 0861 MOVF 0x61, W 509 00F0 MOVWF 0x70 50A 0862 MOVF 0x62, W 50B 00F1 MOVWF 0x71 50C 0863 MOVF 0x63, W 50D 00F2 MOVWF 0x72 50E 158A BSF 0xa, 0x3 50F 24D5 CALL 0x4d5 510 118A BCF 0xa, 0x3 511 0870 MOVF 0x70, W 512 1283 BCF 0x3, 0x5 513 1303 BCF 0x3, 0x6 514 00E1 MOVWF 0x61 515 0871 MOVF 0x71, W 516 00E2 MOVWF 0x62 517 0872 MOVF 0x72, W 518 00E3 MOVWF 0x63 519 2D1A GOTO 0x51a 26: } 27: x = exp(log(x) * y); 51A 1283 BCF 0x3, 0x5 51B 1303 BCF 0x3, 0x6 51C 0861 MOVF 0x61, W 51D 00D1 MOVWF 0x51 51E 0862 MOVF 0x62, W 51F 00D2 MOVWF 0x52 520 0863 MOVF 0x63, W 521 00D3 MOVWF 0x53 522 118A BCF 0xa, 0x3 523 22BB CALL 0x2bb 524 118A BCF 0xa, 0x3 525 1283 BCF 0x3, 0x5 526 1303 BCF 0x3, 0x6 527 0851 MOVF 0x51, W 528 00E8 MOVWF 0x68 529 0852 MOVF 0x52, W 52A 00E9 MOVWF 0x69 52B 0853 MOVF 0x53, W 52C 00EA MOVWF 0x6a 52D 0864 MOVF 0x64, W 52E 00A0 MOVWF 0x20 52F 0865 MOVF 0x65, W 530 00A1 MOVWF 0x21 531 0866 MOVF 0x66, W 532 00A2 MOVWF 0x22 533 0868 MOVF 0x68, W 534 00A3 MOVWF 0x23 535 0869 MOVF 0x69, W 536 00A4 MOVWF 0x24 537 086A MOVF 0x6a, W 538 00A5 MOVWF 0x25 539 118A BCF 0xa, 0x3 53A 2384 CALL 0x384 53B 118A BCF 0xa, 0x3 53C 1283 BCF 0x3, 0x5 53D 1303 BCF 0x3, 0x6 53E 0820 MOVF 0x20, W 53F 00D7 MOVWF 0x57 540 0821 MOVF 0x21, W 541 00D8 MOVWF 0x58 542 0822 MOVF 0x22, W 543 00D9 MOVWF 0x59 544 118A BCF 0xa, 0x3 545 26AF CALL 0x6af 546 118A BCF 0xa, 0x3 547 1283 BCF 0x3, 0x5 548 1303 BCF 0x3, 0x6 549 0857 MOVF 0x57, W 54A 00E1 MOVWF 0x61 54B 0858 MOVF 0x58, W 54C 00E2 MOVWF 0x62 54D 0859 MOVF 0x59, W 54E 00E3 MOVWF 0x63 28: if(sign) 54F 086B MOVF 0x6b, W 550 1D03 BTFSS 0x3, 0x2 551 2D53 GOTO 0x553 552 2D66 GOTO 0x566 29: return -x; 553 0861 MOVF 0x61, W 554 00F0 MOVWF 0x70 555 0862 MOVF 0x62, W 556 00F1 MOVWF 0x71 557 0863 MOVF 0x63, W 558 00F2 MOVWF 0x72 559 158A BSF 0xa, 0x3 55A 24D5 CALL 0x4d5 55B 118A BCF 0xa, 0x3 55C 0870 MOVF 0x70, W 55D 1283 BCF 0x3, 0x5 55E 1303 BCF 0x3, 0x6 55F 00E1 MOVWF 0x61 560 0871 MOVF 0x71, W 561 00E2 MOVWF 0x62 562 0872 MOVF 0x72, W 563 00E3 MOVWF 0x63 564 2D66 GOTO 0x566 565 2D66 GOTO 0x566 30: return x; 31: } 566 0008 RETURN --- X:\_C_PIC\690 PIC_C\OK\POW\Lennuk.as ------------------------------------------------------- 1: opt subtitle "HI-TECH Software Omniscient Code Generator (Lite mode) build 6738" 2: 3: opt pagewidth 120 4: 5: opt lm 6: 7: processor 16F690 8: clrc macro 9: bcf 3,0 10: endm 11: clrz macro 12: bcf 3,2 13: endm 14: setc macro 15: bsf 3,0 16: endm 17: setz macro 18: bsf 3,2 19: endm 20: skipc macro 21: btfss 3,0 22: endm 23: skipz macro 24: btfss 3,2 25: endm 26: skipnc macro 27: btfsc 3,0 28: endm 29: skipnz macro 30: btfsc 3,2 31: endm 32: indf equ 0 33: indf0 equ 0 34: pc equ 2 35: pcl equ 2 36: status equ 3 37: fsr equ 4 38: fsr0 equ 4 39: c equ 1 40: z equ 0 41: pclath equ 10 42: # 3 "X:\_C_PIC\690 PIC_C\OK\POW\Lennuk.c" 43: psect config,class=CONFIG,delta=2 ;# 44: # 3 "X:\_C_PIC\690 PIC_C\OK\POW\Lennuk.c" 45: dw 0x3FFC & 0x3FF7 & 0x3FEF & 0x3FFF & 0x3FFF & 0x3FFF & 0x3CFF & 0x3BFF & 0x37FF ;# 46: FNCALL _main,_pow 47: FNCALL _pow,___ftge 48: FNCALL _pow,___fttol 49: FNCALL _pow,___lltoft 50: FNCALL _pow,___ftneg 51: FNCALL _pow,_log 52: FNCALL _pow,___ftmul 53: FNCALL _pow,_exp 54: FNCALL _exp,___ftge 55: FNCALL _exp,___ftneg 56: FNCALL _exp,___ftmul 57: FNCALL _exp,_floor 58: FNCALL _exp,___fttol 59: FNCALL _exp,___awtoft 60: FNCALL _exp,___ftsub 61: FNCALL _exp,_eval_poly 62: FNCALL _exp,_ldexp 63: FNCALL _exp,___ftdiv 64: FNCALL _log,___ftge 65: FNCALL _log,_frexp 66: FNCALL _log,___ftmul 67: FNCALL _log,___ftadd 68: FNCALL _log,_eval_poly 69: FNCALL _log,___awtoft 70: FNCALL _eval_poly,___bmul 71: FNCALL _eval_poly,___ftmul 72: FNCALL _eval_poly,___ftadd 73: FNCALL _floor,_frexp 74: FNCALL _floor,___ftge 75: FNCALL _floor,___fttol 76: FNCALL _floor,___altoft 77: FNCALL _floor,___ftadd 78: FNCALL ___ftsub,___ftadd 79: FNCALL _ldexp,___ftge 80: FNCALL _ldexp,___ftneg 81: FNCALL ___lltoft,___ftpack 82: FNCALL ___altoft,___ftpack 83: FNCALL ___awtoft,___ftpack 84: FNCALL ___ftmul,___ftpack 85: FNCALL ___ftdiv,___ftpack 86: FNCALL ___ftadd,___ftpack 87: FNROOT _main 88: global exp@coeff 89: psect strings,class=STRING,delta=2 90: global __pstrings 91: __pstrings: 92: ; global stringdir,stringtab,__stringbase 93: stringtab: 94: ; String table - string pointers are 1 byte each 95: stringcode:stringdir: 96: movlw high(stringdir) 97: movwf pclath 98: movf fsr,w 99: incf fsr 100: addwf pc 101: __stringbase: 102: retlw 0 103: psect strings 104: file "C:\Program Files\HI-TECH Software\PICC\9.80\sources\exp.c" 105: line 17 106: exp@coeff: 107: retlw 0x0 108: retlw 0x80 109: retlw 0x3f 110: 111: retlw 0x72 112: retlw 0x31 113: retlw 0x3f 114: 115: retlw 0xfe 116: retlw 0x75 117: retlw 0x3e 118: 119: retlw 0x58 120: retlw 0x63 121: retlw 0x3d 122: 123: retlw 0x95 124: retlw 0x1d 125: retlw 0x3c 126: 127: retlw 0xc5 128: retlw 0xae 129: retlw 0x3a 130: 131: retlw 0x79 132: retlw 0x21 133: retlw 0x39 134: 135: retlw 0x94 136: retlw 0x80 137: retlw 0x37 138: 139: retlw 0x93 140: retlw 0xa7 141: retlw 0x35 142: 143: retlw 0x56 144: retlw 0x15 145: retlw 0x34 146: 147: global log@coeff 148: psect strings 149: file "C:\Program Files\HI-TECH Software\PICC\9.80\sources\log.c" 150: line 9 151: log@coeff: 152: retlw 0x0 153: retlw 0x0 154: retlw 0x0 155: 156: retlw 0x0 157: retlw 0x80 158: retlw 0x3f 159: 160: retlw 0xf0 161: retlw 0xff 162: retlw 0xbe 163: 164: retlw 0xe2 165: retlw 0xa9 166: retlw 0x3e 167: 168: retlw 0x83 169: retlw 0x76 170: retlw 0xbe 171: 172: retlw 0xae 173: retlw 0x2b 174: retlw 0x3e 175: 176: retlw 0x3c 177: retlw 0xc3 178: retlw 0xbd 179: 180: retlw 0xd2 181: retlw 0x13 182: retlw 0x3d 183: 184: retlw 0x78 185: retlw 0xd3 186: retlw 0xbb 187: 188: global exp@coeff 189: global log@coeff 190: global _Anurk 191: global _P2 192: global _Pinge 193: global _nurk 194: global _errno 195: global _d10 196: psect nvBANK1,class=BANK1,space=1 197: global __pnvBANK1 198: __pnvBANK1: 199: _d10: 200: ds 3 201: 202: global _d3 203: _d3: 204: ds 3 205: 206: global _d31 207: _d31: 208: ds 3 209: 210: global _dpow 211: _dpow: 212: ds 3 213: 214: global _dpow1 215: _dpow1: 216: ds 3 217: 218: global _pinge 219: _pinge: 220: ds 3 221: 222: file "Lennuk.as" 223: line # 224: psect cinit,class=CODE,delta=2 225: global start_initialization 226: start_initialization: 227: 228: psect bssBANK1,class=BANK1,space=1 229: global __pbssBANK1 230: __pbssBANK1: 231: _Anurk: 232: ds 3 233: 234: _P2: 235: ds 3 236: 237: _Pinge: 238: ds 3 239: 240: _nurk: 241: ds 3 242: 243: _errno: 244: ds 2 245: 246: psect clrtext,class=CODE,delta=2 247: global clear_ram 248: ; Called with FSR containing the base address, and 249: ; W with the last address+1 250: clear_ram: 251: clrwdt ;clear the watchdog before getting into this loop CC3 0064 CLRWDT 252: clrloop: 253: clrf indf ;clear RAM location pointed to by FSR CC4 0180 CLRF 0 254: incf fsr,f ;increment pointer CC5 0A84 INCF 0x4, F 255: xorwf fsr,w ;XOR with final address CC6 0604 XORWF 0x4, W 256: btfsc status,2 ;have we reached the end yet? CC7 1903 BTFSC 0x3, 0x2 257: retlw 0 ;all done for this memory range, return CC8 3400 RETLW 0 258: xorwf fsr,w ;XOR again to restore value CC9 0604 XORWF 0x4, W 259: goto clrloop ;do the next byte CCA 2CC4 GOTO 0x4c4 260: 261: ; Clear objects allocated to BANK1 262: psect cinit,class=CODE,delta=2 263: bcf status, 7 ;select IRP bank0 CCB 1383 BCF 0x3, 0x7 264: movlw low(__pbssBANK1) CCC 30B2 MOVLW 0xb2 265: movwf fsr CCD 0084 MOVWF 0x4 266: movlw low((__pbssBANK1)+0Eh) CCE 30C0 MOVLW 0xc0 267: fcall clear_ram CCF 158A BSF 0xa, 0x3 CD0 24C3 CALL 0x4c3 CD1 158A BSF 0xa, 0x3 268: psect cinit,class=CODE,delta=2 269: global end_of_initialization 270: 271: ;End of C runtime variable initialization code 272: 273: end_of_initialization: 274: clrf status CD2 0183 CLRF 0x3 275: ljmp _main ;jump to C main() function CD3 118A BCF 0xa, 0x3 CD4 2808 GOTO 0x8 --- X:\_C_PIC\690 PIC_C\OK\POW\Lennuk.c -------------------------------------------------------- 1: #include 2: #include 3: __CONFIG(INTIO & WDTDIS & PWRTEN & MCLREN & UNPROTECT & UNPROTECT \ 4: & BORDIS & IESODIS & FCMDIS); 5: double P2, nurk, dpow, d10, d3, dpow1, d31; 6: double pinge, Anurk, Pinge; 7: void main(void){ 8: d10=10.0; 008 3000 MOVLW 0 009 1683 BSF 0x3, 0x5 00A 1303 BCF 0x3, 0x6 00B 00A0 MOVWF 0x20 00C 3020 MOVLW 0x20 00D 00A1 MOVWF 0x21 00E 3041 MOVLW 0x41 00F 00A2 MOVWF 0x22 9: d3=3.0; 010 3000 MOVLW 0 011 00A3 MOVWF 0x23 012 3040 MOVLW 0x40 013 00A4 MOVWF 0x24 014 3040 MOVLW 0x40 015 00A5 MOVWF 0x25 10: dpow=pow(d10, d3); 016 0820 MOVF 0x20, W 017 1283 BCF 0x3, 0x5 018 1303 BCF 0x3, 0x6 019 00E1 MOVWF 0x61 01A 1683 BSF 0x3, 0x5 01B 1303 BCF 0x3, 0x6 01C 0821 MOVF 0x21, W 01D 1283 BCF 0x3, 0x5 01E 1303 BCF 0x3, 0x6 01F 00E2 MOVWF 0x62 020 1683 BSF 0x3, 0x5 021 1303 BCF 0x3, 0x6 022 0822 MOVF 0x22, W 023 1283 BCF 0x3, 0x5 024 1303 BCF 0x3, 0x6 025 00E3 MOVWF 0x63 026 1683 BSF 0x3, 0x5 027 1303 BCF 0x3, 0x6 028 0823 MOVF 0x23, W 029 1283 BCF 0x3, 0x5 02A 1303 BCF 0x3, 0x6 02B 00E4 MOVWF 0x64 02C 1683 BSF 0x3, 0x5 02D 1303 BCF 0x3, 0x6 02E 0824 MOVF 0x24, W 02F 1283 BCF 0x3, 0x5 030 1303 BCF 0x3, 0x6 031 00E5 MOVWF 0x65 032 1683 BSF 0x3, 0x5 033 1303 BCF 0x3, 0x6 034 0825 MOVF 0x25, W 035 1283 BCF 0x3, 0x5 036 1303 BCF 0x3, 0x6 037 00E6 MOVWF 0x66 038 118A BCF 0xa, 0x3 039 2470 CALL 0x470 03A 118A BCF 0xa, 0x3 03B 1283 BCF 0x3, 0x5 03C 1303 BCF 0x3, 0x6 03D 0861 MOVF 0x61, W 03E 1683 BSF 0x3, 0x5 03F 1303 BCF 0x3, 0x6 040 00A9 MOVWF 0x29 041 1283 BCF 0x3, 0x5 042 1303 BCF 0x3, 0x6 043 0862 MOVF 0x62, W 044 1683 BSF 0x3, 0x5 045 1303 BCF 0x3, 0x6 046 00AA MOVWF 0x2a 047 1283 BCF 0x3, 0x5 048 1303 BCF 0x3, 0x6 049 0863 MOVF 0x63, W 04A 1683 BSF 0x3, 0x5 04B 1303 BCF 0x3, 0x6 04C 00AB MOVWF 0x2b 11: d31=2.9999; 04D 30FE MOVLW 0xfe 04E 00A6 MOVWF 0x26 04F 303F MOVLW 0x3f 050 00A7 MOVWF 0x27 051 3040 MOVLW 0x40 052 00A8 MOVWF 0x28 12: dpow1=pow(d10, d31); 053 0820 MOVF 0x20, W 054 1283 BCF 0x3, 0x5 055 1303 BCF 0x3, 0x6 056 00E1 MOVWF 0x61 057 1683 BSF 0x3, 0x5 058 1303 BCF 0x3, 0x6 059 0821 MOVF 0x21, W 05A 1283 BCF 0x3, 0x5 05B 1303 BCF 0x3, 0x6 05C 00E2 MOVWF 0x62 05D 1683 BSF 0x3, 0x5 05E 1303 BCF 0x3, 0x6 05F 0822 MOVF 0x22, W 060 1283 BCF 0x3, 0x5 061 1303 BCF 0x3, 0x6 062 00E3 MOVWF 0x63 063 1683 BSF 0x3, 0x5 064 1303 BCF 0x3, 0x6 065 0826 MOVF 0x26, W 066 1283 BCF 0x3, 0x5 067 1303 BCF 0x3, 0x6 068 00E4 MOVWF 0x64 069 1683 BSF 0x3, 0x5 06A 1303 BCF 0x3, 0x6 06B 0827 MOVF 0x27, W 06C 1283 BCF 0x3, 0x5 06D 1303 BCF 0x3, 0x6 06E 00E5 MOVWF 0x65 06F 1683 BSF 0x3, 0x5 070 1303 BCF 0x3, 0x6 071 0828 MOVF 0x28, W 072 1283 BCF 0x3, 0x5 073 1303 BCF 0x3, 0x6 074 00E6 MOVWF 0x66 075 118A BCF 0xa, 0x3 076 2470 CALL 0x470 077 118A BCF 0xa, 0x3 078 1283 BCF 0x3, 0x5 079 1303 BCF 0x3, 0x6 07A 0861 MOVF 0x61, W 07B 1683 BSF 0x3, 0x5 07C 1303 BCF 0x3, 0x6 07D 00AC MOVWF 0x2c 07E 1283 BCF 0x3, 0x5 07F 1303 BCF 0x3, 0x6 080 0862 MOVF 0x62, W 081 1683 BSF 0x3, 0x5 082 1303 BCF 0x3, 0x6 083 00AD MOVWF 0x2d 084 1283 BCF 0x3, 0x5 085 1303 BCF 0x3, 0x6 086 0863 MOVF 0x63, W 087 1683 BSF 0x3, 0x5 088 1303 BCF 0x3, 0x6 089 00AE MOVWF 0x2e 13: pinge=1.6; 08A 30CD MOVLW 0xcd 08B 00AF MOVWF 0x2f 08C 30CC MOVLW 0xcc 08D 00B0 MOVWF 0x30 08E 303F MOVLW 0x3f 08F 00B1 MOVWF 0x31 14: } 090 118A BCF 0xa, 0x3