aburto@marlin.UUCP (Alfred A. Aburto) (11/20/86)
Several people have asked me how one could talk to the 68020/68881 via
Lattice C. The best solution of course would be an Amiga Lattice C compiler
version that supports the 68020/68881. Next would be a software library
such as the mathffp.library and mathtrans.library which one could call from
C. Finally one could write an assembly program which does 68020/68881
things that would be compiled and linked to work with a target C program.
Its this latter approach that I can help with. What I have is a bit of a
kludge but it does work. A sample C test program is shown below and I'll
upload the Assembly program in a follow up message.
The sample C program :
/**************************************/
/* 68020/68881 test program */
/**************************************/
extern float FPCP(); /* 68020/68881 Assembly program */
main()
{
float ua, ub, uc, ud;
int mc;
mc = 1;
ua = 0.5;
ub = 1.75;
uc = FPCP(mc, &ua, &ub); /* uc = ua + ub */
printf(" ua + ub = %f\n",uc);
uc = FPCP(2, &ua, &ub); /* uc = ua - ub */
printf(" ua - ub = %f\n",uc);
uc = FPCP(3, &ua, &ub); /* uc = ua * ub */
printf(" ua * ub = %f\n",uc);
uc = FPCP(4, &ua, &ub); /* uc = ua / ub */
printf(" ua / ub = %f\n",uc);
uc = FPCP(5, &ua); /* uc = sin(ua) */
printf(" sin(ua) = %f\n",uc);
uc = FPCP(6, &ua); /* uc = cos(ua) */
printf(" cos(ua) = %f\n",uc);
uc = FPCP(7, &ua, &ud); /* uc = sin(ua) */
/* ud = cos(ua) */
}
__________________________ end of program ____________________________
I'll upload the assembly program shortly........
Al Aburto
aburto@marlin.UUCP (Alfred A. Aburto) (11/21/86)
This is the 68020/68881 Amiga Assembly program source which can be compiled and then linked to the C sample program.... ************************************** * 68020/68881 Assembly program * ************************************** XDEF _FPCP SECTION TEXT _FPCP LINK A6,#$FFFC MOVE.L $08(A6),D0 ;mc (the int mc) MOVE.L $0C(A6),A0 ;&ua (the address of ua) MOVE.L $10(A6),A1 ;ub (the address of ub) FADDS: CMPI.B #$01,D0 BNE FSUBS DC.L $F2104400 ;FMOVE.S (A0),FP0 DC.L $F2114422 ;FADD.S (A1),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FSUBS: CMPI.B #$02,D0 BNE FMULS DC.L $F2104400 ;FMOVE.S (A0),FP0 DC.L $F2114428 ;FSUB.S (A1),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FMULS: CMPI.B #$03,D0 BNE FDIVS DC.L $F2104400 ;FMOVE.S (A0),FP0 DC.L $F2114423 ;FMUL.S (A1),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FDIVS: CMPI.B #$04,D0 BNE FSINS DC.L $F2104400 ;FMOVE.S (A0),FP0 DC.L $F2114420 ;FDIV.S (A1),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FSINS: CMPI.B #$05,D0 BNE FCOSS DC.L $F210440E ;FSIN.S (A0),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FCOSS: CMPI.B #$06,D0 BNE FSINCOSS DC.L $F210441D ;FCOS.S (A0),FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 UNLK A6 RTS FSINCOSS: CMPI.B #$07,D0 BNE QUIT DC.L $F2104431 ;FSINCOS.S (A0),FP1:FP0 DC.L $F2006400 ;FMOVE.S FP0,D0 DC.L $F2116480 ;FMOVE.S FP1,(A1) QUIT: UNLK A6 RTS END ___________________ End of assembly Program ______________________________ Al Aburto