Subject: port-m68k/2761: wrong fmovem emulation code of FPE
To: None <gnats-bugs@gnats.netbsd.org>
From: Takeshi Nakayama <takeshi@sakabe.nuie.nagoya-u.ac.jp>
List: netbsd-bugs
Date: 09/16/1996 23:45:27
>Number:         2761
>Category:       port-m68k
>Synopsis:       wrong fmovem emulation code of FPE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 16 07:50:02 1996
>Last-Modified:
>Originator:     Takeshi Nakayama
>Organization:
Department of Information Engineering, Nagoya University, Japan
>Release:        1.2_BETA
>Environment:
System: NetBSD selene 1.2 NetBSD 1.2 (SELENE) #1: Mon Sep 16 03:52:03 JST 1996 takeshi@selene:/usr/src/sys/arch/x68k/compile/SELENE x68k


>Description:
	The emulation code of fmovem does not consider the FP
register ordaring. Therefore, at the end of function call, fmovem
restores datum to the wrong register.

>How-To-Repeat:
	For example, the instruction `fmovem sp@+,fp0-fp1' restores
datum to fp0 and fp1, but on the system running FPE, restores to
fp6 and fp7.

>Fix:
	Apply the following patch to src/sys/arch/m68k/fpe/fpu_emulate.c.

*** fpu_emulate.c.orig	Wed May 15 20:30:11 1996
--- fpu_emulate.c	Sun Sep  8 05:37:26 1996
***************
*** 445,451 ****
      int word1, sig;
      int reglist, regmask, regnum;
      int fpu_to_mem, order;
!     int w1_post_incr;		/* XXX - FP regs order? */
      int *fpregs;
  
      insn->is_advance = 4;
--- 445,451 ----
      int word1, sig;
      int reglist, regmask, regnum;
      int fpu_to_mem, order;
!     int w1_post_incr;
      int *fpregs;
  
      insn->is_advance = 4;
***************
*** 487,493 ****
      }
  
      while ((0 <= regnum) && (regnum < 8)) {
! 	regmask = 1 << regnum;
  	if (regmask & reglist) {
  	    if (fpu_to_mem) {
  		sig = fpu_store_ea(frame, insn, &insn->is_ea0,
--- 487,497 ----
      }
  
      while ((0 <= regnum) && (regnum < 8)) {
! 	if (w1_post_incr) {
! 	    regmask = 0x80 >> regnum;
! 	} else {
! 	    regmask = 1 << regnum;
! 	}
  	if (regmask & reglist) {
  	    if (fpu_to_mem) {
  		sig = fpu_store_ea(frame, insn, &insn->is_ea0,
>Audit-Trail:
>Unformatted: