head     56.1;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


56.1
date     91.11.05.09.34.49;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.13.17;  author jwh;  state Exp;
branches ;
next     54.2;

54.2
date     91.08.21.14.41.15;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.20.32;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.21.55;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.05.42;  author jwh;  state Exp;
branches ;
next     51.2;

51.2
date     91.02.10.16.09.20;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.04.48;  author jwh;  state Exp;
branches ;
next     1.1;

1.1
date     91.01.16.15.29.08;  author jwh;  state Exp;
branches ;
next     ;


desc
@first version.
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


54.2
log
@
pws2rcs automatic delta on Wed Aug 21 13:42:03 MDT 1991
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@a0 275
*
*       x_snan.sa 3.1 12/10/90
*
* fpsp_snan --- FPSP handler for signalling NAN exception
*
* SNAN for float -> integer conversions (integer conversion of
* an SNAN) is a non-maskable run-time exception.
*
* For trap disabled the 040 does the following:
* If the dest data format is s, d, or x, then the SNAN bit in the NAN
* is set to one and the resulting non-signaling NAN (truncated if
* necessary) is transferred to the dest.  If the dest format is b, w,
* or l, then garbage is written to the dest (actually the upper 32 bits
* of the mantissa are sent to the integer unit).
*
* For trap enabled the 040 does the following:
* If the inst is move_out, then the results are the same as for trap
* disabled with the exception posted.  If the instruction is not move_
* out, the dest. is not modified, and the exception is posted.
*

*               Copyright (C) Motorola, Inc. 1990
*                       All Rights Reserved
*
*       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
*       The copyright notice above does not evidence any
*       actual or intended publication of such source code.



	include fpsp_h

	refr    get_fline
	refr    mem_write
	refr    real_snan
	refr    real_inex
	refr    fpsp_done
	refr    reg_dest

	def     fpsp_snan
fpsp_snan    equ    *
	link            a6,#-LOCAL_SIZE
	fsave           -(a7)
	movem.l         d0-d1/a0-a1,USER_DA(a6)
	fmovem.x        fp0-fp3,USER_FP0(a6)
	fmovem.l        FPCONTROL/FPSTATUS/FPIADDR,USER_FPCONTROL(a6)

*
* Check if trap enabled
*
	btst            #snan_bit,FPCONTROL_ENABLE(a6)
	bne.b           ena             ;If enabled, then branch

	bsr.l           move_out        ;else SNAN disabled
*
* It is possible to have an inex1 exception with the
* snan.  If the inex enable bit is set in the FPCONTROL, and either
* inex2 or inex1 occured, we must clean up and branch to the
* real inex handler.
*
ck_inex    equ    *
	move.b  FPCONTROL_ENABLE(a6),d0
	and.b   FPSTATUS_EXCEPT(a6),d0
	andi.b  #$3,d0
	beq.w   end_snan
*
* Inexact enabled and reported, and we must take an inexact exception.
*
take_inex    equ    *
	move.b          #INEX_VEC,EXC_VEC+1(a6)
	movem.l         USER_DA(a6),d0-d1/a0-a1
	fmovem.x        USER_FP0(a6),fp0-fp3
	fmovem.l        USER_FPCONTROL(a6),FPCONTROL/FPSTATUS/FPIADDR
	frestore        (a7)+
	unlk            a6
	bra.l           real_inex
*
* SNAN is enabled.  Check if inst is move_out.
* Make any corrections to the 040 output as necessary.
*
ena    equ    *
	btst            #5,CMDREG1B(a6) ;if set, inst is move out
	beq.w           not_out

	bsr.l           move_out

report_snan    equ    *
	move.b          (a7),VER_TMP(a6)
	cmpi.b          #VER_40,(a7)    ;test for orig unimp frame
	bne.b           ck_rev
	moveq           #13,d0          ;need to zero 14 lwords
	bra.b           rep_con
ck_rev    equ    *
	moveq           #11,d0          ;need to zero 12 lwords
rep_con    equ    *
	clr.l           (a7)
loop1    equ    *
	clr.l           -(a7)           ;clear and dec a7
	dbra            d0,loop1
	move.b          VER_TMP(a6),(a7) ;format a busy frame
	move.b          #BUSY_SIZE-4,1(a7)
	move.l          USER_FPSTATUS(a6),FPSTATUS_SHADOW(a6)
	ori.l           #sx_mask,E_BYTE(a6)
	movem.l         USER_DA(a6),d0-d1/a0-a1
	fmovem.x        USER_FP0(a6),fp0-fp3
	fmovem.l        USER_FPCONTROL(a6),FPCONTROL/FPSTATUS/FPIADDR
	frestore        (a7)+
	unlk            a6
	bra.l           real_snan
*
* Exit snan handler by expanding the unimp frame into a busy frame
*
end_snan    equ    *
	bclr            #E1,E_BYTE(a6)

	move.b          (a7),VER_TMP(a6)
	cmpi.b          #VER_40,(a7)    ;test for orig unimp frame
	bne.b           ck_rev2
	moveq           #13,d0          ;need to zero 14 lwords
	bra.b           rep_con2
ck_rev2    equ    *
	moveq           #11,d0          ;need to zero 12 lwords
rep_con2    equ    *
	clr.l           (a7)
