Entries 26.1 KB
Newer Older
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
; 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.
;
; Sources.Entries

;--------------------------------------------------------
Alphabet
        Debug   xx,"Territory : Alphabet entry"

        MOV     r0,#AlphNum
        MOV     PC,LR

;--------------------------------------------------------
AlphabetIdent
        Debug   xx,"Territory : AlphabetIdentifier entry"

        ADR     r0,Alphabet_IdentString
        MOV     PC,LR

Alphabet_IdentString

        DCB     "$AlphabetName",0
        ALIGN


;--------------------------------------------------------
SelectKeyboardHandler

        Push    "r0-r2,LR"

Robert Sprowson's avatar
Robert Sprowson committed
42
        MOV     r0,#OsByte_Alphabet
43 44 45 46 47 48 49 50 51 52 53 54 55
        MOV     r1,#128+TerrNum
        SWI     XOS_Byte
        STRVS   r0,[SP]

        Pull    "r0-r2,PC"

;--------------------------------------------------------
WriteDirection

        MOV     r0,#WriteDir
        MOV     PC,LR

;--------------------------------------------------------
56 57 58 59 60 61
IME

        LDR     r0,=IMESWIChunk
        MOV     PC,LR

;--------------------------------------------------------
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


CharacterPropertyTable

        TEQ     r1,#Property_Control
        ADREQL  r0,ControlTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Uppercase
        ADREQL  r0,UppercaseTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Lowercase
        ADREQL  r0,LowercaseTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Alpha
        ADREQL  r0,AlphaTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Punctuation
        ADREQL  r0,PunctuationTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Space
        ADREQL  r0,SpaceTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Digit
        ADREQL  r0,DigitTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_XDigit
        ADREQL  r0,XDigitTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_Accented
        ADREQL  r0,AccentedTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_ForwardFlow
        ADREQL  r0,ForwardFlowTable
        MOVEQ   PC,LR
        TEQ     r1,#Property_BackwardFlow
        ADREQL  r0,BackwardFlowTable
        MOVEQ   PC,LR

        ADR     r0,ErrorBlock_UnknownProperty
        B       message_errorlookup

ErrorBlock_UnknownProperty
104
        DCD     TerritoryError_UnknownProperty
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
        DCB     "UnkProp",0
        ALIGN

;--------------------------------------------------------
GetLowerCaseTable

        ADRL    r0,ToLowerTable
        MOV     PC,LR

;--------------------------------------------------------
GetUpperCaseTable

        ADRL    r0,ToUpperTable
        MOV     PC,LR

;--------------------------------------------------------
GetControlTable

        ADRL    r0,ToControlTable
        MOV     PC,LR

;--------------------------------------------------------
GetPlainTable

        ADRL    r0,ToPlainTable
        MOV     PC,LR

;--------------------------------------------------------
GetValueTable

        ADRL    r0,ToValueTable
        MOV     PC,LR

;--------------------------------------------------------
GetRepresentationTable

        ADRL    r0,ToRepresentationTable
        MOV     PC,LR

;--------------------------------------------------------
; Collate
;     Entry:
;             R1 -> String 1   (0 terminated)
;             R2 -> String 2   (0 terminated)
;             R3 = flags
;                        bit 0 - Ignore case.
;                        bit 1 - Ignore accents
152
;                        bit 2 - Interpret cardinals numerically
153 154 155 156 157 158 159 160 161 162 163 164 165 166
;     Exit:
;             R0   <0 if S1 < S2
;                  =0 if S1 = S2
;                  >0 if S1 > S2
;             Other registers preserved.
;
;             Z set if equal (EQ).
;             C set and Z clear if S1 > S2 (HI)
;             N set and V clear if S1 < S2 (LT)
;
;             V set if error.

Collate

167
        Push    "r1-r8,LR"
168

169 170
        MOV     r3, r3, LSL #16
        MOV     r3, r3, LSR #16
171 172 173 174

        ; We start off ignoring case and accents
        ORR     r3,r3,#Collate_IgnoreCase :OR: Collate_IgnoreAccent
        ADRL    r4,ToLowerTable
175
        ADRL    r5,ToPlainForCollateTable
176
        ADRL    r7,SortValueTable
177
        ADRL    r8,ToRepresentationTable
178
01
179
        LDRB    r12,[r1],#1
180 181 182
        LDRB    r6 ,[r2],#1


