Tail 5.01 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
; Copyright 1996 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.
;
; > s.Tail

;-----------------------------------------------------------------------------------------
; cmpstr.
;
; compare the strings pointed to by r0 and r1 (case insensitive).
cmpstr
       Push     "r0-r2,LR"

01
       LDRB     r14,[r0],#1
       BIC      r14,r14,#&20
       LDRB     r2,[r1],#1
       BIC      r2,r2,#&20
       CMP      r14,r2
       Pull     "r0-r2,PC",NE
       CMP      r14,#0
       BNE      %BT01

       Pull     "r0-r2,PC"

; [ :LNOT: usefp
;;-----------------------------------------------------------------------------------------
;; divrem.
;;
;; divides r9 by r10. result in r9, reminder in r10.
;divrem
;       Push    "LR"

;       Debuga  xx,"Div ",r9,r10

;       CMP     r10,#0
;       MOVEQ   r9,#0
;       Pull   "PC",EQ
;
;       MOV     r14,#0
;01
;       SUBS    r9,r9,r10
;       BCC     %FT02
;       ADD     r14,r14,#1
;       B       %BT01
;02
;       ADD     r10,r9,r10
;       MOV     r9,r14

;       Debug   xx," = ",r9,r10

;       Pull    "PC"
; ]

 [ {FALSE}      ; no longer used
;-----------------------------------------------------------------------------------------
; round.
;
; Rounds r0 to the nearest whole multiple of r1.
round
        Push    "LR"

        ADD     r0,r0,r1,LSR #1     ; Add half of R1
        MOV     r14,#0
01
        SUBS    r0,r0,r1
        BMI     %FT02
        ADD     r14,r14,#1
        B       %BT01
02
        MUL     r0,r1,r14

        Pull    "PC"
 ]
; ----------------------------------------------------------------------------------------------------------------------
;       Release linked lists of files/icons. Note - may be in USER mode or SVC mode - can't use USER stack,
;       though, as it may not be okay. Hence not allowed to use the stack at all.
;    R2 -> pointer to start of list to kill (active_ptr or buffered_ptr)
;        DANGER - CORRUPTS R0-R3
free_list
        MOV     R3, LR
        LDR     r1, [r2,#next_ptr]
        MOV     r0, #0
        STR     r0, [r2,#next_ptr]
; Get next file in the list
01
        MOV     r0, #ModHandReason_Free
        SUBS    r2, r1, #0
        MOVLE   PC, R3
; Free the workspace
        LDR     r1, [r2,#next_ptr]
        SWI     XOS_Module
        B       %BT01

; ----------------------------------------------------------------------------------------------------------------------

copy_r0r4r3_space

        Push    "r3,r4,LR"
01
        LDRB    r14, [r4], #1
        CMP     r14,#32
        MOVLE   R14,#0
        STRB    r14, [r0], #1
        SUBS    r3 , r3,#1
        CMPNE   r14, #0
        BNE     %BT01
        CMP     r3,#0
        STREQB  r3,[r0],#1
        SUB     r0, r0, #1

        Pull    "r3,r4,PC"

; ----------------------------------------------------------------------------------------------------------------------

; MessageTrans routines

LookupError
        Push    "r1-r7,lr"
        BL      open_messages
        Pull    "r1-r7,pc",VS
        MOV     r4, r1
        ADR     r1, message_fblock
        MOV     r2, #0
        MOV     r5, #0
        MOV     r6, #0
        MOV     r7, #0
        SWI     XMessageTrans_ErrorLookup
        Pull    "r1-r7,pc"

message_filename
        DCB     "Free:Messages",0
        ALIGN

open_messages
        Push    "r0-r2,lr"
        LDR     r0, message_fopen
        CMP     r0, #0
        Pull    "r0-r2,pc",NE
        ADR     r0, message_fblock
        ADR     r1, message_filename
        MOV     r2, #0
        SWI     XMessageTrans_OpenFile
        STRVS   r0, [sp]
        STRVC   r0, message_fopen
        Pull    "r0-r2,pc"

Lookup_InPlace  ROUT
        Push    "r1-r7,LR"
        BL      open_messages
        Pull    "r1-r7,PC",VS
        MOV     r1,r0
        ADR     r0,message_fblock
        MOV     r2,#0
        MOV     R4,#0
        MOV     R5,#0
        MOV     R6,#0
        MOV     R7,#0
        SWI     XMessageTrans_Lookup
        MOVVC   r0,r2
        Pull    "r1-r7,PC"

Lookup  ROUT                ; r0 -> token, r2 -> buffer , r3 = buf length ,r4 -> arg
        Push    "r1-r7,LR"
        BL      open_messages
        Pull    "r1-r7,PC",VS
        MOV     r1,r0
        ADR     r0,message_fblock
        MOV     R5,#0
        MOV     R6,#0
        MOV     R7,#0
        SWI     XMessageTrans_Lookup
        MOVVC   r0,r2
        STRVC   r3,[sp,#2*4]
        Pull    "r1-r7,PC"

; ----------------------------------------------------------------------------------------------------------------------



; Neil's debugging routines

      [ debug
        InsertNDRDebugRoutines
      ]

        END