loop2    equ    *
	clr.l           -(a7)           ;clear and dec a7
	dbra            d0,loop2
	move.b          VER_TMP(a6),(a7) ;format a busy frame
	move.b          #BUSY_SIZE-4,1(a7) ;write busy size
	move.l          USER_FPSTATUS(a6),FPSTATUS_SHADOW(a6)
	ori.l           #sx_mask,E_BYTE(a6)
	movem.l         USER_DA(a6),d0-d1/a0-a1
	fmovem.x        USER_FP0(a6),fp0-fp3
	fmovem.l        USER_FPCONTROL(a6),FPCONTROL/FPSTATUS/FPIADDR
	frestore        (a7)+
	unlk            a6
	bra.l           fpsp_done

*
* Move_out
*
move_out    equ    *
	move.l          EXC_EA(a6),a0   ;get <ea> from exc frame

	bfextu          CMDREG1B(a6){3:3},d0 ;move rx field to d0{2:0}
	cmpi.l          #0,d0           ;check for long
	beq.b           sto_long        ;branch if move_out long

	cmpi.l          #4,d0           ;check for word
	beq.b           sto_word        ;branch if move_out word

	cmpi.l          #6,d0           ;check for byte
	beq.b           sto_byte        ;branch if move_out byte

*
* Not byte, word or long
*
	rts
*
* Get the 32 most significant bits of etemp mantissa
*
sto_long    equ    *
	move.l          ETEMP_HI(a6),d1
	move.l          #4,d0           ;load byte count
*
* Set signalling nan bit
*
	bset            #30,d1
*
* Store to the users destination address
*
	tst.l           a0              ;check if <ea> is 0
	beq.b           wrt_dn          ;destination is a data register

	move.l          d1,-(a7)        ;move the snan onto the stack
	move.l          a0,a1           ;load dest addr into a1
	move.l          a7,a0           ;load src addr of snan into a0
	bsr.l           mem_write       ;write snan to user memory
	move.l          (a7)+,d1        ;clear off stack
	rts
*
* Get the 16 most significant bits of etemp mantissa
*
sto_word    equ    *
	move.l          ETEMP_HI(a6),d1
	move.l          #2,d0           ;load byte count
*
* Set signalling nan bit
*
	bset            #30,d1
*
* Store to the users destination address
*
	tst.l           a0              ;check if <ea> is 0
	beq.b           wrt_dn          ;destination is a data register

	move.l          d1,-(a7)        ;move the snan onto the stack
	move.l          a0,a1           ;load dest addr into a1
	move.l          a7,a0           ;point to low word
	bsr.l           mem_write       ;write snan to user memory
	move.l          (a7)+,d1        ;clear off stack
	rts
*
* Get the 8 most significant bits of etemp mantissa
*
sto_byte    equ    *
	move.l          ETEMP_HI(a6),d1
	move.l          #1,d0           ;load byte count
*
* Set signalling nan bit
*
	bset            #30,d1
*
* Store to the users destination address
*
	tst.l           a0              ;check if <ea> is 0
	beq.b           wrt_dn          ;destination is a data register
	move.l          d1,-(a7)        ;move the snan onto the stack
	move.l          a0,a1           ;load dest addr into a1
	move.l          a7,a0           ;point to source byte
	bsr.l           mem_write       ;write snan to user memory
	move.l          (a7)+,d1        ;clear off stack
	rts

*
*       wrt_dn --- write to a data register
*
*       We get here with D1 containing the data to write and D0 the
*       number of bytes to write: 1=byte,2=word,4=long.
*
wrt_dn    equ    *
	move.l          d1,L_SCR1(a6)   ;data
	move.l          d0,-(a7)        ;size
	bsr.l           get_fline       ;returns fline word in d0
	move.l          d0,d1
	andi.l          #$7,d1          ;d1 now holds register number
	move.l          (sp)+,d0        ;get original size
	cmpi.l          #4,d0
	beq.b           wrt_long
	cmpi.l          #2,d0
	bne.b           wrt_byte
wrt_word    equ    *
	or.l            #$8,d1
	bra.l           reg_dest
wrt_long    equ    *
	or.l            #$10,d1
	bra.l           reg_dest
wrt_byte    equ    *
	bra.l           reg_dest
*
* Check if it is a src nan or dst nan
*
not_out    equ    *
	move.l          DTAG(a6),d0
	bfextu          d0{0:3},d0      ;isolate dtag in lsbs

	cmpi.b          #3,d0           ;check for nan in destination
	bne.b           issrc           ;destination nan has priority
dst_nan    equ    *
	btst            #6,FPTEMP_HI(a6) ;check if dest nan is an snan
	bne.b           issrc           ;no, so check source for snan
	move.w          FPTEMP_EX(a6),d0
	bra.b           cont
issrc    equ    *
	move.w          ETEMP_EX(a6),d0
cont    equ    *
	btst            #15,d0          ;test for sign of snan
	beq.b           clr_neg
	bset            #neg_bit,FPSTATUS_CC(a6)
	bra.w           report_snan
clr_neg    equ    *
	bclr            #neg_bit,FPSTATUS_CC(a6)
	bra.w           report_snan

	end
@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.2
log
@*** empty log message ***
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@d31 1
a31 1
	include fpsp.h
@


1.1
log
@Initial revision
@
text
@@
