x_fline.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. |
  2. | x_fline.sa 3.3 1/10/91
  3. |
  4. | fpsp_fline --- FPSP handler for fline exception
  5. |
  6. | First determine if the exception is one of the unimplemented
  7. | floating point instructions. If so, let fpsp_unimp handle it.
  8. | Next, determine if the instruction is an fmovecr with a non-zero
  9. | <ea> field. If so, handle here and return. Otherwise, it
  10. | must be a real F-line exception.
  11. |
  12. | Copyright (C) Motorola, Inc. 1990
  13. | All Rights Reserved
  14. |
  15. | For details on the license for this file, please see the
  16. | file, README, in this same directory.
  17. X_FLINE: |idnt 2,1 | Motorola 040 Floating Point Software Package
  18. |section 8
  19. #include "fpsp.h"
  20. |xref real_fline
  21. |xref fpsp_unimp
  22. |xref uni_2
  23. |xref mem_read
  24. |xref fpsp_fmt_error
  25. .global fpsp_fline
  26. fpsp_fline:
  27. |
  28. | check for unimplemented vector first. Use EXC_VEC-4 because
  29. | the equate is valid only after a 'link a6' has pushed one more
  30. | long onto the stack.
  31. |
  32. cmpw #UNIMP_VEC,EXC_VEC-4(%a7)
  33. beql fpsp_unimp
  34. |
  35. | fmovecr with non-zero <ea> handling here
  36. |
  37. subl #4,%a7 |4 accounts for 2-word difference
  38. | ;between six word frame (unimp) and
  39. | ;four word frame
  40. link %a6,#-LOCAL_SIZE
  41. fsave -(%a7)
  42. moveml %d0-%d1/%a0-%a1,USER_DA(%a6)
  43. moveal EXC_PC+4(%a6),%a0 |get address of fline instruction
  44. leal L_SCR1(%a6),%a1 |use L_SCR1 as scratch
  45. movel #4,%d0
  46. addl #4,%a6 |to offset the sub.l #4,a7 above so that
  47. | ;a6 can point correctly to the stack frame
  48. | ;before branching to mem_read
  49. bsrl mem_read
  50. subl #4,%a6
  51. movel L_SCR1(%a6),%d0 |d0 contains the fline and command word
  52. bfextu %d0{#4:#3},%d1 |extract coprocessor id
  53. cmpib #1,%d1 |check if cpid=1
  54. bne not_mvcr |exit if not
  55. bfextu %d0{#16:#6},%d1
  56. cmpib #0x17,%d1 |check if it is an FMOVECR encoding
  57. bne not_mvcr
  58. | ;if an FMOVECR instruction, fix stack
  59. | ;and go to FPSP_UNIMP
  60. fix_stack:
  61. cmpib #VER_40,(%a7) |test for orig unimp frame
  62. bnes ck_rev
  63. subl #UNIMP_40_SIZE-4,%a7 |emulate an orig fsave
  64. moveb #VER_40,(%a7)
  65. moveb #UNIMP_40_SIZE-4,1(%a7)
  66. clrw 2(%a7)
  67. bras fix_con
  68. ck_rev:
  69. cmpib #VER_41,(%a7) |test for rev unimp frame
  70. bnel fpsp_fmt_error |if not $40 or $41, exit with error
  71. subl #UNIMP_41_SIZE-4,%a7 |emulate a rev fsave
  72. moveb #VER_41,(%a7)
  73. moveb #UNIMP_41_SIZE-4,1(%a7)
  74. clrw 2(%a7)
  75. fix_con:
  76. movew EXC_SR+4(%a6),EXC_SR(%a6) |move stacked sr to new position
  77. movel EXC_PC+4(%a6),EXC_PC(%a6) |move stacked pc to new position
  78. fmovel EXC_PC(%a6),%FPIAR |point FPIAR to fline inst
  79. movel #4,%d1
  80. addl %d1,EXC_PC(%a6) |increment stacked pc value to next inst
  81. movew #0x202c,EXC_VEC(%a6) |reformat vector to unimp
  82. clrl EXC_EA(%a6) |clear the EXC_EA field
  83. movew %d0,CMDREG1B(%a6) |move the lower word into CMDREG1B
  84. clrl E_BYTE(%a6)
  85. bsetb #UFLAG,T_BYTE(%a6)
  86. moveml USER_DA(%a6),%d0-%d1/%a0-%a1 |restore data registers
  87. bral uni_2
  88. not_mvcr:
  89. moveml USER_DA(%a6),%d0-%d1/%a0-%a1 |restore data registers
  90. frestore (%a7)+
  91. unlk %a6
  92. addl #4,%a7
  93. bral real_fline
  94. |end