Board index » delphi » 80bit data moves using the FPU.

80bit data moves using the FPU.

A while back there was a rumour floating around in rec.games.programmer
and comp.lang.asm.x86 about being able to move data 80bits at a time
using the FPU.  Well, due to entirely too much coffee and spare time at
the local Village Inn, I have discovered how to do it.  The following code
snippet will flip a 320x200 double buffer (which is contained in the pointer
scrn2) to the screen.  Although this may not be useful to people, it will
give one a chance to see how moving 80bits at a time works.  I will have
to replace my ModeX scan-line fill code [in my fillpoly procedure] with
something similar.  Imagine filling 40 pixels in one move.  Mwahehehehehe.

var scrn2:pointer;

procedure FlipPages; assembler;
asm
        mov     dx,ds             ;{save ds}
        xor     di,di
        mov     es,Sega000        ;{es:[di] points to screen memory}
        lds     si,scrn2          ;{location of 320x200 screen buffer}
        mov     cx,64000/10       ;{80bits=10 bytes :)}
@@loop: fld     tbyte ptr ds:[si] ;{push 80bits onto the FP stack}
        fstp    tbyte ptr es:[di] ;{pop 80bits from the FP stack to the screen}
        add     si,10             ;{move source}
        add     di,10             ;{move dest}
        dec     cx
        jnz     @@loop
        mov     ds,dx             ;{restore ds}
end;

--TCA of NewOrder  /  newor...@argo.unm.edu  /  http://www.nmt.edu/~surface
Programmer for Stranger Than Fiction Games, Inc.
Project WallyWorld Quote:  "A gleekzorp without a tornpee is like a quop
without a fertsneet (sort of)."

 

Re:80bit data moves using the FPU.


newor...@unm.edu (NewOrder Demo Group) wrote:

Quote
>A while back there was a rumour floating around in rec.games.programmer
>and comp.lang.asm.x86 about being able to move data 80bits at a time
>using the FPU.
 ...
>@@loop: fld     tbyte ptr ds:[si] ;{push 80bits onto the FP stack}
>        fstp    tbyte ptr es:[di] ;{pop 80bits from the FP stack to the screen}

My guess would be that this is not reliable.  The problem is that not
all 10 byte encodings are legal floating point numbers.  I would guess
if you load an illegal encoding, you'll generate an interrupt (which
you could mask), and the FPU will fix it up, so when it gets stored it
won't be the same.

If you want to check this out, the illegal encodings generally have
the high word equal to 7FFF or FFFF, and the next most significant one
or two bits equal to 0.  On the 8087 they were called "pseudo-NaNs"
and "pseudo-infinities".

Duncan Murdoch

Re:80bit data moves using the FPU.


On Tue, 09 Jan 1996 23:49:35 GMT, dmurd...@mast.queensu.ca (Duncan

Quote
Murdoch) wrote:
>newor...@unm.edu (NewOrder Demo Group) wrote:

>>A while back there was a rumour floating around in rec.games.programmer
>>and comp.lang.asm.x86 about being able to move data 80bits at a time
>>using the FPU.
> ...
>>@@loop: fld     tbyte ptr ds:[si] ;{push 80bits onto the FP stack}
>>        fstp    tbyte ptr es:[di] ;{pop 80bits from the FP stack to the screen}

>My guess would be that this is not reliable.  The problem is that not
>all 10 byte encodings are legal floating point numbers.

My guess was wrong.  When loading an extended real, the FPU doesn't
check for legality.  This would be a problem if you tried to use the
same trick to load 8 byte doubles (since those do get checked), but
not 10 byte extendeds.

Duncan Murdoch

Re:80bit data moves using the FPU.


In article <30f2fd77.2441...@130.15.126.54>,

Quote
Duncan Murdoch <dmurd...@mast.queensu.ca> wrote:
>newor...@unm.edu (NewOrder Demo Group) wrote:

>>A while back there was a rumour floating around in rec.games.programmer
>>and comp.lang.asm.x86 about being able to move data 80bits at a time
>>using the FPU.
> ...
>>@@loop: fld     tbyte ptr ds:[si] ;{push 80bits onto the FP stack}
>>        fstp    tbyte ptr es:[di] ;{pop 80bits from the FP stack to the screen}

>My guess would be that this is not reliable.  The problem is that not
>all 10 byte encodings are legal floating point numbers.  I would guess
>if you load an illegal encoding, you'll generate an interrupt (which
>you could mask), and the FPU will fix it up, so when it gets stored it
>won't be the same.

>If you want to check this out, the illegal encodings generally have
>the high word equal to 7FFF or FFFF, and the next most significant one
>or two bits equal to 0.  On the 8087 they were called "pseudo-NaNs"
>and "pseudo-infinities".

Although it is very possible (and moderately easy) to get an exception when
using floating point instructions, FLD only pushes the number onto the stack
and does no checking.  If one were to attempt to modify an invalid number,
it could possibly generate an exception.  (The above sequence of byte/word/
tbytes worked without any problem).

--TCA of NewOrder  /  newor...@argo.unm.edu  /  http://www.nmt.edu/~surface
Programmer for Stranger Than Fiction Games, Inc.
Project WallyWorld Quote:  "Know what I hate?  Rhetorical questions."

Re:80bit data moves using the FPU.


Hi TCA!

NDG> A while back there was a rumour floating around in rec.games.programmer
NDG> and comp.lang.asm.x86 about being able to move data 80bits at a time
NDG> using the FPU.

NDG> @@loop: fld     tbyte ptr ds:[si] ;{push 80bits onto the FP stack}
NDG>         fstp    tbyte ptr es:[di] ;{pop 80bits from the FP stack to the

Nice. Reminds me of the BP7 type /comp/, which is a FPU 64bit integer.

For most applications it works as supposed. But there are pitfalls, like that
there is _no_ rounding off on divisions inside /comp/ expressions (but that can
be forced by extra assignments/rounding calls), like: res:=(c div 2)*2 makes
res exactly the same as c, ignorant of the oddness of c. temp:=(c div 2);
res:=temp*2 gives the desired result.

Since BP7 and the Intel x86 up to Pentium don't support true 64bit integers,
and the fact that there are numerous applications for 64bit integers, makes the
indirect way via the FPU interesting (on some calculations 64bit /comp/ might
be faster than 32bit /longint/, especially on a Pentium).

CU
    Mike =8-#)

2:2452/108.348 - msie...@yftn.fido.de

Re:80bit data moves using the FPU.


NewOrder Demo Group (newor...@unm.edu) wrote:
[..]

Quote
>to replace my ModeX scan-line fill code [in my fillpoly procedure] with
>something similar.  Imagine filling 40 pixels in one move.  Mwahehehehehe.

Did you make speed tasts? It would be interesting to compare with
the MOVSW and MOVSD (forget REP for the moment).

--
Zhenya Sorokin

E-mail     : soro...@ps1.iaee.tuwien.ac.at, s...@rs6.iaee.tuwien.ac.at
Paper-mail : E. Sorokin, Gusshausstr. 27/359-4, 1040 Vienna, Austria
Voice-mail : +43(1)58801-3703, -3948
Fax-mail   : +43(1)504 2477

Other Threads