From: George H. <geo...@us...> - 2005-11-16 09:11:49
|
Update of /cvsroot/win32forth/win32forth/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23125/win32forth/src Modified Files: FLOAT.F Log Message: gah: More optimisations to produce shorter and faster code Index: FLOAT.F =================================================================== RCS file: /cvsroot/win32forth/win32forth/src/FLOAT.F,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** FLOAT.F 15 Nov 2005 10:42:39 -0000 1.20 --- FLOAT.F 16 Nov 2005 09:11:38 -0000 1.21 *************** *** 257,266 **** \ Input: eax = number of floats we need subr: fstack-check ! ! B/FLOAT 10 = [IF] ! lea eax, 0 [eax*4] [eax] ! add eax, eax ! [ELSE] shl eax, # 3 ! [THEN] mov ecx, FSP_MEMORY cmp ecx, eax js short L$1 --- 257,261 ---- \ Input: eax = number of floats we need subr: fstack-check ! mov ecx, FSP_MEMORY cmp ecx, eax js short L$1 *************** *** 274,278 **** \ makro to check if there is at least one element on the floating point stack macro: fstack-check_1 ! mov eax, # 1 call fstack-check true to fsp-cached? --- 269,273 ---- \ makro to check if there is at least one element on the floating point stack macro: fstack-check_1 ! mov eax, # b/float call fstack-check true to fsp-cached? *************** *** 281,285 **** \ makro to check if there are at least two elements on the floating point stack macro: fstack-check_2 ! mov eax, # 2 call fstack-check true to fsp-cached? --- 276,280 ---- \ makro to check if there are at least two elements on the floating point stack macro: fstack-check_2 ! mov eax, # b/float 2* call fstack-check true to fsp-cached? *************** *** 288,292 **** \ makro to check if there are at least three elements on the floating point stack macro: fstack-check_3 ! mov eax, # 3 call fstack-check true to fsp-cached? --- 283,287 ---- \ makro to check if there are at least three elements on the floating point stack macro: fstack-check_3 ! mov eax, # b/float 3 * call fstack-check true to fsp-cached? *************** *** 493,496 **** --- 488,496 ---- mov eax, ebx inc eax + B/FLOAT 10 = [IF] + lea eax, 0 [eax*4] [eax] + add eax, eax + [ELSE] shl eax, # 3 + [THEN] call fstack-check *************** *** 818,821 **** --- 818,847 ---- : f>s f>d drop ; + \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + \ Transfering floats to the data stack (as floats) for windows + \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ + + code FS>DS ( -- d ) ( f: r -- ) \ move floating point number bits to + \ data stack as a 64-bit float + fstack-check_1 + >fpu + push ebx + push ebx + push ebx + fstp double 0 [esp] + pop ebx + float; + + \ from Jos v.d. Ven + \ Push the top of the float stack onto the data stack as a 32-bit float + code SFS>DS ( -- float ) ( fs: r -- ) \ 10 b/float + fstack-check_1 + >fpu + push ebx + push ebx + fstp float 0 [esp] + pop ebx + float; + \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ Floating point comparison operators *************** *** 1093,1101 **** code FLNP1 ( fs: r1 -- r2 ) \ ? error for x <= -1 ! mov ecx, FSP_MEMORY ! sub ecx, # B/FLOAT ! js short L$1 fldln2 ! fld FSIZE FSTACK_MEMORY fld FSIZE sq2m1 fcomp st(1) --- 1119,1128 ---- code FLNP1 ( fs: r1 -- r2 ) \ ? error for x <= -1 ! fstack-check_1 ! fldln2 ! ! >FPU ! fld FSIZE sq2m1 fcomp st(1) *************** *** 1110,1114 **** jb short L$4 fyl2xp1 ! fstp FSIZE FSTACK_MEMORY jmp short L$2 L$4: fld1 \ add the "1" explicitly --- 1137,1143 ---- jb short L$4 fyl2xp1 ! ! (FPU>) \ Used to balance branches ! jmp short L$2 L$4: fld1 \ add the "1" explicitly *************** *** 1116,1126 **** fabs fyl2x ! fstp FSIZE FSTACK_MEMORY jmp short L$2 L$3: fcompp \ return arg if incomparable ! jmp short L$2 ! L$1: mov esi, # ' fstkuflo >body ! L$2: next, ! end-code code FLOG ( fs: r1 -- r2 ) --- 1145,1155 ---- fabs fyl2x ! ! FPU> ! jmp short L$2 L$3: fcompp \ return arg if incomparable ! ! L$2: float; code FLOG ( fs: r1 -- r2 ) *************** *** 1184,1192 **** code FEXP ( fs: r1 -- r2 ) \ ? error for x too large ! mov ecx, FSP_MEMORY ! sub ecx, # B/FLOAT ! js short L$1 fldl2e \ log base 2 of e \ 1 ! fld FSIZE FSTACK_MEMORY \ 2 fmulp st(1), st \ modified exponent \ 1 fld st(0) \ duplicate exponent \ 2 --- 1213,1219 ---- code FEXP ( fs: r1 -- r2 ) \ ? error for x too large ! fstack-check_1 fldl2e \ log base 2 of e \ 1 ! >FPU \ 2 fmulp st(1), st \ modified exponent \ 1 fld st(0) \ duplicate exponent \ 2 *************** *** 1204,1212 **** faddp st(1), st \ 2**frac \ 2 fmulp st(1), st \ 2**(int + frac) \ 1 ! fstp FSIZE FSTACK_MEMORY \ 0 ! jmp short L$2 ! L$1: mov esi, # ' FSTKUFLO >body ! L$2: next, ! end-code : FCOSH ( f: r1 -- r2 ) \ ? error for x too large --- 1231,1236 ---- faddp st(1), st \ 2**frac \ 2 fmulp st(1), st \ 2**(int + frac) \ 1 ! FPU> \ 0 ! float; : FCOSH ( f: r1 -- r2 ) \ ? error for x too large *************** *** 1424,1437 **** code f**+n ( f: r1 -- r2 ; n -- ) ! mov ecx, FSP_MEMORY ! sub ecx, # B/FLOAT ! js short L$4 ! fld1 ! or ebx, ebx je short L$5 ! fld FSIZE FSTACK_MEMORY fxch st(1) ! L$1: shr ebx, # 1 jnc short L$2 fmul st(0), st(1) --- 1448,1458 ---- code f**+n ( f: r1 -- r2 ; n -- ) ! fstack-check_1 fld1 ! or tos, tos je short L$5 ! >fpu fxch st(1) ! L$1: shr tos, # 1 jnc short L$2 fmul st(0), st(1) *************** *** 1443,1453 **** L$3: fxch st(1) fstp st(0) ! L$5: fstp FSIZE FSTACK_MEMORY ! ! jmp short L$6 ! L$4: mov esi, # ' FSTKUFLO >body ! L$6: pop ebx ! next, ! end-code : f**n ( F: r1 -- r2 ; n -- ) \ Floating number raised to integer power. --- 1464,1470 ---- L$3: fxch st(1) fstp st(0) ! L$5: fpu> ! pop tos ! float; : f**n ( F: r1 -- r2 ; n -- ) \ Floating number raised to integer power. *************** *** 2247,2283 **** )) - code FS>DS ( -- d ) ( f: r -- ) \ move floating point number bits to - \ data stack as a 64-bit float - mov ecx, FSP_MEMORY - sub ecx, # B/FLOAT - js short L$1 - fld FSIZE FSTACK_MEMORY - mov FSP_MEMORY , ecx - push ebx - push ebx - push ebx - fstp double 0 [esp] - pop ebx - jmp short L$2 - L$1: mov esi, # ' FSTKUFLO >body - pop ebx - L$2: next, - end-code - - \ from Jos v.d. Ven - \ Push the top of the float stack onto the data stack as a 32-bit float - code SFS>DS ( -- float ) ( fs: r -- ) \ 10 b/float - mov ecx, FSP_MEMORY - sub ecx, # B/FLOAT - js short L$1 - fld FSIZE FSTACK_MEMORY - mov FSP_MEMORY , ecx - push ebx - push ebx - fstp float 0 [esp] - pop ebx - jmp short L$2 - L$1: mov esi, # ' FSTKUFLO >body - pop ebx - L$2: next, - end-code --- 2264,2265 ---- |