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