Home » Archimedes archive » Archimedes World » archimedes_world_volume_15_issue_2_scp.adf » !ARMwrest_ARMwrest » ID2

ID2

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » archimedes_world_volume_15_issue_2_scp.adf » !ARMwrest_ARMwrest
Filename: ID2
Read OK:
File size: 09BD bytes
Load address: 0000
Exec address: 0000
File contents
   10LIBRARY "MRC/MCR"
   20LIBRARY "DecodeID"
   30
   40ON ERROR PRINT REPORT$;" at ";ERL:END
   50
   60DIM code% 1000
   70
   80FOR pass%=0 TO 2 STEP 2
   90
  100P% = code%
  110
  120[     OPT pass%
  130      stmfd     r13!,{r14}
  140      mov       r0,#1                            ; undefined instruction handler
  150      adr       r1,undefined_instruction_handler ; the address of the handler
  160      mov       r2,#0                            ; not used
  170      mov       r3,#0                            ; not used
  180      swi       "OS_ChangeEnvironment"           ; install undefined instruction handler
  190      stmfd     r13!,{r0-r3}                     ; save the previous handlers details
  200      swi       "OS_EnterOS"                     ; enter SVC mode
  210      mov       r0,#1                            ; ARM 1
  220      DCD       &E0010090                        ; mul     r1,r0,r0
  230      teq       r0,#0                            ; if undefined instruction handler was called
  240      beq       type_found                       ; then return
  250      mov       r0,#2                            ; ARM 2
  260      adr       r2,temp_word
  270      DCD       &E1021091                        ; swp     r1,r1,[r2]
  280      teq       r0,#0
  290      beq       type_found
  300      mov       r0,#250                          ; ARM 250
  310      FNmrc("AL",15,0,0,0,0,0)                   ; read ID register
  320      teq       r0,#0
  330      beq       type_found
  340      str       r0,processor_type
  350.type_found
  360      teqp      pc,#0                            ; return to user mode
  370      mov       r0,r0                            ; must have a no-op after a mode change
  380      ldmfd     r13!,{r0-r3}                     
  390      swi       "OS_ChangeEnvironment"           ; reinstall the old handler
  400      ldr       r0,processor_type                ; return the processor type
  410      ldmfd     r13!,{pc}^
  420      
  430.undefined_instruction_handler
  440      str       r0,processor_type                ; store the processor type (the contents R0)
  450      mov       r0,#0                            ; and set r0 to 0 to indicate this has been called
  460      movs      pc,r14                           ; return to the program
  470      
  480.temp_word
  490      DCD       0
  500.processor_type
  510      DCD       0
  520]
  530
  540NEXT pass%
  550
  560proc_version% = USR(code%)
  570
  580CASE proc_version% OF
  590  WHEN 1 : PRINT "ARM 1"
  600  WHEN 2 : PRINT "ARM 2"
  610  WHEN 250 : PRINT "ARM 250"
  620  OTHERWISE : PROCdecode_processor_id(proc_version%)
  630ENDCASE
  640  
  650END

ț "MRC/MCR"
ț "DecodeID"