183
        Debug   xx,"r12,r6",r12,r6
184

185
 [ CollateDanishAA
186 187
        TEQ     r12,#'A'
        TEQNE   r12,#'a'
188 189 190 191
        TEQNE   r6, #'A'
        TEQNE   r6, #'a'
        BNE     %FT35

192 193
        TEQ     r12,#'A'
        TEQNE   r12,#'a'
194 195
        BNE     %FT33           ; r6 must be an A/a
        LDRB    r0, [r1]
196
        TEQ     r0, r12
197
        BEQ     %FT31
198
        TEQ     r12,#'A'
199 200 201
        TEQEQ   r0,#'a'
        BNE     %FT32
31
202 203 204
        TEQ     r12,#'A'        ; Got aa, Aa or AA.
        MOVEQ   r12,#''
        MOVNE   r12,#''
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
        ADD     r1, r1, #1

32
        TEQ     r6,#'A'
        TEQNE   r6,#'a'
        BNE     %FT35
33      LDRB    r0, [r2]
        TEQ     r0, r6
        BEQ     %FT34
        TEQ     r6,#'A'
        TEQEQ   r0,#'a'
        BNE     %FT35
34
        TEQ     r6,#'A'         ; Got aa, Aa or AA.
        MOVEQ   r6,#''
        MOVNE   r6,#''
        ADD     r2, r2, #1
35
 ]
224 225 226 227 228 229 230 231
        TST     r3,#Collate_InterpretCardinals
        BEQ     %FT37
        MOV     r0,r12
        BL      is_digit
        MOVEQ   r0,r6
        BLEQ    is_digit
        BEQ     %FT60           ; Both are digits
37
232
        TST     r3,#Collate_IgnoreAccent
233
        LDRNEB  r12,[r5,r12]
234 235
        LDRNEB  r6 ,[r5,r6]

236
        Debug   xx,"r12,r6",r12,r6
237 238

        TST     r3,#Collate_IgnoreCase
239
        LDRNEB  r12,[r4,r12]
240 241
        LDRNEB  r6 ,[r4,r6]

242
        Debug   xx,"r12,r6",r12,r6
243 244

 [ CollateLatin1Ligatures
245 246
        TEQ     r12,#''
        TEQNE   r12,#''
247 248 249 250
        TEQNE   r6, #''
        TEQNE   r6, #''
        BNE     %FT05

251 252
        TEQ     r12,#''
        TEQNE   r12,#''
253 254 255
        BNE     %FT03           ; r6 must be a ligature
        EOR     r3, r3, #&20000000
        TST     r3, #&20000000
256
        MOVNE   r12, #'f'
257 258
        SUBNE   r1, r1, #1
        BNE     %FT02
259 260 261
        TEQ     r12, #''
        MOVEQ   r12, #'i'
        MOVNE   r12, #'l'
262 263 264 265 266 267 268 269 270 271 272 273 274

02      TEQ     r6,#''
        TEQNE   r6,#''
        BNE     %FT05
03      EOR     r3, r3, #&10000000
        TST     r3, #&10000000
        MOVNE   r6, #'f'
        SUBNE   r2, r2, #1
        BNE     %FT05
        TEQ     r6, #''
        MOVEQ   r6, #'i'
        MOVNE   r6, #'l'
05
275 276 277
 ]

 [ CollateOELigatures
278 279
        TEQ     r12,#''
        TEQNE   r12,#''
280 281 282 283
        TEQNE   r6, #''
        TEQNE   r6, #''
        BNE     %FT15

284 285
        TEQ     r12,#''
        TEQNE   r12,#''
286 287 288 289 290
        BNE     %FT13           ; r6 must be a ligature
        EOR     r3, r3, #&08000000
        TST     r3, #&08000000
        BEQ     %FT11
        SUB     r1, r1, #1
291 292 293
        TEQ     r12,#''
        MOVEQ   r12,#'O'
        MOVNE   r12,#'o'
294
        B       %FT12
295 296 297
11      TEQ     r12,#''
        MOVEQ   r12,#'E'
        MOVNE   r12,#'e'
298 299 300 301 302 303 304

12      TEQ     r6,#''
        TEQNE   r6,#''
        BNE     %FT15
13      EOR     r3, r3, #&04000000
        TST     r3, #&04000000
        BEQ     %FT14
305
        SUB     r2, r2, #1
306 307 308 309 310 311 312 313 314 315 316
        TEQ     r6,#''
        MOVEQ   r6,#'O'
        MOVNE   r6,#'o'
        B       %FT15
14      TEQ     r6,#''
        MOVEQ   r6,#'E'
        MOVNE   r6,#'e'
15
 ]

 [ CollateThornAsTH
317 318
        TEQ     r12,#''
        TEQNE   r12,#''
319 320 321 322
        TEQNE   r6, #''
        TEQNE   r6, #''
        BNE     %FT25

323 324
        TEQ     r12,#''
        TEQNE   r12,#''
325 326 327 328 329
        BNE     %FT23           ; r6 must be a thorn
        EOR     r3, r3, #&02000000
        TST     r3, #&02000000
        BEQ     %FT21
        SUB     r1, r1, #1
330 331 332
        TEQ     r12,#''
        MOVEQ   r12,#'T'
        MOVNE   r12,#'t'
333
        B       %FT22
334 335 336
21      TEQ     r12,#''
        MOVEQ   r12,#'H'
        MOVNE   r12,#'h'
337 338 339 340

22      TEQ     r6,#''
        TEQNE   r6,#''
        BNE     %FT25
341 342
23      EOR     r3, r3, #&01000000
        TST     r3, #&01000000
343 344 345 346 347 348 349 350 351 352
        BEQ     %FT24
        SUB     r1, r1, #1
        TEQ     r6,#''
        MOVEQ   r6,#'T'
        MOVNE   r6,#'t'
        B       %FT25
24      TEQ     r6,#''
        MOVEQ   r6,#'H'
        MOVNE   r6,#'h'
25
353 354
 ]

