File indexing completed on 2025-05-11 08:23:49
0001 #include "fpsp-namespace.h"
0002 //
0003 //
0004 // x_fline.sa 3.3 1/10/91
0005 //
0006 // fpsp_fline --- FPSP handler for fline exception
0007 //
0008 // First determine if the exception is one of the unimplemented
0009 // floating point instructions. If so, let fpsp_unimp handle it.
0010 // Next, determine if the instruction is an fmovecr with a non-zero
0011 // <ea> field. If so, handle here and return. Otherwise, it
0012 // must be a real F-line exception.
0013 //
0014
0015 // Copyright (C) Motorola, Inc. 1990
0016 // All Rights Reserved
0017 //
0018 // THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
0019 // The copyright notice above does not evidence any
0020 // actual or intended publication of such source code.
0021
0022 X_FLINE: //idnt 2,1 | Motorola 040 Floating Point Software Package
0023
0024 |section 8
0025
0026 #include "fpsp.defs"
0027
0028 |xref real_fline
0029 |xref fpsp_unimp
0030 |xref uni_2
0031 |xref mem_read
0032 |xref fpsp_fmt_error
0033
0034 .global fpsp_fline
0035 fpsp_fline:
0036 //
0037 // check for unimplemented vector first. Use EXC_VEC-4 because
0038 // the equate is valid only after a 'link a6' has pushed one more
0039 // long onto the stack.
0040 //
0041 cmpw #UNIMP_VEC,EXC_VEC-4(%a7)
0042 beql fpsp_unimp
0043
0044 //
0045 // fmovecr with non-zero <ea> handling here
0046 //
0047 subl #4,%a7 //4 accounts for 2-word difference
0048 // ;between six word frame (unimp) and
0049 // ;four word frame
0050 link %a6,#-LOCAL_SIZE
0051 fsave -(%a7)
0052 moveml %d0-%d1/%a0-%a1,USER_DA(%a6)
0053 moveal EXC_PC+4(%a6),%a0 //get address of fline instruction
0054 leal L_SCR1(%a6),%a1 //use L_SCR1 as scratch
0055 movel #4,%d0
0056 addl #4,%a6 //to offset the sub.l #4,a7 above so that
0057 // ;a6 can point correctly to the stack frame
0058 // ;before branching to mem_read
0059 bsrl mem_read
0060 subl #4,%a6
0061 movel L_SCR1(%a6),%d0 //d0 contains the fline and command word
0062 bfextu %d0{#4:#3},%d1 //extract coprocessor id
0063 cmpib #1,%d1 //check if cpid=1
0064 bne not_mvcr //exit if not
0065 bfextu %d0{#16:#6},%d1
0066 cmpib #0x17,%d1 //check if it is an FMOVECR encoding
0067 bne not_mvcr
0068 // ;if an FMOVECR instruction, fix stack
0069 // ;and go to FPSP_UNIMP
0070 fix_stack:
0071 cmpib #VER_40,(%a7) //test for orig unimp frame
0072 bnes ck_rev
0073 subl #UNIMP_40_SIZE-4,%a7 //emulate an orig fsave
0074 moveb #VER_40,(%a7)
0075 moveb #UNIMP_40_SIZE-4,1(%a7)
0076 clrw 2(%a7)
0077 bras fix_con
0078 ck_rev:
0079 cmpib #VER_41,(%a7) //test for rev unimp frame
0080 bnel fpsp_fmt_error //if not $40 or $41, exit with error
0081 subl #UNIMP_41_SIZE-4,%a7 //emulate a rev fsave
0082 moveb #VER_41,(%a7)
0083 moveb #UNIMP_41_SIZE-4,1(%a7)
0084 clrw 2(%a7)
0085 fix_con:
0086 movew EXC_SR+4(%a6),EXC_SR(%a6) //move stacked sr to new position
0087 movel EXC_PC+4(%a6),EXC_PC(%a6) //move stacked pc to new position
0088 fmovel EXC_PC(%a6),%FPIAR //point FPIAR to fline inst
0089 movel #4,%d1
0090 addl %d1,EXC_PC(%a6) //increment stacked pc value to next inst
0091 movew #0x202c,EXC_VEC(%a6) //reformat vector to unimp
0092 clrl EXC_EA(%a6) //clear the EXC_EA field
0093 movew %d0,CMDREG1B(%a6) //move the lower word into CMDREG1B
0094 clrl E_BYTE(%a6)
0095 bsetb #UFLAG,T_BYTE(%a6)
0096 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 //restore data registers
0097 bral uni_2
0098
0099 not_mvcr:
0100 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 //restore data registers
0101 frestore (%a7)+
0102 unlk %a6
0103 addl #4,%a7
0104 bral real_fline
0105
0106 |end