Commit f7d78f97 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Made assembler code APCS-R compatible!!

  Retained old code as 32-bit APCS compatible on the usual switches.
Detail:
  ANT were clearly ahead of their time when they wrote all of
    this assembler, because none of it bothers to preserve the
    PSR flags like the C code requires them to.  Could this
    perhaps be a contributing factor to why Omni is so unstable?!
Admin:
  Requires AsmUtils.
  Intermediate version. Do not use.
parent 7527ac33
......@@ -24,9 +24,12 @@
; 26-01-96 Add CollectCallbacks
; **************************************************
GET Hdr.RegNames
GET Hdr.SwiNames
GET Hdr.ResourceFS
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Machine.<Machine>
GET Hdr:APCS.<APCS>
GET Hdr:ResourceFS
; ---------------------------
......@@ -134,15 +137,24 @@ fsentry_common ; os_error *fsentry_common( Parameter_Block * )
MOVNE r0, R8
; Mess about with the flag bits in R8
[ :LNOT: No32bitCode
; If we're allowed to use 32-bit code, it all falls out really nicely
MOVNE R8, #V_bit ; R8 == 0 if Z, V set if !Z
|
MOV R8, pc
BIC R8, R8, #C_bit + V_bit
ORRNE R8, R8, #V_bit ; V = err != 0
]
TST r1, r1 ; C = r1 == 0
ORREQ R8, R8, #C_bit
; Move the flag bits into psr
[ :LNOT: No32bitCode
MSR CPSR_f, r8
|
TEQP R8, #0
MOV R0,R0 ; added 980127:RCE
NOP
]
LDMFD SP!, {R8}
......@@ -170,11 +182,11 @@ fsentry_branchtable
EXPORT OmniS_Suicide
OmniS_Suicide ; (char *modulename)
STMFD SP!, {r14}
FunctionEntry
MOV r1, r0 ; save module_title address (called as r12)
ADR r0, suicide_cb
SWI XOS_AddCallBack
LDMFD SP!, {pc}
Return
suicide_cb
STMFD SP!, {r0-r1, r14}
......@@ -192,22 +204,18 @@ suicide_cb
; in the Z bit. For this reason the routine calls our 'FreeOp'
; SWI.
; Free module only worried about V and Z, doesn't mind C and N being
; corrupted. Removed all the unnecessary flag todging and non-32-bit
; friendly code: V is already set correctly, the TEQ sets the Z as
; required. Yes, the return value is already stacked. (sbrodie: 19/11/99)
EXPORT Free_ServiceRoutine
Free_ServiceRoutine ; On entry R0 = reason code 0-3
STMFD SP!, {R1, R4}
SWI XLanMan_FreeOp
MOV R4, PC
BIC R4, R4, #V_bit + C_bit + Z_bit
ORRVS R4, R4, #V_bit ; V set & R0->error block if error
CMP R1, #0 ; Set Z if R1 was 0 on exit
ORREQ R4, R4, #Z_bit
TEQP R4, #0 ; Set flags to PC
MOV R0,R0 ; added 980127:RCE
LDMFD SP!, {R1, R4}
LDMIA R13!, {PC} ; As it says in book
TEQ R1,#0 ; set Z if R1 was 0 on exit, preserve V
LDMFD SP!, {R1, R4, PC} ; As it says in book
DCB "Nothing libellous or obscene", 0 ; Contractual obligation
ALIGN
......@@ -217,7 +225,7 @@ Free_ServiceRoutine ; On entry R0 = reason code 0-3
EXPORT CollectCallbacks ; (void)
CollectCallbacks
STMFD SP!, {LR}
FunctionEntry
TSTP PC,#&FC ;Set User mode.
MOV R0, R0
......@@ -229,7 +237,7 @@ CollectCallbacks
SWI OS_EnterOS ;Set SVC mode.
MOV R0, R0
LDMFD SP!, {PC}^
Return
; Long multiplier ----------------------------------------
; Taken from Acorn Assembler manual.
......@@ -237,6 +245,7 @@ CollectCallbacks
EXPORT OmniS_FastMultiply64
OmniS_FastMultiply64
FunctionEntry
STMFD sp!, {lr}
MOVS lr, a2, LSR #16
BIC a2, a2, lr, LSL #16
......@@ -251,7 +260,7 @@ OmniS_FastMultiply64
ADDS a4, a4, a2, LSL #16
ADC lr, lr, a2, LSR #16
STMIA a1, {a4, lr}
LDMFD sp!, {pc}^
Return
......@@ -266,28 +275,28 @@ OmniS_FastMultiply64
; Register & Deregister routines for our ResourceFS block
OmniS_ResourceInit ; (void)
STMFD sp!, {r14}
FunctionEntry
ADR r0, Resource_Base
SWI XResourceFS_RegisterFiles
MOVVC r0, #0
LDMFD sp!, {pc}
Return
OmniS_ResourceShutdown ; (void)
STMFD sp!, {r14}
FunctionEntry
ADR r0, Resource_Base
SWI XResourceFS_DeregisterFiles
MOVVC r0, #0
LDMFD sp!, {pc}
Return
OmniS_ResFSStarting ; (int R2, int R3 )
; Dunno what this does!!
STMFD sp!, {r14}
FunctionEntry
MOV r2, r0
MOV r3, r1
ADR r0, Resource_Base
MOV r14, pc
MOV pc, r2
LDMFD sp!, {pc}^
Return
; Data block
......
; Copyright 1998 Acorn Computers Ltd
;
; 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.
;
; Assembler function to give RM base address to C program
IMPORT |Image$$RO$$Base|
EXPORT Image_RO_Base
AREA Code_Description, DATA, REL
Image_RO_Base DCD |Image$$RO$$Base|
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