MsgCode 19 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
; 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.
;
; Kernel.Messages
;
; This file deals with translating text and errors in an international
; kernel.
;
;
; TranslateError
; Entry:
;       R0 = Pointer to error block (Error number followed by token:default).
; Exit
;       R0 = pointer to error block to use.
;            If the error semaphore is set a pointer to the original block is
;            returned.
;       V Set.
;
30 31 32 33 34 35 36

        GBLL    countmsgusage
countmsgusage SETL {FALSE}
     [ countmsgusage
        ! 0,    "*** WARNING: Cacheing *ALL* messages - even those with substitutions"
     ]

Neil Turton's avatar
Neil Turton committed
37 38 39 40
TranslateError_VClear  ROUT
        Push    "r4,LR"
        MOV     r4,#0
        BL      TranslateError_UseR4
Kevin Bracey's avatar
Kevin Bracey committed
41 42 43 44
 [ No26bitCode
        CLRV
        Pull    "r4,PC"
 |
Neil Turton's avatar
Neil Turton committed
45
        Pull    "r4,PC",,^
Kevin Bracey's avatar
Kevin Bracey committed
46
 ]
Neil Turton's avatar
Neil Turton committed
47 48 49 50 51 52 53 54

TranslateError  ROUT
        Push    "r4,LR"
        MOV     r4,#0
        BL      TranslateError_UseR4
        Pull    "r4,PC"

TranslateError_UseR4
55
        Push    "R8,R9,LR"
56
        MRS     R8,CPSR
Kevin Bracey's avatar
Kevin Bracey committed
57
        ORR     R8,R8,#V_bit                    ; V set ready :)
Neil Turton's avatar
Neil Turton committed
58

