home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ; Fixed-Point Assembler Modul for Turbo Pascal
- ; Copyright (c) 1994,95 by J.E. Hoffmann
- ; All rights reserved
- ;----------------------------------------------------------------------------
- TITLE FixedPas.ASM
-
-
- MODEL SMALL
-
-
- IDEAL
- NOJUMPS
- LOCALS @@
-
-
- DATASEG
- SinTable \
- DW 00000h, 00006h, 0000Dh, 00013h, 00019h, 0001Fh, 00026h, 0002Ch, 00032h, 00038h, 0003Fh, 00045h, 0004Bh, 00051h, 00058h, 0005Eh
- DW 00064h, 0006Ah, 00070h, 00076h, 0007Ch, 00082h, 00089h, 0008Fh, 00095h, 0009Bh, 000A1h, 000A7h, 000ACh, 000B2h, 000B8h, 000BEh
- DW 000C4h, 000CAh, 000CFh, 000D5h, 000DBh, 000E1h, 000E6h, 000ECh, 000F1h, 000F7h, 000FCh, 00102h, 00107h, 0010Dh, 00112h, 00117h
- DW 0011Ch, 00122h, 00127h, 0012Ch, 00131h, 00136h, 0013Bh, 00140h, 00145h, 0014Ah, 0014Eh, 00153h, 00158h, 0015Ch, 00161h, 00166h
- DW 0016Ah, 0016Eh, 00173h, 00177h, 0017Bh, 00180h, 00184h, 00188h, 0018Ch, 00190h, 00194h, 00197h, 0019Bh, 0019Fh, 001A3h, 001A6h
- DW 001AAh, 001ADh, 001B1h, 001B4h, 001B7h, 001BAh, 001BDh, 001C1h, 001C4h, 001C6h, 001C9h, 001CCh, 001CFh, 001D1h, 001D4h, 001D7h
- DW 001D9h, 001DBh, 001DEh, 001E0h, 001E2h, 001E4h, 001E6h, 001E8h, 001EAh, 001ECh, 001EDh, 001EFh, 001F1h, 001F2h, 001F4h, 001F5h
- DW 001F6h, 001F7h, 001F8h, 001F9h, 001FAh, 001FBh, 001FCh, 001FDh, 001FEh, 001FEh, 001FFh, 001FFh, 001FFh, 00200h, 00200h, 00200h
- DW 00200h
-
-
- CODESEG
- P386N
-
-
- PUBLIC FixMul
- PUBLIC FixDiv
- PUBLIC FixSQR
- PUBLIC FixSin
- PUBLIC FixCos
-
-
-
- ;----------------------------------------------------------------------------
- ; function FixMul(A,B :Fixed) :Fixed; near; external;
- ;----------------------------------------------------------------------------
- PROC FixMul NEAR
- pop cx
- pop ebx
- pop eax
- imul ebx
- shrd eax,edx,9
- rol eax,16
- mov dx,ax
- rol eax,16
- push cx
- ret
- ENDP
-
-
-
- ;----------------------------------------------------------------------------
- ; function FixDiv(A,B :Fixed) :Fixed; near; external;
- ;----------------------------------------------------------------------------
- PROC FixDiv NEAR
- pop cx
- pop ebx
- pop eax
- cdq
- shld edx,eax,9
- shl eax,9
- idiv ebx
- rol eax,16
- mov dx,ax
- rol eax,16
- push cx
- ret
- ENDP
-
-
-
- ;----------------------------------------------------------------------------
- ; function FixSQR(A :Fixed) :Fixed; near; external;
- ;----------------------------------------------------------------------------
- PROC FixSQR NEAR
- pop cx
- pop eax
- imul eax
- shrd eax,edx,9
- rol eax,16
- mov dx,ax
- rol eax,16
- push cx
- ret
- ENDP
-
-
-
- ;----------------------------------------------------------------------------
- ; function FixSin(W :Integer) :Fixed; near; external;
- ;----------------------------------------------------------------------------
- PROC FixSin NEAR
- pop cx
- pop bx
- $$Sin:
- and bx,1FFh
- cmp bx,256
- jge @@21
- cmp bx,128
- jng @@11
- neg bx
- add bx,256
- @@11:
- shl bx,1
- mov ax,[bx+SinTable]
- cwd
- push cx
- ret
- @@21:
- sub bx,256
- cmp bx,128
- jnge @@22
- neg bx
- add bx,256
- @@22:
- shl bx,1
- mov ax,[bx+SinTable]
- neg ax
- cwd
- push cx
- ret
- ENDP
-
-
-
- ;----------------------------------------------------------------------------
- ; function FixCos(W :Integer) :Fixed; near; external;
- ;----------------------------------------------------------------------------
- PROC FixCos NEAR
- pop cx
- pop bx
- add bx,128
- jmp $$Sin
- ENDP
- END