x_fline.sa revision 1.1.1.1 1 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
2 * M68000 Hi-Performance Microprocessor Division
3 * M68040 Software Package
4 *
5 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
6 * All rights reserved.
7 *
8 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
9 * To the maximum extent permitted by applicable law,
10 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
11 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
12 * PARTICULAR PURPOSE and any warranty against infringement with
13 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
14 * and any accompanying written materials.
15 *
16 * To the maximum extent permitted by applicable law,
17 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
18 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
19 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
20 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
21 * SOFTWARE. Motorola assumes no responsibility for the maintenance
22 * and support of the SOFTWARE.
23 *
24 * You are hereby granted a copyright license to use, modify, and
25 * distribute the SOFTWARE so long as this entire notice is retained
26 * without alteration in any modified and/or redistributed versions,
27 * and that such modified versions are clearly identified as such.
28 * No licenses are granted by implication, estoppel or otherwise
29 * under any patents or trademarks of Motorola, Inc.
30
31 *
32 * x_fline.sa 3.3 1/10/91
33 *
34 * fpsp_fline --- FPSP handler for fline exception
35 *
36 * First determine if the exception is one of the unimplemented
37 * floating point instructions. If so, let fpsp_unimp handle it.
38 * Next, determine if the instruction is an fmovecr with a non-zero
39 * <ea> field. If so, handle here and return. Otherwise, it
40 * must be a real F-line exception.
41 *
42
43 X_FLINE IDNT 2,1 Motorola 040 Floating Point Software Package
44
45 section 8
46
47 include fpsp.h
48
49 xref real_fline
50 xref fpsp_unimp
51 xref uni_2
52 xref mem_read
53 xref fpsp_fmt_error
54
55 xdef fpsp_fline
56 fpsp_fline:
57 *
58 * check for unimplemented vector first. Use EXC_VEC-4 because
59 * the equate is valid only after a 'link a6' has pushed one more
60 * long onto the stack.
61 *
62 cmp.w #UNIMP_VEC,EXC_VEC-4(a7)
63 beq.l fpsp_unimp
64
65 *
66 * fmovecr with non-zero <ea> handling here
67 *
68 sub.l #4,a7 ;4 accounts for 2-word difference
69 * ;between six word frame (unimp) and
70 * ;four word frame
71 link a6,#-LOCAL_SIZE
72 fsave -(a7)
73 movem.l d0-d1/a0-a1,USER_DA(a6)
74 movea.l EXC_PC+4(a6),a0 ;get address of fline instruction
75 lea.l L_SCR1(a6),a1 ;use L_SCR1 as scratch
76 move.l #4,d0
77 add.l #4,a6 ;to offset the sub.l #4,a7 above so that
78 * ;a6 can point correctly to the stack frame
79 * ;before branching to mem_read
80 bsr.l mem_read
81 sub.l #4,a6
82 move.l L_SCR1(a6),d0 ;d0 contains the fline and command word
83 bfextu d0{4:3},d1 ;extract coprocessor id
84 cmpi.b #1,d1 ;check if cpid=1
85 bne.w not_mvcr ;exit if not
86 bfextu d0{16:6},d1
87 cmpi.b #$17,d1 ;check if it is an FMOVECR encoding
88 bne.w not_mvcr
89 * ;if an FMOVECR instruction, fix stack
90 * ;and go to FPSP_UNIMP
91 fix_stack:
92 cmpi.b #VER_40,(a7) ;test for orig unimp frame
93 bne.b ck_rev
94 sub.l #UNIMP_40_SIZE-4,a7 ;emulate an orig fsave
95 move.b #VER_40,(a7)
96 move.b #UNIMP_40_SIZE-4,1(a7)
97 clr.w 2(a7)
98 bra.b fix_con
99 ck_rev:
100 cmpi.b #VER_41,(a7) ;test for rev unimp frame
101 bne.l fpsp_fmt_error ;if not $40 or $41, exit with error
102 sub.l #UNIMP_41_SIZE-4,a7 ;emulate a rev fsave
103 move.b #VER_41,(a7)
104 move.b #UNIMP_41_SIZE-4,1(a7)
105 clr.w 2(a7)
106 fix_con:
107 move.w EXC_SR+4(a6),EXC_SR(a6) ;move stacked sr to new position
108 move.l EXC_PC+4(a6),EXC_PC(a6) ;move stacked pc to new position
109 fmove.l EXC_PC(a6),FPIAR ;point FPIAR to fline inst
110 move.l #4,d1
111 add.l d1,EXC_PC(a6) ;increment stacked pc value to next inst
112 move.w #$202c,EXC_VEC(a6) ;reformat vector to unimp
113 clr.l EXC_EA(a6) ;clear the EXC_EA field
114 move.w d0,CMDREG1B(a6) ;move the lower word into CMDREG1B
115 clr.l E_BYTE(a6)
116 bset.b #UFLAG,T_BYTE(a6)
117 movem.l USER_DA(a6),d0-d1/a0-a1 ;restore data registers
118 bra.l uni_2
119
120 not_mvcr:
121 movem.l USER_DA(a6),d0-d1/a0-a1 ;restore data registers
122 frestore (a7)+
123 unlk a6
124 add.l #4,a7
125 bra.l real_fline
126
127 end
128