Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!viusys!uxui!unislc!bryce!netw23!val From: val@netw23.uucp (Oberon Kenobi) Newsgroups: comp.sys.amiga.programmer Subject: Re: SAS/C Assembler bug + FPU quiz (Answer) Message-ID: <177366@netw23.uucp> Date: 25 May 91 19:33:54 GMT References: <177235@netw23.uucp> Organization: Weber State University, CS DEPT. Lines: 34 In article <177235@netw23.uucp>, val@netw23.uucp (Oberon Kenobi) writes: > ... > 2) Notice the self-modifying version, which was the first that I tried. > All caches were turned off, but it was still one constant behind. (i.e.: In > my loop, I ask for $3F and I get pi, $3E -> 10^4096, $3D ->10^2048, etc..) > Please don't mail me nor post the answer. This is a quiz for which I will > post the answer in two weeks. > ... > consts.asm==================================================================== > ... > _fpconst_sm: > move.l 4(a7),d0 ; Get it from the stack if called that way > _fpconst_sm_r0: > and.b #63,d0 ; Only pay attention to the lower six bits > lea 7(pc),a0 ; The location that is going to be changed > move.b d0,(a0) ; Change the location fnop ; Flush the FPU pipeline > fmovecr.x #0,fp0 ; Move the constant > rts > ... Two weeks are up. As I promised, here is the answer: Since the 68030 has a three instruction pipeline (I think), the FMOVECR is being fetched before the instruction is being changed. The next time it executes the instruction, it gets the instruction as changed by the previous iteration. The FNOP effectively flushes the execution pipeline. (I haven't actually tried it, but this should work.) -- ____ ____ ____ |=============================================================| \ \/ \/ / | "vi? Because I don't have a real editor." -- U*x user | \Weber State/ |=============================================================| \University/ |Oberon| Internet: val@csulx.weber.edu, val@net23.weber.edu | \___/\___/ |Kenobi| Usenet: uunet!viusys!uxui!unislc!bryce!netw23!val | Computer Science |=============================================================|