Commit 6ffb001b authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Missed out this file in previous checkin

parent 826581a6
hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
......
; Copyright 1999 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
a1 RN 0
a2 RN 1
a3 RN 2
a4 RN 3
v1 RN 4
v2 RN 5
ip RN 12
sp RN 13
lr RN 14
pc RN 15
AREA |C$$code|, CODE, READONLY
EXPORT muldiv
;;;; IMPORT raise
muldiv
; muldiv(a, b, c)
; result = a*b/c
; the intermediate product is 64 bits long
; do everything using moduluses, and sort out signs later
STMFD sp!, {a1, a2, a3, a4, v1, v2, lr}
; first, the double-length product, returned in a3 & a4
; uses ip, a1 and a2 as workspace
MOV a3, #0
MOV a4, #0
MOV ip, #0
CMPS a2, #0
RSBLT a2, a2, #0 ; abs b
MOV v2, a2
CMPS a1, #0
RSBLT a1, a1, #0 ; abs a
muldiv0
MOVS a2, a2, LSR #1
BCC muldiv1
ADDS a4, a4, a1
ADC a3, a3, ip
muldiv1
MOVS a1, a1, ASL #1
ADC ip, ip, ip
CMPS a2, #0
BNE muldiv0
; now the 64*32 bit divide
; dividend in a3 and a4
; remainder ends up in a4; quotient in ip
; uses a1 and a2 to hold the (shifted) divisor;
; v1 for the current bit in the quotient
LDR a2, [sp, #8] ; recover divisor
CMPS a2, #0
LDMEQFD sp!, {a1-a4, v1, v2, pc}^
;;was BEQ muldiv_by_0, but we might be a module
RSBLT a2, a2, #0 ; abs c
MOV v2, a2
MOV ip, #0
MOV a1, #0
MOV v1, #0
MOV lr, #1
muldiv2
CMPS a1, #&80000000
BCS muldiv3
CMPS a1, a3
CMPEQS a2, a4 ; compare of [a1, a2] against [a3, a4]
BCS muldiv3
MOVS a2, a2, ASL #1
MOV a1, a1, ASL #1
ADC a1, a1, #0
ADD v1, v1, #1
B muldiv2
muldiv3
CMPS a1, a3
CMPEQS a2, a4
BHI muldiv4
CMPS v1, #31
ADDLE ip, ip, lr, ASL v1
SUBS a4, a4, a2
SBC a3, a3, a1
muldiv4
MOVS a1, a1, ASR #1
MOV a2, a2, RRX
SUBS v1, v1, #1
BGE muldiv3
; now all we need to do is sort out the signs.
LDMFD sp!, {a1, a2, a3, v1}
EOR a2, a2, a1 ; a2 has the sign of a*b: a3 is the sign of c
MOV a1, ip
TEQS a2, a3 ; if a*b and c have opposite signs,
RSBMI a1, a1, #0 ; negate the quotient
CMPS a2, #0 ; and if the dividend was negative,
RSBLT a4, a4, #0 ; negate the remainder
;;;; Now discard the remainder - J R C 19 March 1991
;;;; STR a4, [v1]
LDMFD sp!, {v1, v2, pc}^
muldiv_by_0 ;not used
;;;; LDMFD sp!, {a1-a4, v1, v2, lr}
;;;; MOV a1, #2 ; SIGFPE
;;;; B raise
END
; Copyright 1999 Pace Micro Technology plc
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; veneer.s - filter veneer
GBLL Trace
Trace SETL {FALSE}
GBLL Small_Stubs
Small_Stubs SETL {FALSE}
GET OS:Hdr.Types
IMPORT main_post_filter
IMPORT main_pre_filter
AREA |C$$code|, CODE, READONLY
;;; ENTRY
;;; IMPORT |__module_header|
;---------------------------------------------------------------------------
EXPORT veneer_post_filter
veneer_post_filter
; Entry
; A1 = event code for event about to be returned
; A2 -> event block
; A3 = task handle
; IP -> task record (passed to Filter_RegisterPostFilter)
; owner task paged in
; SVC mode, interrupts enabled
; Exit
; A1 = replacement event code, or -1 (none)
; A2 -> (possibly modified) event block
STMFD SP!, {A2, A3, A4, V1, V2, V3, SL, FP, IP, LR}
[ Trace
SWI XHostFS_HostVdu
SWI XOS_WriteS
= 10, "s.veneer,36: veneer_post_filter", 13, 10, 0
SWI XHostFS_TubeVdu
]
MOV SL, SP, LSR #20
MOV SL, SL, ASL #20 ; SP_LWM
LDMIA SL, {V1, V2, V3} ; save reloc modifiers
MOV A4, IP
; A4 -> task record
LDR IP, [IP, #8]
; IP -> module workspace (offsetof (dialogue_task_list, workspace) is 8)
LDR IP, [IP]
; IP -> static data
[ Small_Stubs
LDMIA IP, {FP, IP, LR} ; new relocation modifiers
STMIA SL, {FP, IP, LR} ; set by module init
|
LDMIB IP, {FP, IP} ; new relocation modifiers
STMIA SL, {FP, IP} ; set by module init
]
ADD SL, SL, #540 ; C magic
; A1 = event code for event about to be returned
; A2 -> event block
; A3 = task handle
; A4 = workspace pointer
BL main_post_filter
; A1 = replacement event code, or -1 (none)
; A2, A3, A4 corrupted
SUB SL, SL, #540 ; C magic
STMIA SL, {V1, V2, V3} ; restore reloc modifiers
LDMFD SP!, {A2, A3, A4, V1, V2, V3, SL, FP, IP, PC}^
;---------------------------------------------------------------------------
EXPORT veneer_pre_filter
veneer_pre_filter
; Entry
; A1 = event mask
; A2 -> event block
; A3 = task handle
; IP -> task record (passed to Filter_RegisterPreFilter)
; owner task paged in
; SVC mode, interrupts enabled
; Exit
; A1 = replacement event mask
STMFD SP!, {A2, A3, A4, V1, V2, V3, SL, FP, IP, LR}
[ Trace
SWI XHostFS_HostVdu
SWI XOS_WriteS
= 10, "s.veneer,90: veneer_pre_filter", 13, 10, 0
SWI XHostFS_TubeVdu
]
MOV SL, SP, LSR #20
MOV SL, SL, ASL #20 ; SP_LWM
LDMIA SL, {V1, V2, V3} ; save reloc modifiers
MOV A4, IP
; A4 -> task record
LDR IP, [IP, #8]
; IP -> module workspace (offsetof (dialogue_task_list, workspace) is 8)
LDR IP, [IP]
; IP -> static data
[ Small_Stubs
LDMIA IP, {FP, IP, LR} ; new relocation modifiers
STMIA SL, {FP, IP, LR} ; set by module init
|
LDMIB IP, {FP, IP} ; new relocation modifiers
STMIA SL, {FP, IP} ; set by module init
]
ADD SL, SL, #540 ; C magic
; A1 = event mask
; A2 -> event block
; A3 = task handle
; A4 = workspace pointer
BL main_pre_filter
; A1 = replacement event mask
; A2, A3, A4 corrupted
SUB SL, SL, #540 ; C magic
STMIA SL, {V1, V2, V3} ; restore reloc modifiers
LDMFD SP!, {A2, A3, A4, V1, V2, V3, SL, FP, IP, PC}^
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment