summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/FPESTUB.S
blob: f015a1881e393315b3e61d4e2a60d6032c2fb49a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
;;; fpestub.s: library stub for fpe400 (emulator for fp instruction set 3)
;;;
;;; Copyright (C) Advanced RISC Machines Ltd., 1993

;;; RCS $Revision: 1.5 $
;;; Checkin $Date: 1994/01/24 14:19:42 $
;;; Revising $Author: irickard $

        AREA    |FP$$code|, CODE

        IMPORT  __rt_trap, WEAK                 ; from run-time kernel...

; change FPE_ to FPS_ to allow FPA support code to be incorporated in library
; (there is currently no veneer support for the combined FPE/FPASC)
        IMPORT  FPE_Install
        IMPORT  FPE_DeInstall
        EXPORT  FPE_GenerateError               ; to FPE

        EXPORT  __fp_initialise                 ; to client
        EXPORT  __fp_finalise                   ; to client
        EXPORT  __fp_address_in_emulator        ; to client

        IMPORT  |FP$$code$$Base|
        IMPORT  |FP$$code$$Limit|


; RISCOS SWI names (for use in very_standalone only).

Write0     * 2 + (1:SHL:17)
NewLine    * 3 + (1:SHL:17)
Exit       * &11

;******************************************************************************
;


__fp_initialise
        B       FPE_Install

__fp_finalise
        B       FPE_DeInstall

;******************************************************************************
;
;       Come here for a floating point exception, such as divide by zero.
;
; r0 = error descriptor
; r1 -> cpu register dump
;

FPE_GenerateError
; still in some non-user mode...
        LDR     r2, =|__rt_trap|
        CMP     r2, #0
        BEQ     very_standalone
        ADD     r3, r1, #r13*4
        LDMIA   r3, {r13}^              ; retrieve user's sp
        NOP
        MOVS    pc, r2                  ; to __rt_ in user mode


very_standalone
 [ {CONFIG} = 26
        TEQP    pc, #0                  ; to user mode
 |
        MSR     CPSR_ctl, #&10          ; to user32
 ]
        ADD     r0, r0, #4              ; ignore the error code
        SWI     Write0                  ; write the message
        SWI     NewLine
        BL      |__fp_finalise|         ; tidy the ill-instr vector
        SWI     Exit                    ; and exit

|__fp_address_in_emulator|
        ; for the benefit of abort handling, determine whether an address
        ; is within the code of the fp emulator.  (Allowing a data abort or
        ; address exception in a floating-point load or store to be reported
        ; as occurring at that instruction, rather than somewhere in the code
        ; of the emulator).
 [ {CONFIG} = 26
        BIC     r0, r0, #&fc000003      ; remove PSR bits in case
 ]
        LDR     r1, =|FP$$code$$Base|
        CMP     r0, r1
        LDRGT   r1, =|FP$$code$$Limit|
        CMPGT   r1, r0
        MOVLE   r0, #0
        MOVGT   r0, #1
 [ {CONFIG} = 26
        MOVS    pc, lr
 |
        MOV     pc, lr
 ]
        LTORG

        END