(� � � �$;" at ";�:�
2
<� code% 1000
F
P� pass%=0 � 2 � 2
Z
dP% = code%
n
x[     OPT pass%
�      stmfd     r13!,{r14}
�T      mov       r0,#1                            ; undefined instruction handler
�Q      adr       r1,undefined_instruction_handler ; the address of the handler
�?      mov       r2,#0                            ; not used
�?      mov       r3,#0                            ; not used
�\      swi       "OS_ChangeEnvironment"           ; install undefined instruction handler
�Y      stmfd     r13!,{r0-r3}                     ; save the previous handlers details
�E      swi       "OS_EnterOS"                     ; enter SVC mode
�<      mov       r0,#1                            ; ARM 1
�G      DCD       &E0010090                        ; mul     r1,r0,r0
�b      teq       r0,#0                            ; if undefined instruction handler was called
�B      beq       type_found                       ; then return
�<      mov       r0,#2                            ; ARM 2
       adr       r2,temp_word
I      DCD       &E1021091                        ; swp     r1,r1,[r2]
      teq       r0,#0
"      beq       type_found
,>      mov       r0,#250                          ; ARM 250
6F      �mrc("AL",15,0,0,0,0,0)                   ; read ID register
@      teq       r0,#0
J      beq       type_found
T%      str       r0,processor_type
^.type_found
hJ      teqp      pc,#0                            ; return to user mode
r\      mov       r0,r0                            ; must have a no-op after a mode change
|5      ldmfd     r13!,{r0-r3}                     
�P      swi       "OS_ChangeEnvironment"           ; reinstall the old handler
�P      ldr       r0,processor_type                ; return the processor type
�      ldmfd     r13!,{pc}^
�
      
�".undefined_instruction_handler
�a      str       r0,processor_type                ; store the processor type (the contents R0)
�g      mov       r0,#0                            ; and set r0 to 0 to indicate this has been called
�L      movs      pc,r14                           ; return to the program
�
      
�.temp_word
�      DCD       0
�.processor_type
�      DCD       0
]

� pass%
&
0proc_version% = �(code%)
:
DȎ proc_version% �
N  � 1 : � "ARM 1"
X  � 2 : � "ARM 2"
b  � 250 : � "ARM 250"
l-   : �decode_processor_id(proc_version%)
v�
�  
��
�
00000000  0d 00 0a 10 c8 9b 20 22  4d 52 43 2f 4d 43 52 22  |...... "MRC/MCR"|
00000010  0d 00 14 11 c8 9b 20 22  44 65 63 6f 64 65 49 44  |...... "DecodeID|
00000020  22 0d 00 1e 04 0d 00 28  17 ee 20 85 20 f1 20 f6  |"......(.. . . .|
00000030  24 3b 22 20 61 74 20 22  3b 9e 3a e0 0d 00 32 04  |$;" at ";.:...2.|
00000040  0d 00 3c 10 de 20 63 6f  64 65 25 20 31 30 30 30  |..<.. code% 1000|
00000050  0d 00 46 04 0d 00 50 15  e3 20 70 61 73 73 25 3d  |..F...P.. pass%=|
00000060  30 20 b8 20 32 20 88 20  32 0d 00 5a 04 0d 00 64  |0 . 2 . 2..Z...d|
00000070  0e 50 25 20 3d 20 63 6f  64 65 25 0d 00 6e 04 0d  |.P% = code%..n..|
00000080  00 78 13 5b 20 20 20 20  20 4f 50 54 20 70 61 73  |.x.[     OPT pas|
00000090  73 25 0d 00 82 1e 20 20  20 20 20 20 73 74 6d 66  |s%....      stmf|
000000a0  64 20 20 20 20 20 72 31  33 21 2c 7b 72 31 34 7d  |d     r13!,{r14}|
000000b0  0d 00 8c 54 20 20 20 20  20 20 6d 6f 76 20 20 20  |...T      mov   |
000000c0  20 20 20 20 72 30 2c 23  31 20 20 20 20 20 20 20  |    r0,#1       |
000000d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000000e0  20 20 20 20 20 3b 20 75  6e 64 65 66 69 6e 65 64  |     ; undefined|
000000f0  20 69 6e 73 74 72 75 63  74 69 6f 6e 20 68 61 6e  | instruction han|
00000100  64 6c 65 72 0d 00 96 51  20 20 20 20 20 20 61 64  |dler...Q      ad|
00000110  72 20 20 20 20 20 20 20  72 31 2c 75 6e 64 65 66  |r       r1,undef|
00000120  69 6e 65 64 5f 69 6e 73  74 72 75 63 74 69 6f 6e  |ined_instruction|
00000130  5f 68 61 6e 64 6c 65 72  20 3b 20 74 68 65 20 61  |_handler ; the a|
00000140  64 64 72 65 73 73 20 6f  66 20 74 68 65 20 68 61  |ddress of the ha|
00000150  6e 64 6c 65 72 0d 00 a0  3f 20 20 20 20 20 20 6d  |ndler...?      m|
00000160  6f 76 20 20 20 20 20 20  20 72 32 2c 23 30 20 20  |ov       r2,#0  |
00000170  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000180  20 20 20 20 20 20 20 20  20 20 3b 20 6e 6f 74 20  |          ; not |
00000190  75 73 65 64 0d 00 aa 3f  20 20 20 20 20 20 6d 6f  |used...?      mo|
000001a0  76 20 20 20 20 20 20 20  72 33 2c 23 30 20 20 20  |v       r3,#0   |
000001b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000001c0  20 20 20 20 20 20 20 20  20 3b 20 6e 6f 74 20 75  |         ; not u|
000001d0  73 65 64 0d 00 b4 5c 20  20 20 20 20 20 73 77 69  |sed...\      swi|
000001e0  20 20 20 20 20 20 20 22  4f 53 5f 43 68 61 6e 67  |       "OS_Chang|
000001f0  65 45 6e 76 69 72 6f 6e  6d 65 6e 74 22 20 20 20  |eEnvironment"   |
00000200  20 20 20 20 20 20 20 20  3b 20 69 6e 73 74 61 6c  |        ; instal|
00000210  6c 20 75 6e 64 65 66 69  6e 65 64 20 69 6e 73 74  |l undefined inst|
00000220  72 75 63 74 69 6f 6e 20  68 61 6e 64 6c 65 72 0d  |ruction handler.|
00000230  00 be 59 20 20 20 20 20  20 73 74 6d 66 64 20 20  |..Y      stmfd  |
00000240  20 20 20 72 31 33 21 2c  7b 72 30 2d 72 33 7d 20  |   r13!,{r0-r3} |
00000250  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000260  20 20 20 20 3b 20 73 61  76 65 20 74 68 65 20 70  |    ; save the p|
00000270  72 65 76 69 6f 75 73 20  68 61 6e 64 6c 65 72 73  |revious handlers|
00000280  20 64 65 74 61 69 6c 73  0d 00 c8 45 20 20 20 20  | details...E    |
00000290  20 20 73 77 69 20 20 20  20 20 20 20 22 4f 53 5f  |  swi       "OS_|
000002a0  45 6e 74 65 72 4f 53 22  20 20 20 20 20 20 20 20  |EnterOS"        |
000002b0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 65  |             ; e|
000002c0  6e 74 65 72 20 53 56 43  20 6d 6f 64 65 0d 00 d2  |nter SVC mode...|
000002d0  3c 20 20 20 20 20 20 6d  6f 76 20 20 20 20 20 20  |<      mov      |
000002e0  20 72 30 2c 23 31 20 20  20 20 20 20 20 20 20 20  | r0,#1          |
000002f0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000300  20 20 3b 20 41 52 4d 20  31 0d 00 dc 47 20 20 20  |  ; ARM 1...G   |
00000310  20 20 20 44 43 44 20 20  20 20 20 20 20 26 45 30  |   DCD       &E0|
00000320  30 31 30 30 39 30 20 20  20 20 20 20 20 20 20 20  |010090          |
00000330  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00000340  6d 75 6c 20 20 20 20 20  72 31 2c 72 30 2c 72 30  |mul     r1,r0,r0|
00000350  0d 00 e6 62 20 20 20 20  20 20 74 65 71 20 20 20  |...b      teq   |
00000360  20 20 20 20 72 30 2c 23  30 20 20 20 20 20 20 20  |    r0,#0       |
00000370  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000380  20 20 20 20 20 3b 20 69  66 20 75 6e 64 65 66 69  |     ; if undefi|
00000390  6e 65 64 20 69 6e 73 74  72 75 63 74 69 6f 6e 20  |ned instruction |
000003a0  68 61 6e 64 6c 65 72 20  77 61 73 20 63 61 6c 6c  |handler was call|
000003b0  65 64 0d 00 f0 42 20 20  20 20 20 20 62 65 71 20  |ed...B      beq |
000003c0  20 20 20 20 20 20 74 79  70 65 5f 66 6f 75 6e 64  |      type_found|
000003d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000003e0  20 20 20 20 20 20 20 3b  20 74 68 65 6e 20 72 65  |       ; then re|
000003f0  74 75 72 6e 0d 00 fa 3c  20 20 20 20 20 20 6d 6f  |turn...<      mo|
00000400  76 20 20 20 20 20 20 20  72 30 2c 23 32 20 20 20  |v       r0,#2   |
00000410  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000420  20 20 20 20 20 20 20 20  20 3b 20 41 52 4d 20 32  |         ; ARM 2|
00000430  0d 01 04 20 20 20 20 20  20 20 61 64 72 20 20 20  |...       adr   |
00000440  20 20 20 20 72 32 2c 74  65 6d 70 5f 77 6f 72 64  |    r2,temp_word|
00000450  0d 01 0e 49 20 20 20 20  20 20 44 43 44 20 20 20  |...I      DCD   |
00000460  20 20 20 20 26 45 31 30  32 31 30 39 31 20 20 20  |    &E1021091   |
00000470  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000480  20 20 20 20 20 3b 20 73  77 70 20 20 20 20 20 72  |     ; swp     r|
00000490  31 2c 72 31 2c 5b 72 32  5d 0d 01 18 19 20 20 20  |1,r1,[r2]....   |
000004a0  20 20 20 74 65 71 20 20  20 20 20 20 20 72 30 2c  |   teq       r0,|
000004b0  23 30 0d 01 22 1e 20 20  20 20 20 20 62 65 71 20  |#0..".      beq |
000004c0  20 20 20 20 20 20 74 79  70 65 5f 66 6f 75 6e 64  |      type_found|
000004d0  0d 01 2c 3e 20 20 20 20  20 20 6d 6f 76 20 20 20  |..,>      mov   |
000004e0  20 20 20 20 72 30 2c 23  32 35 30 20 20 20 20 20  |    r0,#250     |
000004f0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000500  20 20 20 20 20 3b 20 41  52 4d 20 32 35 30 0d 01  |     ; ARM 250..|
00000510  36 46 20 20 20 20 20 20  a4 6d 72 63 28 22 41 4c  |6F      .mrc("AL|
00000520  22 2c 31 35 2c 30 2c 30  2c 30 2c 30 2c 30 29 20  |",15,0,0,0,0,0) |
00000530  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000540  20 20 3b 20 72 65 61 64  20 49 44 20 72 65 67 69  |  ; read ID regi|
00000550  73 74 65 72 0d 01 40 19  20 20 20 20 20 20 74 65  |ster..@.      te|
00000560  71 20 20 20 20 20 20 20  72 30 2c 23 30 0d 01 4a  |q       r0,#0..J|
00000570  1e 20 20 20 20 20 20 62  65 71 20 20 20 20 20 20  |.      beq      |
00000580  20 74 79 70 65 5f 66 6f  75 6e 64 0d 01 54 25 20  | type_found..T% |
00000590  20 20 20 20 20 73 74 72  20 20 20 20 20 20 20 72  |     str       r|
000005a0  30 2c 70 72 6f 63 65 73  73 6f 72 5f 74 79 70 65  |0,processor_type|
000005b0  0d 01 5e 0f 2e 74 79 70  65 5f 66 6f 75 6e 64 0d  |..^..type_found.|
000005c0  01 68 4a 20 20 20 20 20  20 74 65 71 70 20 20 20  |.hJ      teqp   |
000005d0  20 20 20 70 63 2c 23 30  20 20 20 20 20 20 20 20  |   pc,#0        |
000005e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000005f0  20 20 20 20 3b 20 72 65  74 75 72 6e 20 74 6f 20  |    ; return to |
00000600  75 73 65 72 20 6d 6f 64  65 0d 01 72 5c 20 20 20  |user mode..r\   |
00000610  20 20 20 6d 6f 76 20 20  20 20 20 20 20 72 30 2c  |   mov       r0,|
00000620  72 30 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |r0              |
00000630  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00000640  6d 75 73 74 20 68 61 76  65 20 61 20 6e 6f 2d 6f  |must have a no-o|
00000650  70 20 61 66 74 65 72 20  61 20 6d 6f 64 65 20 63  |p after a mode c|
00000660  68 61 6e 67 65 0d 01 7c  35 20 20 20 20 20 20 6c  |hange..|5      l|
00000670  64 6d 66 64 20 20 20 20  20 72 31 33 21 2c 7b 72  |dmfd     r13!,{r|
00000680  30 2d 72 33 7d 20 20 20  20 20 20 20 20 20 20 20  |0-r3}           |
00000690  20 20 20 20 20 20 20 20  20 20 0d 01 86 50 20 20  |          ...P  |
000006a0  20 20 20 20 73 77 69 20  20 20 20 20 20 20 22 4f  |    swi       "O|
000006b0  53 5f 43 68 61 6e 67 65  45 6e 76 69 72 6f 6e 6d  |S_ChangeEnvironm|
000006c0  65 6e 74 22 20 20 20 20  20 20 20 20 20 20 20 3b  |ent"           ;|
000006d0  20 72 65 69 6e 73 74 61  6c 6c 20 74 68 65 20 6f  | reinstall the o|
000006e0  6c 64 20 68 61 6e 64 6c  65 72 0d 01 90 50 20 20  |ld handler...P  |
000006f0  20 20 20 20 6c 64 72 20  20 20 20 20 20 20 72 30  |    ldr       r0|
00000700  2c 70 72 6f 63 65 73 73  6f 72 5f 74 79 70 65 20  |,processor_type |
00000710  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00000720  20 72 65 74 75 72 6e 20  74 68 65 20 70 72 6f 63  | return the proc|
00000730  65 73 73 6f 72 20 74 79  70 65 0d 01 9a 1e 20 20  |essor type....  |
00000740  20 20 20 20 6c 64 6d 66  64 20 20 20 20 20 72 31  |    ldmfd     r1|
00000750  33 21 2c 7b 70 63 7d 5e  0d 01 a4 0a 20 20 20 20  |3!,{pc}^....    |
00000760  20 20 0d 01 ae 22 2e 75  6e 64 65 66 69 6e 65 64  |  ...".undefined|
00000770  5f 69 6e 73 74 72 75 63  74 69 6f 6e 5f 68 61 6e  |_instruction_han|
00000780  64 6c 65 72 0d 01 b8 61  20 20 20 20 20 20 73 74  |dler...a      st|
00000790  72 20 20 20 20 20 20 20  72 30 2c 70 72 6f 63 65  |r       r0,proce|
000007a0  73 73 6f 72 5f 74 79 70  65 20 20 20 20 20 20 20  |ssor_type       |
000007b0  20 20 20 20 20 20 20 20  20 3b 20 73 74 6f 72 65  |         ; store|
000007c0  20 74 68 65 20 70 72 6f  63 65 73 73 6f 72 20 74  | the processor t|
000007d0  79 70 65 20 28 74 68 65  20 63 6f 6e 74 65 6e 74  |ype (the content|
000007e0  73 20 52 30 29 0d 01 c2  67 20 20 20 20 20 20 6d  |s R0)...g      m|
000007f0  6f 76 20 20 20 20 20 20  20 72 30 2c 23 30 20 20  |ov       r0,#0  |
00000800  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000810  20 20 20 20 20 20 20 20  20 20 3b 20 61 6e 64 20  |          ; and |
00000820  73 65 74 20 72 30 20 74  6f 20 30 20 74 6f 20 69  |set r0 to 0 to i|
00000830  6e 64 69 63 61 74 65 20  74 68 69 73 20 68 61 73  |ndicate this has|
00000840  20 62 65 65 6e 20 63 61  6c 6c 65 64 0d 01 cc 4c  | been called...L|
00000850  20 20 20 20 20 20 6d 6f  76 73 20 20 20 20 20 20  |      movs      |
00000860  70 63 2c 72 31 34 20 20  20 20 20 20 20 20 20 20  |pc,r14          |
00000870  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000880  20 3b 20 72 65 74 75 72  6e 20 74 6f 20 74 68 65  | ; return to the|
00000890  20 70 72 6f 67 72 61 6d  0d 01 d6 0a 20 20 20 20  | program....    |
000008a0  20 20 0d 01 e0 0e 2e 74  65 6d 70 5f 77 6f 72 64  |  .....temp_word|
000008b0  0d 01 ea 15 20 20 20 20  20 20 44 43 44 20 20 20  |....      DCD   |
000008c0  20 20 20 20 30 0d 01 f4  13 2e 70 72 6f 63 65 73  |    0.....proces|
000008d0  73 6f 72 5f 74 79 70 65  0d 01 fe 15 20 20 20 20  |sor_type....    |
000008e0  20 20 44 43 44 20 20 20  20 20 20 20 30 0d 02 08  |  DCD       0...|
000008f0  05 5d 0d 02 12 04 0d 02  1c 0b ed 20 70 61 73 73  |.]......... pass|
00000900  25 0d 02 26 04 0d 02 30  1c 70 72 6f 63 5f 76 65  |%..&...0.proc_ve|
00000910  72 73 69 6f 6e 25 20 3d  20 ba 28 63 6f 64 65 25  |rsion% = .(code%|
00000920  29 0d 02 3a 04 0d 02 44  16 c8 8e 20 70 72 6f 63  |)..:...D... proc|
00000930  5f 76 65 72 73 69 6f 6e  25 20 ca 0d 02 4e 15 20  |_version% ...N. |
00000940  20 c9 20 31 20 3a 20 f1  20 22 41 52 4d 20 31 22  | . 1 : . "ARM 1"|
00000950  0d 02 58 15 20 20 c9 20  32 20 3a 20 f1 20 22 41  |..X.  . 2 : . "A|
00000960  52 4d 20 32 22 0d 02 62  19 20 20 c9 20 32 35 30  |RM 2"..b.  . 250|
00000970  20 3a 20 f1 20 22 41 52  4d 20 32 35 30 22 0d 02  | : . "ARM 250"..|
00000980  6c 2d 20 20 7f 20 3a 20  f2 64 65 63 6f 64 65 5f  |l-  . : .decode_|
00000990  70 72 6f 63 65 73 73 6f  72 5f 69 64 28 70 72 6f  |processor_id(pro|
000009a0  63 5f 76 65 72 73 69 6f  6e 25 29 0d 02 76 05 cb  |c_version%)..v..|
000009b0  0d 02 80 06 20 20 0d 02  8a 05 e0 0d ff           |....  .......|
000009bd