355
 [ CollateGermanSharpS
356
        TEQ     r12, #''
357 358
        EOREQS  r3, r3, #&00800000
        TST     r3, #&00800000
359
        MOVNE   r12, #'s'
360 361 362 363 364 365 366 367 368
        SUBNE   r1, r1, #1

        TEQ     r6, #''
        EOREQS  r3, r3, #&00400000
        TST     r3, #&00400000
        MOVNE   r6, #'s'
        SUBNE   r2, r2, #1
 ]

369
        LDRB    r12,[r7,r12]
370 371
        LDRB    r6 ,[r7,r6]

372
        Debug   xx,"r12,r6",r12,r6
373

374 375 376
        SUBS    r0,r12,r6
        Pull    "r1-r8,PC",NE           ; Not equal, result is result of compare.
        TEQ     r12,#0
377
        BNE     %BT01                   ; Equal but not 0, get next char.
378 379 380
30      LDR     r12,[sp,#8]             ; Get original flags
        EORS    r12,r3,r12
        Pull    "r1-r8,PC",EQ           ; Done desired comparison - they're equal
381

382
 [ :LNOT:CollateAccentsBackwards
383
        LDMIA   sp,{r1,r2}              ; Restore string pointers
384
 ]
385

386
        TST     r12,#Collate_IgnoreAccent ; Do they want us to differ accents?
387
        BICNE   r3,r3,#Collate_IgnoreAccent
388 389 390 391 392
 [ CollateAccentsBackwards
        BNE     %FT40

        LDMIA   sp,{r1,r2}
 |
393
        BNE     %BT01                   ; Back to the top, doing accents this time.
394
 ]
395 396 397

        BIC     r3,r3,#Collate_IgnoreCase ; Already obeying accent directive, so
        B       %BT01                   ; must be disobeying case - check case.
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415

 [ CollateAccentsBackwards
40
; At this point the strings have just compared equal when ignoring case and
; accents. We are about to go around again, looking at accents this time. But
; the important point is that we must scan the string backwards. This is only
; required for French as far as I know, so for now, the following assertions
; will simplify things.

        ASSERT :LNOT: CollateThornAsTH
        ASSERT :LNOT: CollateDanishAA

; We know that the two strings must be of equivalent length, so as we rewind,
; r1 and r2 will hit the start simultaneously (as long as there's nothing
; really bizarre about the ToPlainForCollate table, such as ToPlain(f)='').

        LDR     r5, [sp,#0]             ; get back start of first string
41
416
        LDRB    r12,[r1,#-1]!
417 418
        LDRB    r6 ,[r2,#-1]!

419
        LDRB    r12,[r4,r12]            ; We must be ignoring case at this point
420 421
        LDRB    r6 ,[r4,r6]

422 423 424
      [ CollateLatin1Ligatures
        TEQ     r12,#''
        TEQNE   r12,#''
425 426 427 428
        TEQNE   r6, #''
        TEQNE   r6, #''
        BNE     %FT45

429 430
        TEQ     r12,#''
        TEQNE   r12,#''
431 432 433
        BNE     %FT43           ; r6 must be a ligature
        EOR     r3, r3, #&20000000
        TST     r3, #&20000000
434
        MOVEQ   r12, #'f'
435 436
        BEQ     %FT42
        ADD     r1, r1, #1
437 438 439
        TEQ     r12, #''
        MOVEQ   r12, #'i'
        MOVNE   r12, #'l'
440 441 442 443 444 445 446 447 448 449 450 451 452

42      TEQ     r6,#''
        TEQNE   r6,#''
        BNE     %FT45
43      EOR     r3, r3, #&10000000
        TST     r3, #&10000000
        MOVEQ   r6, #'f'
        BEQ     %FT45
        ADD     r2, r2, #1
        TEQ     r6, #''
        MOVEQ   r6, #'i'
        MOVNE   r6, #'l'
45
453
      ]
454

455 456 457
      [ CollateOELigatures
        TEQ     r12,#''
        TEQNE   r12,#''
458 459 460 461
        TEQNE   r6, #''
        TEQNE   r6, #''
        BNE     %FT55

462 463
        TEQ     r12,#''
        TEQNE   r12,#''
464 465 466 467
        BNE     %FT53           ; r6 must be a ligature
        EOR     r3, r3, #&08000000
        TST     r3, #&08000000
        BNE     %FT51
468 469 470
        TEQ     r12,#''
        MOVEQ   r12,#'O'
        MOVNE   r12,#'o'
471
        B       %FT52
472 473 474
51      TEQ     r12,#''
        MOVEQ   r12,#'E'
        MOVNE   r12,#'e'
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
        ADD     r1, r1, #1

52      TEQ     r6,#''
        TEQNE   r6,#''
        BNE     %FT55
53      EOR     r3, r3, #&04000000
        TST     r3, #&04000000
        BNE     %FT54
        TEQ     r6,#''
        MOVEQ   r6,#'O'
        MOVNE   r6,#'o'
        B       %FT55
54      TEQ     r6,#''
        MOVEQ   r6,#'E'
        MOVNE   r6,#'e'
        ADD     r2, r2, #1
55
492
      ]
493

494
        LDRB    r12,[r7,r12]
495 496
        LDRB    r6 ,[r7,r6]

497 498
        SUBS    r0,r12,r6
        Pull    "r1-r8,PC",NE           ; Not equal, result is result of compare.
499 500 501
        CMP     r1, r5                  ; are we now pointing at the start of the string?
        BNE     %BT41                   ; no, so get next character
        B       %BT30                   ; finished this pass - they're equal. Back to normal processing.
502
 ]
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
60
; Cardinal compare algorithm (ignores sign, decimal point & exponents)
; * Skip leading zeros in both numbers
; * Count length of both numbers
; * If equal length, just do strcmp()
; * If different length, longest wins
        Push    "r1-r2,r4-r5"

        MOV     r0,r12
61      BL      is_zero
        LDREQB  r0,[r1],#1
        BEQ     %BT61
        SUB     r4,r1,#1                ; First non '0'
62      BL      is_digit
        LDREQB  r0,[r1],#1
        BEQ     %BT62                   ; Is a digit

        MOV     r0,r6
63      BL      is_zero
        LDREQB  r0,[r2],#1
        BEQ     %BT63
        SUB     r5,r2,#1                ; First non '0'
64      BL      is_digit
        LDREQB  r0,[r2],#1
        BEQ     %BT64                   ; Is a digit

        SUB     r1,r1,r4                ; Lengths
        SUB     r2,r2,r5
        SUBS    r0,r1,r2
532 533
        LDREQB  r12,[r4],#1
        LDREQB  r6 ,[r5],#1
534 535 536 537
        STMEQIA sp,{r4-r5}

        Pull    "r1-r2,r4-r5"

538
        BEQ     %BT37                   ; Carry on collating from that digit
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
        Pull    "r1-r8,PC"              ; We have a winner

is_digit ROUT
        ; R0 = char, R8 -> representation table
        ; Returns Z=1 if char is entry 0-9 in the table
        Push    "r1,lr"
        MOV     r1,#9
10      LDRB    r14,[r8,r1]
        TEQ     r14,r0
        Pull    "r1,PC",EQ
        SUBS    r1,r1,#1
        BPL     %BT10
        Pull    "r1,PC"                 ; R1 -ve, therefore also NE
is_zero
        Push    "r1,lr"
        MOV     r1,#0
        B       %BT10
556 557 558 559 560

; ------------------------------------------------------------------------
; ReadTimeZones
;
; In:
561 562 563
;       IF R4 = 'ZONE'
;          R1 = timezone to lookup, 0 to NumberOfTZ - 1
;
564
; Out:
565 566 567 568
;       R0 -> name of standard TZ if this territory was in use
;       R1 -> name of summer TZ if this territory was in use
;       R2 = Offset from UTC to standard time
;       R3 = Offset from UTC to summer time.
569
;       IF R4 = 'ZONE' on entry, R4 = 0
570 571
;
ReadTimeZones
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
        LDR     r0, =ReadTimeZones_Extension
        TEQ     r0, r4
        MOVNE   r1, #0                  ; Behave as no extension
        MOVEQ   r4, #0                  ; Denote extension is supported

        CMP     r1, #NumberOfTZ
        ADRCS   r0,ErrorBlock_NoMoreZones
        BCS     message_errorlookup

        GBLA    tz_aligned
        GBLA    tz_tableentry
tz_aligned      SETA ((MaxTZLength + 1) + 3) :AND: :NOT: 3
tz_tableentry   SETA (tz_aligned * 2) + 4 + 4
        ADR     r0, tz_table
        MOV     r3, #tz_tableentry
        MLA     r0, r1, r3, r0
        ADD     r1, r0, #tz_aligned
        LDR     r2, [r0, #0 + (2 * tz_aligned)]
        LDR     r3, [r0, #4 + (2 * tz_aligned)]
        MOV     pc, lr

ErrorBlock_NoMoreZones
        DCD     TerritoryError_NoMoreZones
        DCB     "NMZones",0
        ALIGN
597

598
tz_table
599 600
        GBLA    counter
        GBLS    suffix
601 602 603
        GBLS    strstd
        GBLS    strdst
        GBLS    offstd
604 605 606 607 608 609
        GBLS    offdst
        WHILE   counter < NumberOfTZ
      [ counter >= 16
suffix    SETS  :STR:counter:RIGHT:2
      |
suffix    SETS  :STR:counter:RIGHT:1
610
      ]
611 612 613 614 615 616 617 618 619 620
strstd  SETS    "NODST":CC:suffix
strdst  SETS    "DST":CC:suffix
offstd  SETS    "NODSTOffset":CC:suffix
offdst  SETS    "DSTOffset":CC:suffix
        DCB     $strstd, 0
        SPACE   tz_aligned - 1 - :LEN:$strstd
        DCB     $strdst, 0
        SPACE   tz_aligned - 1 - :LEN:$strdst
        DCD     $offstd
        DCD     $offdst
621 622
counter SETA    counter + 1
        WEND
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671

; ------------------------------------------------------------------------
; ReadSymbols
;
; In:
;       R1 - Reason code:
;               0 Return pointer to 0 terminated decimal point string.
;               1 Return pointer to 0 terminated thousands separator
;               2 Return pointer byte list containing the size of each
;                 group of digits in formatted nonmonetary quantities.
;                 255   = No further grouping
;                   0   = Repeat last grouping for rest of number
;                 other = Size of current group, the next byte contains
;                         the size of the next group of dogits before the
;                          current group.
;               3 Return pointer to 0 terminated international currency symbol.
;               4 Return pointer to 0 terminated currency symbol in local alphabet.
;               5 Return pointer to 0 terminated decimal point used for monetary quantities
;               6 Return pointer to 0 terminated thousands separator for monetary quantities
;               7 Return pointer byte list containing the size of each
;                 group of digits in formatted monetary quantities.
;               8 Return pointer to 0 terminated positive sign used for monetary quantities
;               9 Return pointer to 0 terminated negative sign used for monetary quantities
;              10 Return number of fractional digits to be displayed in an internationally
;                 formatted monetay quantity
;              11 Return number of fractional digits to be displayed in a formatted monetay
;                 quantity
;              12 Return 1 If the currency symbol precedes the value for a nonnegative
;                          formatted monetary quantity
;                        0 If the currency symbol succeeds the value for a nonnegative
;                          formatted monetary quantity
;              13 Return 1 If the currency symbol is separated by a space from the value for a
;                          nonnegative formatted monetary quantity
;                        0 If the currency symbol is not separated by a space from the value for a
;                          nonnegative formatted monetary quantity
;              14 Return 1 If the currency symbol precedes the value for a negative
;                          formatted monetary quantity
;                        0 If the currency symbol succeeds the value for a negative
;                          formatted monetary quantity
;              15 Return 1 If the currency symbol is separated by a space from the value for a
;                          negative formatted monetary quantity
;                        0 If the currency symbol is not separated by a space from the value for a
;                          negative formatted monetary quantity
;
;              16 Return for a nonnegative formatted monetary quantity
;                        0 If there are parentheses arround the quantity and currency symbol.
;                        1 If the sign string precedes the quantity and currency symbol.
;                        2 If the sign string succeeds the quantity and currency symbol.
;                        3 If the sign string immediately precedes the currency symbol.
672
;                        4 If the sign string immediately succeeds the currency symbol.
673 674 675 676 677
;              17 Return for a negative formatted monetary quantity
;                        0 If there are parentheses arround the quantity and currency symbol.
;                        1 If the sign string precedes the quantity and currency symbol.
;                        2 If the sign string succeeds the quantity and currency symbol.
;                        3 If the sign string immediately precedes the currency symbol.
678
;                        4 If the sign string immediately succeeds the currency symbol.
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
;              18 Return pointer to 0 terminated list separator
; Out:
;       R0 - Requested value.
ReadSymbols
        Push    "LR"

        ADR     R14,SymbolTable
        LDR     R0,[R14,R1,ASL #2]
        CMP     R0,#20
        ADDGE   R0,R0,R14

        Pull    "PC"

SymbolTable
        DCD     decimal_point           - SymbolTable
        DCD     thousands_sep           - SymbolTable
        DCD     grouping                - SymbolTable
        DCD     int_curr_symbol         - SymbolTable
        DCD     currency_symbol         - SymbolTable
        DCD     mon_decimal_point       - SymbolTable
        DCD     mon_thousands_sep       - SymbolTable
        DCD     mon_grouping            - SymbolTable
        DCD     positive_sign           - SymbolTable
        DCD     negative_sign           - SymbolTable
        DCD     int_frac_digits
        DCD     frac_digits
        DCD     p_cs_precedes
        DCD     p_sep_by_space
        DCD     n_cs_precedes
        DCD     n_sep_by_space
        DCD     p_sign_posn
        DCD     n_sign_posn
        DCD     list_symbol             - SymbolTable

decimal_point           DCB     "$Decimal",0
thousands_sep           DCB     "$Thousand",0
grouping                DCB     $Grouping
int_curr_symbol         DCB     "$IntCurr",0
currency_symbol         DCB     "$Currency",0
mon_decimal_point       DCB     "$MDecimal",0
mon_thousands_sep       DCB     "$MThousand",0
mon_grouping            DCB     $MGrouping
positive_sign           DCB     "$MPositive",0
negative_sign           DCB     "$MNegative",0
list_symbol             DCB     "$ListSymbol",0
        ALIGN

;---------------------------------------------------------------------------------
;ReadCalendarInformation
;
;In:
;   R1 = Pointer to 5 byte UTC time value.
Robert Sprowson's avatar
Robert Sprowson committed
731
;   R2 = Pointer to a 12 word buffer
732 733 734 735 736
;
;Out:
;
;   R1,R2 Preserved.
;
Robert Sprowson's avatar
Robert Sprowson committed
737
;   [R2+0]  = Number of first working day in the week.
738 739
;   [R2+4]  = Number of last working day in the week.
;   [R2+8]  = Number of months in the current year.
Robert Sprowson's avatar
Robert Sprowson committed
740
;             (current = one in which given time falls)
741
;   [R2+12] = Number of days in the current month.
Robert Sprowson's avatar
Robert Sprowson committed
742
;             (current = one in which given time falls)
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
;   [R2+16] = Max length of AM/PM string.
;   [R2+20] = Max length of WE string.
;   [R2+24] = Max length of W3 string.
;   [R2+28] = Max length of DY string.
;   [R2+32] = Max length of ST string (May be 0).
;   [R2+36] = Max length of MO string.
;   [R2+40] = Max length of M3 string.
;   [R2+44] = Max length of TZ string.
;
GetCalendarInformation
        Push    "r0-r11,LR"

        ADR     LR,CalendarInfo
        LDMIA   LR,{R0,R3-R11,LR}       ; Load fixed 11 items
        STMIA   R2!,{R0,R3,R4}          ; First three
        STMIB   R2,{R5-R11,LR}          ; Skip one, then next 8

760
        SWI     XTerritory_ReadCurrentTimeZone
761
        BVS     %FT02
762 763 764 765 766

        MOV     R2,R1
        LDR     R1,[SP,#1*4]
        BL      GetTimeValues

767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
        ADRL    R0,MonthLengths
        LDRB    R0,[R0,R1]              ; Get length of month
        CMP     R1,#2                   ; Is Feb ?
        BNE     %FT01

        TST     R6, #3                  ; is year multiple of 4
        MOVNE   R0,#28                  ; no, then 29 Feb is bad
        BNE     %FT01

        TEQ     R6, #0                  ; is it a century year ?
        BNE     %FT01                   ; no, then 29 Feb is good

        TST     R5, #3                  ; is it a multiple of 400 ?
        MOVNE   R0,#28                  ; no, then 29 Feb is bad
01
        LDR     R2,[SP,#2*4]
        STR     R0,[R2,#12]
02
        STRVS   r0,[SP]
        Pull    "r0-r11,PC"

CalendarInfo
        DCD     FirstWorkDay    ; First working day in week 1=Sunday 7=Saturday
        DCD     LastWorkDay     ; Last  working day in week 1=Sunday 7=Saturday
        DCD     NumberOfMonths  ; Number of month in a year

        DCD     MaxAMPMLength   ; Max length of AM PM String
        DCD     MaxWELength     ; Max length of full day name
        DCD     MaxW3Length     ; Max length of short day name
        DCD     MaxDYLength     ; Max length of day in month
        DCD     MaxSTLength     ; Max length of st nd rd th ... string
        DCD     MaxMOLength     ; Max length of full month name.
        DCD     MaxM3Length     ; Max length of short month name.
        DCD     MaxTZLength     ; Max length of time zone name.

;---------------------------------------------------------------------------------
;NameToNumber
;
;In:
;   R1 = Pointer to territory name.
;
;Out:
;   R0 = 0 - Unknown territory
;        Else territory number.
NameToNumber     ROUT
        Entry   "r1-r7",8               ; We know tokens aren't long.

        BL      open_messages_file

; Enumerate all territory name tokens (TRnn)
817
        ADR     r0,message_file_block
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
        MOV     R4,#0                   ; First call
        ADR     R7,ToLowerTable

01
        ADR     R1,territory_token
        MOV     R2,SP
        MOV     R3,#8
        SWI     XMessageTrans_EnumerateTokens
        EXIT    VS
        CMP     R2,#0
        MOVEQ   r0,#0
        EXIT    EQ

; Get Message

        DebugS  xx,"Next token is ",R2
        MOV     R1,R2                   ; Token.
        MOV     R2,#0                   ; Don't copy message !
        SWI     XMessageTrans_Lookup
        EXIT    VS

; Got message, now compare with territory name in string.

        LDR     R1,[SP,#8]              ; get user R1
02
        LDRB    R14,[R2],#1
        CMP     R14,#10
        BEQ     %FT03                   ; End of message
        LDRB    R14,[R7,R14]            ; Lower case

        LDRB    R10,[R1],#1
        CMP     R10,#0
        MOVEQ   r0,#0
        EXIT    EQ
        LDRB    R10,[R7,R10]            ; Lower case

        CMP     R14,R10
        BEQ     %BT02                   ; Try next character.
856
        B       %BT01                   ; Try next token.
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871
03
        LDRB    R10,[R1],#1
        CMP     R10,#" "
        BGE     %BT01                   ; Not end of user input !

        MOV     R0,#10                  ; Check token number
        ADD     R1,SP,#2
        SWI     XOS_ReadUnsigned
        MOVVC   R0,R2
        EXIT

territory_token
        DCB     "TR*",0
        ALIGN

872
        LNK     Tables.s
873