home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
coders
/
jËzyki_programowania
/
oberon
/
system
/
amigamathl.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1977-12-31
|
6KB
|
174 lines
Syntax20b.Scn.Fnt
ParcElems
Alloc
Syntax24b.Scn.Fnt
Syntax10.Scn.Fnt
Syntax10b.Scn.Fnt
FoldElems
(* AMIGA *)
MODULE AmigaMathL; (* RD 6.8.1995 *)
IMPORT
SYSTEM, Amiga, AmigaExec, AmigaBase;
TwoLInts = RECORD
l1,l2: LONGINT;
END;
BasLib, TransLib: LONGINT;
Dummy: AmigaBase.Regs;
PROCEDURE RealTo(r: LONGREAL; VAR l1,l2: LONGINT);
VAR t: TwoLInts;
BEGIN
t:=SYSTEM.VAL(TwoLInts, r);
l1:=t.l1;l2:=t.l2;
END RealTo;
PROCEDURE ToReal(l1,l2: LONGINT; VAR r:LONGREAL);
VAR t: TwoLInts;
BEGIN
t.l1:=l1;t.l2:=l2;
r:=SYSTEM.VAL( LONGREAL, t);
END ToReal;
PROCEDURE Short*(a: LONGREAL; VAR b: REAL);
VAR t: TwoLInts;
BEGIN
RealTo(a,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -102, Dummy);
b:=SYSTEM.VAL(REAL, Dummy.d[0]);
END Short;
PROCEDURE Long*(a: REAL; VAR b: LONGREAL);
BEGIN
Dummy.d[0]:=SYSTEM.VAL(LONGINT, a);
AmigaBase.LibCall(TransLib, -108, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],b);
END Long;
PROCEDURE Entier*(s: LONGREAL): LONGINT;
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(BasLib, -90, Dummy);
AmigaBase.LibCall(BasLib, -30, Dummy);
RETURN Dummy.d[0];
END Entier;
PROCEDURE IntToReal*(l: LONGINT; VAR d: LONGREAL);
BEGIN
Dummy.d[0]:=l;
AmigaBase.LibCall(BasLib, -36, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END IntToReal;
(* 1 if s1>s2 0 if s1=s2 -1 if s1<s2 *)
PROCEDURE Cmp*(s1, s2: LONGREAL): LONGINT;
BEGIN
RealTo(s1,Dummy.d[0],Dummy.d[1]);
RealTo(s2,Dummy.d[2],Dummy.d[3]);
AmigaBase.LibCall(BasLib, -42, Dummy);
RETURN Dummy.d[0];
END Cmp;
(* 1 if s>0 0 if s=0 -1 if s<0 *)
PROCEDURE Tst*(s: LONGREAL): LONGINT;
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(BasLib, -48, Dummy);
RETURN Dummy.d[0];
END Tst;
PROCEDURE Abs*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(BasLib, -54, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Abs;
PROCEDURE Neg*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(BasLib, -60, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Neg;
PROCEDURE Add*(s1, s2: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s1,Dummy.d[0],Dummy.d[1]);
RealTo(s2,Dummy.d[2],Dummy.d[3]);
AmigaBase.LibCall(BasLib, -66, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Add;
PROCEDURE Sub*(s1, s2: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s1,Dummy.d[0],Dummy.d[1]);
RealTo(s2,Dummy.d[2],Dummy.d[3]);
AmigaBase.LibCall(BasLib, -72, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Sub;
PROCEDURE Mul*(s1, s2: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s1,Dummy.d[0],Dummy.d[1]);
RealTo(s2,Dummy.d[2],Dummy.d[3]);
AmigaBase.LibCall(BasLib, -78, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Mul;
PROCEDURE Div*(s1, s2: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s1,Dummy.d[0],Dummy.d[1]);
RealTo(s2,Dummy.d[2],Dummy.d[3]);
AmigaBase.LibCall(BasLib, -84, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Div;
PROCEDURE Arctan*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -30, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Arctan;
PROCEDURE Cos*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -42, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Cos;
PROCEDURE Sin*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -36, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Sin;
PROCEDURE Ln*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -84, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Ln;
PROCEDURE Exp*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -78, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Exp;
PROCEDURE Sqrt*(s: LONGREAL; VAR d: LONGREAL);
BEGIN
RealTo(s,Dummy.d[0],Dummy.d[1]);
AmigaBase.LibCall(TransLib, -96, Dummy);
ToReal(Dummy.d[0],Dummy.d[1],d);
END Sqrt;
(* returns s1/s2 *)
PROCEDURE Ratio*(s1, s2: LONGINT; VAR d: LONGREAL);
VAR r1,r2: LONGREAL;
BEGIN
IntToReal(s1, r1);
IntToReal(s2,r2);
Div(r1,r2,d);
END Ratio;
PROCEDURE e*(VAR d: LONGREAL);
BEGIN
ToReal(04005BF0AH,08B14575DH,d);
END e;
PROCEDURE pi*(VAR d: LONGREAL);
BEGIN
ToReal(0400921FBH,054442D10H,d);
END pi;
PROCEDURE TermProc;
BEGIN
Dummy.a[1]:=BasLib;
IF BasLib#0 THEN AmigaBase.LibCall(AmigaBase.ExecBase(), -414, Dummy);END;
Dummy.a[1]:=TransLib;
IF TransLib#0 THEN AmigaBase.LibCall(AmigaBase.ExecBase(), -414, Dummy)END
END TermProc;
BEGIN
BasLib:=AmigaExec.OpenLibrary("mathieeedoubbas.library", 0);
TransLib:=AmigaExec.OpenLibrary("mathieeedoubtrans.library", 0);
Amiga.TermProcedure(TermProc);
END AmigaMathL.