mac-rom/OS/FPUEmulation/XUnImp.a
Elliot Nunn 4325cdcc78 Bring in CubeE sources
Resource forks are included only for .rsrc files. These are DeRezzed into their data fork. 'ckid' resources, from the Projector VCS, are not included.

The Tools directory, containing mostly junk, is also excluded.
2017-12-26 09:52:23 +08:00

167 lines
4.2 KiB
Plaintext

;
; File: XUnImp.a
;
; Contains: Routines to handle the Unimplemented Instruction exception
;
; Originally Written by: Motorola Inc.
; Adapted to Apple/MPW: Jon Okada
;
; Copyright: © 1990-1993 by Apple Computer, Inc., all rights reserved.
;
; This file is used in these builds: Mac32
;
; Change History (most recent first):
;
; <SM2> 2/3/93 CSS Update from Horror:
; <H2> 10/5/92 BG (for Jon Okada) Replaced one constant to fix the problem Jon
; reported to Motorola. See Jon's change log below for more info.
; <2> 3/30/91 BG Rolling in Jon Okada's latest changes.
; <1> 12/14/90 BG First checked into TERROR/BBS.
; xunimp.a
; Based upon Motorola files 'x_unimp.sa' and 'sto_res.sa'
; fpsp_unimp
; CHANGE LOG:
; 26 Aug 92 JPO Retain quotient bit field in USER_FPSR (was cleared in
; D25B fix code).
;
*
* x_unimp.sa 3.1 12/10/90
*
* fpsp_unimp --- FPSP handler for unimplemented instruction
* exception.
*
* Invoked when the user program encounters a floating-point
* op-code that hardware does not support. Trap vector# 11
* (See table 8-1 MC68030 User's Manual).
*
*
* Note: An fsave for an unimplemented inst. will create a short
* fsave stack.
*
* Input: 1. Six word stack frame for unimplemented inst, four word
* for illegal
* (See table 8-7 MC68030 User's Manual).
* 2. Unimp (short) fsave state frame created here by fsave
* instruction.
*
*
* 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.
* X_UNIMP IDNT 2,1 Motorola 040 Floating Point Software Package
fpsp_unimp:
link a6,#-LOCAL_SIZE
fsave -(a7)
uni_2:
movem.l d0-d1/a0-a1,USER_DA(a6)
fmovem.x fp0-fp3,USER_FP0(a6)
fmovem.l fpcr/fpsr/fpiar,USER_FPCR(a6)
move.b (a7),d0 ;test for valid version num
andi.b #$f0,d0 ;test for $4x
cmpi.b #VER_4,d0 ;must be $4x or exit
bne fpsp_fmt_error
*
* Temporary D25B Fix
* The following lines are used to ensure that the FPSR
* exception byte and condition codes are clear before proceeding
*
move.l USER_FPSR(a6),d0
and.l #$00FF00FF,d0 ;clear all but quotient and accrued exceptions <H2>
move.l d0,USER_FPSR(a6)
fmove.l #0,FPSR ;clear all user bits
fmove.l #0,FPCR ;clear all user exceptions for FPSP
clr.b UFLG_TMP(a6) ;clr flag for unsupp data
bsr get_op ;go get operand(s)
clr.b STORE_FLG(a6)
bsr do_func ;do the function
fsave -(a7) ;capture possible exc state
tst.b STORE_FLG(a6)
bne.b no_store ;if STORE_FLG is set, no store
bsr.b sto_res ;store the result in user space
no_store:
bra gen_except ;post any exceptions and return
; sto_res
; CHANGE LOG:
; 09 Jan 91 JPO Renamed label "fp0123" to "is_fp0123". Deleted
; label "is_fp3" (not referenced).
;
*
* sto_res.sa 3.1 12/10/90
*
* Takes the result and puts it in where the user expects it.
* Library functions return result in fp0. If fp0 is not the
* users destination register then fp0 is moved to the the
* correct floating-point destination register. fp0 and fp1
* are then restored to the original contents.
*
* Input: result in fp0
*
* d2 & a0 should be kept unmodified
*
* Output: moves the result to the true destination reg or mem
*
* Modifies: destination floating point register
*
* 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.
* STO_RES IDNT 2,1 Motorola 040 Floating Point Software Package
sto_res:
bfextu CMDREG1B(a6){6:3},d0 ;extract destination register
cmpi.b #3,d0 ;check for fp0-fp3 cases
ble.b is_fp0123 ; renamed label <1/9/91, JPO>
fmovem.x fp0,-(a7)
moveq.l #7,d1
sub.l d0,d1 ;d1 = 7- (dest. reg. no.)
clr.l d0
bset.l d1,d0 ;d0 is dynamic register mask
fmovem.x (a7)+,d0
rts
is_fp0123: ; renamed label <1/9/91, JPO>
cmpi.b #0,d0
beq.b is_fp0
cmpi.b #1,d0
beq.b is_fp1
cmpi.b #2,d0
beq.b is_fp2
;is_fp3: ; label DELETED <1/9/91, JPO>
fmovem.x fp0,USER_FP3(a6)
rts
is_fp2:
fmovem.x fp0,USER_FP2(a6)
rts
is_fp1:
fmovem.x fp0,USER_FP1(a6)
rts
is_fp0:
fmovem.x fp0,USER_FP0(a6)
rts