Kevin Bracey's avatar
Kevin Bracey committed
59 60 61 62 63
        MOV     LR,#0
        LDRB    LR, [LR, #ErrorSemaphore]
        TEQ     LR,#0
        BNE     %FT90

64 65
        BIC     R9, R8, #&0F
        ORR     R9, R9, #SVC_mode               ; SVC mode, preserve IRQ state
66
        MSR     CPSR_c, R9
Neil Turton's avatar
Neil Turton committed
67

68
        Push    "R0-R7"
Neil Turton's avatar
Neil Turton committed
69 70 71 72

        MOV     R5,#0
        MOV     R6,#0
        MOV     R7,#0
73 74 75 76 77 78
        MOV     R1,#-1                          ; We are looking up an error, don't bother
        STRB    R1, [R5, #ErrorSemaphore]       ; translating other errors.

  [ CacheCommonErrors
        BL      CheckCommonErrorCache           ; sets R9 to memory address for cached result
        MOVNE   R1,#0
Stewart Brodie's avatar
Stewart Brodie committed
79
        STRNE   R9,[SP]
80 81 82 83 84 85 86 87
        BNE     %FT80
        MOV     R2,R9                           ; 0 - or our cached area!
        MOV     R3,#256
  |
        MOV     R2,#0
  ]

        ADR     R1,KernelMessagesBlock+4
Neil Turton's avatar
Neil Turton committed
88 89 90 91 92 93 94
        SWI     XMessageTrans_ErrorLookup
        LDR     R14,[R0]
        LDR     R1,[SP]
        LDR     R1,[R1]
        CMP     R14,R1
        STREQ   R0,[SP]

95 96 97 98 99 100
        MOV     R1,#0                           ; To clear the semaphore
  [ CacheCommonErrors
        TEQNE   R9,#0                           ; Did we try to cache this message?
        STRNE   R1,[R9]                         ; blat out the error number
80
  ]
Neil Turton's avatar
Neil Turton committed
101 102
        STRB    R1, [R1 ,#ErrorSemaphore]       ; Clear error semaphore

103
        Pull    "R0-R7"
Kevin Bracey's avatar
Kevin Bracey committed
104
90
105
        MSR     CPSR_cf, R8                     ; Back to original mode, V set
106 107 108 109 110
        Pull    "R8,R9,PC"

  [ CacheCommonErrors
   ; This block MUST not be empty
CommonErrorAddresses
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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    [ countmsgusage
        &       ErrorBlock_RCExc
        &       ErrorBlock_RCNegative
        &       ErrorBlock_BadString
        &       ErrorBlock_VarCantFind
        &       ErrorBlock_BadVarType
        &       ErrorBlock_BadVarNam
        &       ErrorBlock_VarTooLong
        &       ErrorBlock_BadMacVal
        &       ErrorBlock_VarNoRoom
        &       ErrorBlock_BadBra
        &       ErrorBlock_StkOFlo
        &       ErrorBlock_MissOpn
        &       ErrorBlock_MissOpr
        &       ErrorBlock_BadInt
        &       ErrorBlock_StrOFlo
        &       ErrorBlock_NaffItm
        &       ErrorBlock_DivZero
        &       ErrorBlock_BadBase
        &       ErrorBlock_NumbTooBig
        &       ErrorBlock_BadClaimNum
        &       ErrorBlock_SysHeapFull
        &       ErrorBlock_BadDynamicArea
        &       ErrorBlock_AreaAlreadyExists
        &       ErrorBlock_AreaNotOnPageBdy
        &       ErrorBlock_OverlappingAreas
        &       ErrorBlock_CantAllocateArea
        &       ErrorBlock_CantAllocateLevel2
        &       ErrorBlock_UnknownAreaHandler
        &       ErrorBlock_CantGetPhysMem
        &       ErrorBlock_AplWSpaceInUse
        &       ErrorBlock_ChDynamCAO
        &       ErrorBlock_RAMFsUnchangeable
        &       ErrorBlock_HeapBadReason
        &       ErrorBlock_HeapFail_Init
        &       ErrorBlock_HeapFail_BadDesc
        &       ErrorBlock_HeapFail_BadLink
        &       ErrorBlock_HeapFail_Alloc
        &       ErrorBlock_HeapFail_NotABlock
        &       ErrorBlock_HeapFail_BadExtend
        &       ErrorBlock_HeapFail_ExcessiveShrink
        &       ErrorBlock_NoSuchSWI1
        &       ErrorBlock_NoSuchSWI
        &       ErrorBlock_UndefinedInstruction
        &       ErrorBlock_InstructionAbort
        &       ErrorBlock_DataAbort
        &       ErrorBlock_AddressException
        &       ErrorBlock_BranchThrough0
        &       ErrorBlock_BadEnvNumber
        &       ErrorBlock_BadReadSysInfo
        &       ErrorBlock_BadModuleReason
        &       ErrorBlock_NoMoreModules
        &       ErrorBlock_NoMoreIncarnations
        &       ErrorBlock_PostfixNeeded
        &       ErrorBlock_IncarnationExists
        &       ErrorBlock_ChunkNotRM
        &       ErrorBlock_MHNoRoom
        &       ErrorBlock_ModulePostfix
        &       ErrorBlock_NotMod
        &       ErrorBlock_BadRMHeaderField
        &       ErrorBlock_CantKill
        &       ErrorBlock_RMNotFound
        &       ErrorBlock_IncarnationNotFound
        &       ErrorBlock_RMNotFoundInROM
        &       ErrorBlock_ModuleTooOld
        &       ErrorBlock_BadParameters
        &       ErrorBlock_ArgRepeated
        &       ErrorBlock_NaffDevNo
        &       ErrorBlock_BadDevVecRel
        &       ErrorBlock_RedirectFail
        &       ErrorBlock_StackFull
        &       ErrorBlock_OscliLongLine
        &       ErrorBlock_NoOscliSpecials
        &       ErrorBlock_OscliTooHard
        &       ErrorBlock_BadParmString
        &       ErrorBlock_CoreNotWriteable
        &       ErrorBlock_CoreNotReadable
        &       ErrorBlock_BadCommand
        &       ErrorBlock_NoSuchSWI2
        &       ErrorBlock_TooManyParms
        &       ErrorBlock_BadKey
        &       ErrorBlock_BadAddress
        &       ErrorBlock_OutsideFile
        &       ErrorBlock_Escape
        &       ErrorBlock_BadTime
        &       ErrorBlock_BadMODE
        &       ErrorBlock_ModeNotAvailable
        &       ErrorBlock_BadPixelDepth
        &       ErrorBlock_Sprite_BadDPI
        &       ErrorBlock_BadMSFlags
        &       SpriteErr_NoWorkSpace
        &       SpriteErr_NoRoom
        &       SpriteErr_DoesntExist
        &       SpriteErr_NoSprites
        &       SpriteErr_NotGraphics
        &       SpriteErr_NotEnoughRoom
        &       SpriteErr_BadSpriteFile
        &       SpriteErr_NoRoomToMerge
        &       SpriteErr_Bad2ndPtr
        &       SpriteErr_InvalidRowOrCol
        &       SpriteErr_InvalidHeight
        &       SpriteErr_InvalidWidth
        &       SpriteErr_NoRoomToInsert
        &       SpriteErr_SpriteAlreadyExists
        &       SpriteErr_InvalidSpriteMode
        &       SpriteErr_BadReasonCode
        &       SpriteErr_CantInTeletext
        &       SpriteErr_InvalidSaveArea
        &       SpriteErr_SpriteIsCurrentDest
        &       SpriteErr_NoMaskOrPaletteAllowedInThisDepth
     ]
222 223
        &       ErrorBlock_ChDynamNotAllMoved
        &       ErrorBlock_NaffRelease
224 225
        &       ErrorBlock_BuffOverflow
        &       ErrorBlock_BadNumb
226 227 228 229 230 231 232 233
EndCommonErrorAddresses

        GBLA    ECEACount
ECEACount SETA  (EndCommonErrorAddresses-CommonErrorAddresses)/4
        ASSERT  (EndCommonErrorAddresses <> CommonErrorAddresses)

        ! 0, "Requiring ":CC:(:STR:(ECEACount*256)):CC:" bytes for error cache"
        ! 0, "Cached error block pointer at ":CC::STR:CachedErrorBlocks
234
        ! 0, "Cacheing ":CC:(:STR:ECEACount):CC:" error messages"
235 236 237 238 239 240

; This routine exits with Z clear if it can supply a cached translation; else must set Z
; so that the TranslateError_UseR4 routine continues to function and set R9 to the cache
; block to use for the result (or set R9 to zero to indicate no cacheing for this error)
CheckCommonErrorCache ROUT
        Entry   "r1-r3"
241 242 243
    [ countmsgusage
        MOV     r4, #0                      ; prevents substitutions
    |
244 245 246
        CMP     r4, #1                      ; is R4 = 0?  If so, clear C for next instruction
        SBCS    r9, r4, r4                  ; R9=0,Z set - if R4 was >0, else R9=-1, Z clear
        EXIT    EQ
247
    ]
248 249 250 251 252
        LDR     r9, [r4, #KernelMessagesBlock] ; R4 guaranteed zero from above
        TEQ     r9, #0
        EXIT    EQ                          ; not initialised messages yet!  Exit R9=0, Z set
        LDR     r9, [r4, #CachedErrorBlocks]
        TEQ     r9, #0
Stewart Brodie's avatar
Stewart Brodie committed
253
        ; in:  R9=cached error blocks memory pointer
254
        BLEQ    CommonErrorCacheInit
Stewart Brodie's avatar
Stewart Brodie committed
255 256
        ; out: R9=0 and EQ on error; else NE and R9 valid (also case if routine wasn't called)
        EXIT    EQ                          ; not initialised cache yet
257 258 259 260 261 262 263 264 265 266 267 268
        ADR     lr, CommonErrorAddresses
        MOV     r2, #ECEACount - 1
10
        LDR     r1, [lr, r2, LSL #2]
        TEQ     r1, r0
        BEQ     %FT20
        SUBS    r2, r2, #1
        BPL     %BT10
        ; Set Z if message not found, set R9 zero to mark we don't want to cache this
        MOVS    r9, #0
        EXIT
20
269 270 271 272 273 274
    [ countmsgusage
        ADD     r3, r9, #ECEACount*256
        LDR     r1, [r3, r2, LSL #2]
        ADD     r1, r1, #1
        STR     r1, [r3, r2, LSL #2]
    ]
Stewart Brodie's avatar
Stewart Brodie committed
275 276
        ; Read the cached error number (0 = we don't have this cached or we have uncached it)
        ; Update R9 to point to the actual error buffer at the same time.
277 278
        LDR     r1, [r9, r2, LSL #8]!
        ; Set Z if we don't have that error cached yet, clear it and copy the cached
Stewart Brodie's avatar
Stewart Brodie committed
279
        ; block to R0 if we do already have this message.
280 281 282 283
        TEQ     r1, #0
        MOVNE   r0, r9
        EXIT

Stewart Brodie's avatar
Stewart Brodie committed
284 285 286 287 288 289
; On entry, R9 points to the error cache memory, or 0 to indicate we don't have it yet.
; If this routine exits Z clear (NE), it MUST have pointed R9 at the sys heap memory
CommonErrorCacheInit ROUT
        Entry   "r0-r8"
        MOVS    r2, r9                          ; copy R9 to R2 - only claim memory if it was 0
        BNE     %FT10
290 291 292
    [ countmsgusage
        LDR     r3, =ECEACount*260              ; size of block required
    |
Stewart Brodie's avatar
Stewart Brodie committed
293
        LDR     r3, =ECEACount*256              ; size of block required
294
    ]
295
        BL      ClaimSysHeapNode
Stewart Brodie's avatar
Stewart Brodie committed
296 297 298
        MOVS    r9, #0                          ; set Z for STREQ below and for return
        EXIT    VS
10
299
        MOV     r3, #0
Stewart Brodie's avatar
Stewart Brodie committed
300
        STREQ   r2, [R3, #CachedErrorBlocks]
301 302 303

        GBLA    CECLoop
CECLoop SETA    0
304 305 306 307 308 309 310
     [ countmsgusage
        LDR     r4, =ECEACount*260
90
        SUBS    r4, r4, #4
        STR     r3, [r2, r4]
        BNE     %BT90
     |
311
        WHILE CECLoop < ECEACount
Stewart Brodie's avatar
Stewart Brodie committed
312
          STR   r3, [r2, #CECLoop * 256]
313 314
CECLoop SETA    CECLoop+1
        WEND
315
     ]
316

Stewart Brodie's avatar
Stewart Brodie committed
317 318 319 320 321 322 323 324 325 326 327
        MOVS    r9, r2                          ; set up R9; clear Z
        EXIT

; Invoked by the service call handler in the UtilityModule to clear out our cache
; whenever the territory changes or messagetrans says that a messages file was changed.
CacheCommonErrorsReinit
        Entry   "r9"
        MOV     r9, #0
        LDR     r9, [r9, #CachedErrorBlocks]
        TEQ     r9, #0
        BLNE    CommonErrorCacheInit
328 329
        EXIT
  ]
Neil Turton's avatar
Neil Turton committed
330 331 332 333 334 335 336 337 338 339 340 341 342 343

;----------------------------------------------------------------------------------------
;
;WriteS_Translated
;Entry:
;       R14 -> Token.
;*NOTE*
;      MUST BE TOKEN:DEFAULT
;
;Exit:
;       Message printed
;       Returns to word after end of token.
;
WriteS_Translated       ROUT
Kevin Bracey's avatar
Kevin Bracey committed
344 345 346
 [ No26bitCode
        Push    "r0-r8,LR"
 |
Neil Turton's avatar
Neil Turton committed
347
        Push    "r0-r7,LR"
Kevin Bracey's avatar
Kevin Bracey committed
348
 ]
Neil Turton's avatar
Neil Turton committed
349 350 351 352 353
        MOV     r4,#0
        B       Int_WriteS_Translated_UseR4

WriteS_Translated_UseR4

Kevin Bracey's avatar
Kevin Bracey committed
354 355 356
 [ No26bitCode
        Push    "r0-r8,LR"
 |
Neil Turton's avatar
Neil Turton committed
357
        Push    "r0-r7,LR"
Kevin Bracey's avatar
Kevin Bracey committed
358
 ]
Neil Turton's avatar
Neil Turton committed
359 360

Int_WriteS_Translated_UseR4
Kevin Bracey's avatar
Kevin Bracey committed
361
 [ No26bitCode
362
        MRS     r8,CPSR
Kevin Bracey's avatar
Kevin Bracey committed
363 364 365 366
        MOV     r1,LR
 |
        BIC     r1,LR,#ARM_CC_Mask              ; r1 -> Token.
 ]
Neil Turton's avatar
Neil Turton committed
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
        MOV     r0,#0
        LDR     r0,[r0,#KernelMessagesBlock]
        CMP     r0,#0                           ; If no messages file, try the global one.
        ADRNE   r0,KernelMessagesBlock+4
        MOV     r2,#0                           ; Use message in place.
        MOV     r3,#0
        MOV     r5,#0
        MOV     r6,#0
        MOV     r7,#0                           ; No arguments.
        SWI     XMessageTrans_Lookup
        BVC     %FT01

        MOV     R2,R1                           ; MessageTrans not present or token not found.
00
        LDRB    r0,[r2],#1                      ; Skip to after ":"
        CMP     r0,#":"
        BNE     %BT00

; Now
; r1 -> terminator
; r2 -> message
; Print the message.

01
        LDRB    r0,[r2],#1                      ; Print all characters of message
        CMP     r0,#" "
        BLT     %FT02
        CMP     r0,#"%"
        SWINE   XOS_WriteC
        BNE     %BT01

        LDRB    r0,[r2],#1                      ; Found a %
        CMP     r0,#" "
        BLT     %FT02                           ; Trailing % sign!
        CMP     r0,#"0"
        SWINE   XOS_WriteI+"%"
        SWINE   XOS_WriteC
        BNE     %BT01                           ; Just in case it isn't %0

        CMP     r4,#0                           ; r4 = original parameter
        BEQ     %BT01

11
        LDRB    R0,[R4],#1
        CMP     R0,#" "
        SWIGE   XOS_WriteC
        BGE     %BT11
        B       %BT01
                                                ; Now skip to end of token.
02
Kevin Bracey's avatar
Kevin Bracey committed
417 418 419
 [ No26bitCode
        LDR     r1,[sp,#9*4]                    ; Get original token pointer
 |
Neil Turton's avatar
Neil Turton committed
420
        LDR     r1,[sp,#8*4]                    ; Get original token pointer
Kevin Bracey's avatar
Kevin Bracey committed
421 422
        BIC     r1,r1,#ARM_CC_Mask              ; r1 -> Token.
 ]
Neil Turton's avatar
Neil Turton committed
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
03
        LDRB    r0,[r1],#1
        CMP     r0,#32
        BGE     %BT03                           ; Skip to control character.
04
        CMP     r0,#0                           ; Print all control characters to terminating 0.
        SWINE   XOS_WriteC
        LDRNEB  r0,[r1],#1
        BNE     %BT04

; r1 now points at byte after end of token.

        ADD     r1,r1,#3                        ; Round up to next word.
        BIC     r1,r1,#3

Kevin Bracey's avatar
Kevin Bracey committed
438 439 440
 [ No26bitCode
        STR     r1,[sp,#9*4]                    ; Store back as return address on stack
        ORRVS   r8,r8,#V_bit
441
        MSR     CPSR_f,r8
Kevin Bracey's avatar
Kevin Bracey committed
442 443 444

        Pull    "r0-r8,PC"                       ;Return.
 |
Neil Turton's avatar
Neil Turton committed
445
        LDR     r2,[sp,#8*4]
Kevin Bracey's avatar
Kevin Bracey committed
446
        AND     r2,r2,#ARM_CC_Mask              ; Just the flags and mode bits.
Neil Turton's avatar
Neil Turton committed
447 448 449 450
        ORR     r1,r1,r2
        ORRVS   r1,r1,#V_bit
        STR     r1,[sp,#8*4]                    ; Store back as return address on stack

Kevin Bracey's avatar
Kevin Bracey committed
451 452
        Pull    "r0-r7,PC",,^                    ;Return.
 ]
Neil Turton's avatar
Neil Turton committed
453 454 455 456 457 458 459 460 461 462 463 464 465 466

;----------------------------------------------------------------------------------------
;
;GSWriteS_Translated
;Entry:
;       R14 -> Token.
;*NOTE*
;      MUST BE TOKEN:DEFAULT
;
;Exit:
;       Message printed
;       Returns to word after end of token.
;
GSWriteS_Translated       ROUT
Kevin Bracey's avatar
Kevin Bracey committed
467 468 469
 [ No26bitCode
        Push    "r0-r8,LR"
 |
Neil Turton's avatar
Neil Turton committed
470
        Push    "r0-r7,LR"
Kevin Bracey's avatar
Kevin Bracey committed
471
 ]
Neil Turton's avatar
Neil Turton committed
472 473 474 475 476
        MOV     r4,#0
        B       Int_GSWriteS_Translated_UseR4

GSWriteS_Translated_UseR4

Kevin Bracey's avatar
Kevin Bracey committed
477 478 479
 [ No26bitCode
        Push    "r0-r8,LR"
 |
Neil Turton's avatar
Neil Turton committed
480
        Push    "r0-r7,LR"
Kevin Bracey's avatar
Kevin Bracey committed
481
 ]
Neil Turton's avatar
Neil Turton committed
482 483

Int_GSWriteS_Translated_UseR4
Kevin Bracey's avatar
Kevin Bracey committed
484
 [ No26bitCode
485
        MRS     r8,CPSR
Kevin Bracey's avatar
Kevin Bracey committed
486 487 488 489
        MOV     r1,LR
 |
        BIC     r1,LR,#ARM_CC_Mask              ; r1 -> Token.
 ]
Neil Turton's avatar
Neil Turton committed
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
        MOV     r0,#0
        LDR     r0,[r0,#KernelMessagesBlock]
        CMP     r0,#0                           ; If no messages file, try the global one.
        ADRNE   r0,KernelMessagesBlock+4
        LDR     r2,=GeneralMOSBuffer
        MOV     r3,#256
        MOV     r5,#0
        MOV     r6,#0
        MOV     r7,#0                           ; No arguments.
        SWI     XMessageTrans_GSLookup
        BVC     %FT01

        MOV     R2,R1                           ; MessageTrans not present or token not found.
00
        LDRB    r0,[r2],#1                      ; Skip to after ":"
        CMP     r0,#":"
        BNE     %BT00

; Now
; r1 -> terminator
; r2 -> message
; Print the message using OS_PrettyPrint.

01
        LDR     r0, =GeneralMOSBuffer
        MOV     r1, #0
        SWI     XOS_PrettyPrint
                                                ; Now skip to end of token.
02
Kevin Bracey's avatar
Kevin Bracey committed
519 520 521
 [ No26bitCode
        LDR     r1,[sp,#9*4]                    ; Get original token pointer
 |
Neil Turton's avatar
Neil Turton committed
522
        LDR     r1,[sp,#8*4]                    ; Get original token pointer
Kevin Bracey's avatar
Kevin Bracey committed
523 524
        BIC     r1,r1,#ARM_CC_Mask              ; r1 -> Token.
 ]
Neil Turton's avatar
Neil Turton committed
525 526 527 528 529 530 531 532 533 534
03
        LDRB    r0,[r1],#1
        CMP     r0,#0
        BNE     %BT03                           ; Skip to 0.

; r1 now points at byte after end of token.

        ADD     r1,r1,#3                        ; Round up to next word.
        BIC     r1,r1,#3

Kevin Bracey's avatar
Kevin Bracey committed
535 536 537
 [ No26bitCode
        STR     r1,[sp,#9*4]                    ; Store back as return address on stack
        ORRVS   r8,r8,#V_bit
538
        MSR     CPSR_f,r8
Kevin Bracey's avatar
Kevin Bracey committed
539 540 541

        Pull    "r0-r8,PC"                       ;Return.
 |
Neil Turton's avatar
Neil Turton committed
542
        LDR     r2,[sp,#8*4]
Kevin Bracey's avatar
Kevin Bracey committed
543
        AND     r2,r2,#ARM_CC_Mask              ; Just the flags and mode bits.
Neil Turton's avatar
Neil Turton committed
544 545 546 547 548
        ORR     r1,r1,r2
        ORRVS   r1,r1,#V_bit
        STR     r1,[sp,#8*4]                    ; Store back as return address on stack

        Pull    "r0-r7,PC",,^                    ;Return.
Kevin Bracey's avatar
Kevin Bracey committed
549
 ]
Neil Turton's avatar
Neil Turton committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563

;----------------------------------------------------------------------------------------
;FindToken
;
;Entry:
;       R0 -> Token.
;*NOTE*
;      MUST BE TOKEN:DEFAULT
;
;Exit:
;       r0 -> Message, or after the : if MessageTrans is dead.
;
;
FindToken      ROUT
Kevin Bracey's avatar
Kevin Bracey committed
564 565
 [ No26bitCode
        Push    "r0-r8,LR"
566
        MRS     r8,CPSR
Kevin Bracey's avatar
Kevin Bracey committed
567
 |
Neil Turton's avatar
Neil Turton committed
568
        Push    "r0-r7,LR"
Kevin Bracey's avatar
Kevin Bracey committed
569
 ]
Neil Turton's avatar
Neil Turton committed
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592

        MOV     r1,r0
        MOV     r0,#0
        LDR     r0,[r0,#KernelMessagesBlock]
        CMP     r0,#0                           ; If no messages file, try the global one.
        ADRNE   r0,KernelMessagesBlock+4
        MOV     r2,#0
        MOV     r3,#0
        MOV     r4,#0
        MOV     r5,#0
        MOV     r6,#0
        MOV     r7,#0                           ; No arguments.
        SWI     XMessageTrans_Lookup
        BVC     %FT01

        MOV     R2,R1                           ; MessageTrans not present or token not found.
00
        LDRB    r0,[r2],#1                      ; Skip to after ":"
        CMP     r0,#":"
        BNE     %BT00
01
        STR     r2,[sp]

Kevin Bracey's avatar
Kevin Bracey committed
593
 [ No26bitCode
594
        MSR     CPSR_f,r8
Kevin Bracey's avatar
Kevin Bracey committed
595 596
        Pull    "r0-r8,PC"
 |
Neil Turton's avatar
Neil Turton committed
597
        Pull    "r0-r7,PC",,^
Kevin Bracey's avatar
Kevin Bracey committed
598 599
 ]

Neil Turton's avatar
Neil Turton committed
600 601 602 603 604 605 606 607 608 609 610 611
;----------------------------------------------------------------------------------------
;Write0_Translated
;
;Entry:
;       R0 -> Token.
;*NOTE*
;      MUST BE TOKEN:DEFAULT
;
;Exit:
;        Message printed, r0->Message.
;
Write0_Translated ROUT
Kevin Bracey's avatar
Kevin Bracey committed
612
        EntryS  "r0,r1"
Neil Turton's avatar
Neil Turton committed
613 614 615 616 617 618 619
        BL      FindToken
        MOV     R1,R0
01
        LDRB    R0,[R1],#1
        CMP     R0,#31
        SWIGT   XOS_WriteC
        STRVS   r0,[SP]
Kevin Bracey's avatar
Kevin Bracey committed
620
        EXIT    VS
Neil Turton's avatar
Neil Turton committed
621 622
        BGT     %BT01

Kevin Bracey's avatar
Kevin Bracey committed
623
        EXITS
Neil Turton's avatar
Neil Turton committed
624 625 626 627 628 629 630

        END