home *** CD-ROM | disk | FTP | other *** search
-
- // FIXPOINT.ASM
- //
- // Copyright (c) 1993
- // Kevin Gliner
- //
- // Adapted by Christopher Lampton for
- // GARDENS OF IMAGINATION (Waite Group Press, 1994)
- #pragma inline
-
- inline void fixmul(long arg1, long arg2)
- {
- asm {
- push bp
- mov bp,sp
- mov eax,arg1
- imul arg2
- // shr eax,16 ;to put result in eax instead, do
- ;a shrd edx,eax,16
- shrd eax,edx,16
- pop bp
- ret
- }
- }
-
- inline void fixmuldiv(long arg1, long arg2, long arg3)
- {
- asm {
- push bp
- mov bp,sp
- mov eax, arg1
- imul arg2
- idiv arg3 ;eax now holds result
- shld edx,eax,16
- pop bp
- ret
- }
- }
-
- inline void fixdiv(long numer, long denom)
- {
- asm {
- push bp
- mov bp,sp
- mov eax, numer
- mov edx,eax
- sar edx,16
- shl eax,16
- idiv denom ;eax now holds result
- shld edx,eax,16
- pop bp
- ret
- }
- }
-
- inline void fix(int arg1)
- {
- asm {
- push bp
- mov bp,sp
- mov ax, arg1
- sal eax,16
- mov edx, eax
- shr edx, 16
- pop bp
- ret
- }
- }
-