Home » Archimedes archive » Acorn Computing » 1994 04 subscription disc.adf » 9404s » Miscellany/RunVar/RunVarSrc

Miscellany/RunVar/RunVarSrc

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 » Acorn Computing » 1994 04 subscription disc.adf » 9404s
Filename: Miscellany/RunVar/RunVarSrc
Read OK:
File size: 2D35 bytes
Load address: 0000
Exec address: 0000
File contents
; Source code for RunVar module

; (c) Acorn Computing 1994
; written by David J Seery

; This module creates a system variable of the form File_XXX$Dir for
; each file run, where XXX is the filetype, and the variable is set to the
; directory from which the file was run.

; I've tried to comment out this source as it is not really to complicated
; and non-ARM code programmers might wish to have a look at it.  If the
; syntax is different to the BASIC assembler, it is because I use my own
; assembler to make life easier - it multitasks from the desktop.

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

                dcd      0                 ; No start up code
                dcd      initialise        ; OFFSET to initialisation code
                dcd      finalise          ; OFFSET to finalisation code
                dcd      service           ; OFFSET to service call handler
                                           ; code
                dcd      title             ; Our title string (OFFSET)
                dcd      help              ; Out help string (OFFSET)
                dcd      0                 ; No star commands
                dcd      0                 ; No SWI chunk number
                dcd      0                 ; No SWI handling code
                dcd      0                 ; No SWI decoding table
                dcd      0                 ; No SWI decoding code

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

title           dcb      "RunVar",0
                align

help            dcb      "RunVar"
                dcb      9
                dcb      9                 ; Note the presence of TWO tab
                                           ; characters.  This is so that
                                           ; the layout of *Help Modules on
                                           ; screen is consistent as RunVar
                                           ; is <8 characters.
                dcb      "0.86 (03 Dec 1993)",0
                align

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

initialise      stmfd    r13!,{r0-r8,r14}  ; Stack registers
                mov      r0,#&f            ; =15 FSControlV
                adr      r1,fscontrolv     ; Address of our code
                mov      r2,#0             ; Enter with r12 = 0
                swi      "OS_Claim"        ; Claim the vector
                mov      r0,#8             ; =8 FileV
                adr      r1,filev          ; Address of our code
                mov      r2,#0             ; Enter with r12 = 0
                swi      "OS_Claim"        ; Claim the vector
                ldmfd    r13!,{r0-r8,pc}   ; Re-load registers and exit

finalise        stmfd    r13!,{r0-r8,r14}  ; Stack registers
                mov      r0,#&f            ; =15 FSControlV
                adr      r1,fscontrolv     ; Address of our code
                mov      r2,#0             ; For completeness
                swi      "OS_Release"      ; Release claim on vector
                mov      r0,#8             ; =8 FileV
                adr      r1,filev          ; Address of our code
                mov      r2,#0             ; For completeness
                swi      "OS_Release"      ; Release claim on vector
                ldmfd    r13!,{r0-r8,pc}   ; Re-load registers and exit

service         cmp      r1,#&27           ; Is this a machine reset ?
                movne    pc,r14            ; If not, we don't want to know
                stmfd    r13!,{r0-r11,r14} ; Store ALL registers - must be
                                           ; preserved !
                mov      r0,#&f            ; Yet again, FSControlV
                adr      r1,fscontrolv     ; And the address of our code
                mov      r2,#0             ; Enter with r12 = 0
                swi      "OS_Claim"        ; Claim the vector.  Why?
                                           ; Well, a reset releases all
                                           ; vector claims so we have to
                                           ; reinstate them
                mov      r0,#8             ; =8 FileV
                adr      r1,filev          ; Address of our code
                mov      r2,#0             ; Enter with r12 = 0
                swi      "OS_Claim"        ; Claim the vector
                ldmfd    r13!,{r0-r11,pc}  ; Re-load registers and exit

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

; This is the main part of the code and is called whenever a OS_FSControl
; SWI is passed to the OS.  We check to see if it is to do with *RUNning
; a file (reason code 4) and if it is then we perform a bit of pre-processing
; and create (or alter) the appropriate system variable.

fscontrolv      cmp      r0,#4             ; Is it *RUN file ?
                movne    pc,r14            ; If not, pass it on
                stmfd    r13!,{r0-r9,r14}  ; Store registers
                adr      r6,first_bit      ; Get address of RunFile bit
                mov      r7,#ASC" "        ; Space
                strb     r7,[r6],#1        ; Store it
                mov      r7,#ASC"R"        ; R
                strb     r7,[r6],#1        ; Store it
                mov      r7,#ASC"u"        ; u
                strb     r7,[r6],#1        ; Store it
                mov      r7,#ASC"n"        ; n
                strb     r7,[r6],#1        ; Store it
do_var_bit      mov      r8,r1             ; Make a copy of filename pointer
                mov      r0,#5             ; Set to info on file
                swi      "XOS_File"        ; Get the data
                ldmvsfd  r13!,{r0-r8,pc}   ; If there is a problem, exit
                mov      r2,r2,lsr #8      ; Shift the load address right
                                           ; 8 times
                ldr      r3,num_fff        ; Get the constant 4095 (&FFF)
                and      r2,r2,r3          ; Logically AND the shifted-right
                                           ; load address with 4095 (&FFF)
                mov      r0,r2             ; Set r0 to processed load address
                adr      r1,buffer         ; Set r1 to point to a buffer
                mov      r2,#8             ; Set r2 to maximum size of buffer
                swi      "OS_ConvertHex4"  ; Convert r0 to a hex number

; What is the point of all the above arithmetic ?  What it actually comes
; down to is that the operating system stores the filetype in the load
; address of a file - on the old BBC this was the address (in memory) where
; the file was loaded to if no other address was specified.  It takes the
; form -

;    FFFtttddd

; Where the FFF is an actual constant, the ttt refers to the file type, and
; the ddd is part of the date stamp.  As an example, a file might have the
; address -

;    FFFFF93A9

; And from this we can see that the file type is FF9 - a sprite file.  If
; we shift right 8 times and AND this with &FFF then we can obtain FF9 on
; its own.

                  adr     r1,run_type       ; Set r1 to point to variable
                                            ; type section (the XXX of
                                            ; File_XXX$Dir)
                  ldrb    r2,[r0,#1]        ; Get first byte
                  strb    r2,[r1,#0]        ; And store it
                  ldrb    r2,[r0,#2]        ; Get second byte
                  strb    r2,[r1,#1]        ; And store it
                  ldrb    r2,[r0,#3]        ; Get third byte
                  strb    r2,[r1,#2]        ; And store it
                  mov     r1,r8             ; Get our copy of the filename
                  mov     r9,#0             ; Set a flag to 0 - see later
find_end          ldrb    r2,[r1],#1        ; Get a byte...
                  cmp     r2,#ASC"."        ; Is it a dot ?
                  moveq   r9,#1             ; If it is, set the flag to 1
                  cmp     r2,#32            ; Compare it with ASCII 32...
                  bgt     find_end          ; If greater than, branch back.
                                            ; r1 now points to the byte after
                                            ; the end of string marker
                  cmp     r9,#1             ; Is there a dot in the string ?
                  ldmnefd r13!,{r0-r9,pc}   ; If not, exit, because we can't
                                            ; set the variable to a directory
                                            ; name (safeguard feature)
                  sub     r1,r1,#1          ; Now points to end of string
find_dot          ldrb    r2,[r1],#-1       ; Get a byte...
                  cmp     r2,#ASC"."        ; Compare it with ASCII for "."
                  bne     find_dot          ; If not, branch back
                  mov     r2,#0             ; End of string marker
                  strb    r2,[r1,#1]        ; Store it
                  mov     r9,r1             ; Make a copy of the address
                  adr     r0,run_val        ; Get address of value slot
                  mov     r1,r8             ; Get copy of filename
make_copy         ldrb    r2,[r1],#1        ; Get a byte...
                  cmp     r2,#32            ; Compare it with ASCII 32
                  strb    r2,[r0],#1        ; Store it...
                  bgt     make_copy         ; If greater than, branch back
                  adr     r0,run_var        ; Get address of CLI string
                  swi     "OS_CLI"          ; Set the variable value
                  mov     r2,#ASC"."        ; Make r2 = "."
                  strb    r2,[r9,#1]        ; And store it over the end of
                                            ; string marker
                  ldmfd   r13!,{r0-r9,pc}   ; Re-load registers and pass on
                                            ; the call

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

; This is the second important part of the code and is called when an OS_File
; is discovered.  It checks if it is load file (&ff) and if it is it sets
; a variable LoadFile_XXX$Dir to the directory of the file, as above

filev             cmp     r0,#&ff           ; Is it load file ?
                  cmpne   r0,#&c            ; Another sort of load
                  cmpne   r0,#&e            ; Yet another
                  cmpne   r0,#&10           ; And another
                  movne   pc,r14            ; If it isn't, go away!
                  stmfd   r13!,{r0-r9,r14}  ; Store registers
                  adr     r6,first_bit      ; Get address of LoadFile bit
                  mov     r7,#ASC"L"        ; L
                  strb    r7,[r6],#1        ; Store it
                  mov     r7,#ASC"o"        ; o
                  strb    r7,[r6],#1        ; Store it
                  mov     r7,#ASC"a"        ; a
                  strb    r7,[r6],#1        ; Store it
                  mov     r7,#ASC"d"        ; d
                  strb    r7,[r6],#1        ; Store it
                  b       do_var_bit        ; Create the variable

num_fff           dcd     &fff              ; A constant
.buffer           dcd     0:dcd     0       ; Space for conversion
run_var           dcb     "Set "
first_bit         dcb     " Run"
second_bit        dcb     "File_"
run_type          dcb     0:dcb     0:dcb     0          ; Variable name
                  dcb     "$Dir "
run_val           equs    STRING$(100,CHR$0)
00000000  0a 3b 20 53 6f 75 72 63  65 20 63 6f 64 65 20 66  |.; Source code f|
00000010  6f 72 20 52 75 6e 56 61  72 20 6d 6f 64 75 6c 65  |or RunVar module|
00000020  0a 0a 3b 20 28 63 29 20  41 63 6f 72 6e 20 43 6f  |..; (c) Acorn Co|
00000030  6d 70 75 74 69 6e 67 20  31 39 39 34 0a 3b 20 77  |mputing 1994.; w|
00000040  72 69 74 74 65 6e 20 62  79 20 44 61 76 69 64 20  |ritten by David |
00000050  4a 20 53 65 65 72 79 0a  0a 3b 20 54 68 69 73 20  |J Seery..; This |
00000060  6d 6f 64 75 6c 65 20 63  72 65 61 74 65 73 20 61  |module creates a|
00000070  20 73 79 73 74 65 6d 20  76 61 72 69 61 62 6c 65  | system variable|
00000080  20 6f 66 20 74 68 65 20  66 6f 72 6d 20 46 69 6c  | of the form Fil|
00000090  65 5f 58 58 58 24 44 69  72 20 66 6f 72 0a 3b 20  |e_XXX$Dir for.; |
000000a0  65 61 63 68 20 66 69 6c  65 20 72 75 6e 2c 20 77  |each file run, w|
000000b0  68 65 72 65 20 58 58 58  20 69 73 20 74 68 65 20  |here XXX is the |
000000c0  66 69 6c 65 74 79 70 65  2c 20 61 6e 64 20 74 68  |filetype, and th|
000000d0  65 20 76 61 72 69 61 62  6c 65 20 69 73 20 73 65  |e variable is se|
000000e0  74 20 74 6f 20 74 68 65  0a 3b 20 64 69 72 65 63  |t to the.; direc|
000000f0  74 6f 72 79 20 66 72 6f  6d 20 77 68 69 63 68 20  |tory from which |
00000100  74 68 65 20 66 69 6c 65  20 77 61 73 20 72 75 6e  |the file was run|
00000110  2e 0a 0a 3b 20 49 27 76  65 20 74 72 69 65 64 20  |...; I've tried |
00000120  74 6f 20 63 6f 6d 6d 65  6e 74 20 6f 75 74 20 74  |to comment out t|
00000130  68 69 73 20 73 6f 75 72  63 65 20 61 73 20 69 74  |his source as it|
00000140  20 69 73 20 6e 6f 74 20  72 65 61 6c 6c 79 20 74  | is not really t|
00000150  6f 20 63 6f 6d 70 6c 69  63 61 74 65 64 0a 3b 20  |o complicated.; |
00000160  61 6e 64 20 6e 6f 6e 2d  41 52 4d 20 63 6f 64 65  |and non-ARM code|
00000170  20 70 72 6f 67 72 61 6d  6d 65 72 73 20 6d 69 67  | programmers mig|
00000180  68 74 20 77 69 73 68 20  74 6f 20 68 61 76 65 20  |ht wish to have |
00000190  61 20 6c 6f 6f 6b 20 61  74 20 69 74 2e 20 20 49  |a look at it.  I|
000001a0  66 20 74 68 65 0a 3b 20  73 79 6e 74 61 78 20 69  |f the.; syntax i|
000001b0  73 20 64 69 66 66 65 72  65 6e 74 20 74 6f 20 74  |s different to t|
000001c0  68 65 20 42 41 53 49 43  20 61 73 73 65 6d 62 6c  |he BASIC assembl|
000001d0  65 72 2c 20 69 74 20 69  73 20 62 65 63 61 75 73  |er, it is becaus|
000001e0  65 20 49 20 75 73 65 20  6d 79 20 6f 77 6e 0a 3b  |e I use my own.;|
000001f0  20 61 73 73 65 6d 62 6c  65 72 20 74 6f 20 6d 61  | assembler to ma|
00000200  6b 65 20 6c 69 66 65 20  65 61 73 69 65 72 20 2d  |ke life easier -|
00000210  20 69 74 20 6d 75 6c 74  69 74 61 73 6b 73 20 66  | it multitasks f|
00000220  72 6f 6d 20 74 68 65 20  64 65 73 6b 74 6f 70 2e  |rom the desktop.|
00000230  0a 0a 3b 20 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |..; ------------|
00000240  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000270  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 0a 0a 20  |-------------.. |
00000280  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 64  |               d|
00000290  63 64 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |cd      0       |
000002a0  20 20 20 20 20 20 20 20  20 20 3b 20 4e 6f 20 73  |          ; No s|
000002b0  74 61 72 74 20 75 70 20  63 6f 64 65 0a 20 20 20  |tart up code.   |
000002c0  20 20 20 20 20 20 20 20  20 20 20 20 20 64 63 64  |             dcd|
000002d0  20 20 20 20 20 20 69 6e  69 74 69 61 6c 69 73 65  |      initialise|
000002e0  20 20 20 20 20 20 20 20  3b 20 4f 46 46 53 45 54  |        ; OFFSET|
000002f0  20 74 6f 20 69 6e 69 74  69 61 6c 69 73 61 74 69  | to initialisati|
00000300  6f 6e 20 63 6f 64 65 0a  20 20 20 20 20 20 20 20  |on code.        |
00000310  20 20 20 20 20 20 20 20  64 63 64 20 20 20 20 20  |        dcd     |
00000320  20 66 69 6e 61 6c 69 73  65 20 20 20 20 20 20 20  | finalise       |
00000330  20 20 20 3b 20 4f 46 46  53 45 54 20 74 6f 20 66  |   ; OFFSET to f|
00000340  69 6e 61 6c 69 73 61 74  69 6f 6e 20 63 6f 64 65  |inalisation code|
00000350  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000360  20 64 63 64 20 20 20 20  20 20 73 65 72 76 69 63  | dcd      servic|
00000370  65 20 20 20 20 20 20 20  20 20 20 20 3b 20 4f 46  |e           ; OF|
00000380  46 53 45 54 20 74 6f 20  73 65 72 76 69 63 65 20  |FSET to service |
00000390  63 61 6c 6c 20 68 61 6e  64 6c 65 72 0a 20 20 20  |call handler.   |
000003a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000003c0  20 20 20 20 20 20 20 20  3b 20 63 6f 64 65 0a 20  |        ; code. |
000003d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 64  |               d|
000003e0  63 64 20 20 20 20 20 20  74 69 74 6c 65 20 20 20  |cd      title   |
000003f0  20 20 20 20 20 20 20 20  20 20 3b 20 4f 75 72 20  |          ; Our |
00000400  74 69 74 6c 65 20 73 74  72 69 6e 67 20 28 4f 46  |title string (OF|
00000410  46 53 45 54 29 0a 20 20  20 20 20 20 20 20 20 20  |FSET).          |
00000420  20 20 20 20 20 20 64 63  64 20 20 20 20 20 20 68  |      dcd      h|
00000430  65 6c 70 20 20 20 20 20  20 20 20 20 20 20 20 20  |elp             |
00000440  20 3b 20 4f 75 74 20 68  65 6c 70 20 73 74 72 69  | ; Out help stri|
00000450  6e 67 20 28 4f 46 46 53  45 54 29 0a 20 20 20 20  |ng (OFFSET).    |
00000460  20 20 20 20 20 20 20 20  20 20 20 20 64 63 64 20  |            dcd |
00000470  20 20 20 20 20 30 20 20  20 20 20 20 20 20 20 20  |     0          |
00000480  20 20 20 20 20 20 20 3b  20 4e 6f 20 73 74 61 72  |       ; No star|
00000490  20 63 6f 6d 6d 61 6e 64  73 0a 20 20 20 20 20 20  | commands.      |
000004a0  20 20 20 20 20 20 20 20  20 20 64 63 64 20 20 20  |          dcd   |
000004b0  20 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |   0            |
000004c0  20 20 20 20 20 3b 20 4e  6f 20 53 57 49 20 63 68  |     ; No SWI ch|
000004d0  75 6e 6b 20 6e 75 6d 62  65 72 0a 20 20 20 20 20  |unk number.     |
000004e0  20 20 20 20 20 20 20 20  20 20 20 64 63 64 20 20  |           dcd  |
000004f0  20 20 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |    0           |
00000500  20 20 20 20 20 20 3b 20  4e 6f 20 53 57 49 20 68  |      ; No SWI h|
00000510  61 6e 64 6c 69 6e 67 20  63 6f 64 65 0a 20 20 20  |andling code.   |
00000520  20 20 20 20 20 20 20 20  20 20 20 20 20 64 63 64  |             dcd|
00000530  20 20 20 20 20 20 30 20  20 20 20 20 20 20 20 20  |      0         |
00000540  20 20 20 20 20 20 20 20  3b 20 4e 6f 20 53 57 49  |        ; No SWI|
00000550  20 64 65 63 6f 64 69 6e  67 20 74 61 62 6c 65 0a  | decoding table.|
00000560  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000570  64 63 64 20 20 20 20 20  20 30 20 20 20 20 20 20  |dcd      0      |
00000580  20 20 20 20 20 20 20 20  20 20 20 3b 20 4e 6f 20  |           ; No |
00000590  53 57 49 20 64 65 63 6f  64 69 6e 67 20 63 6f 64  |SWI decoding cod|
000005a0  65 0a 0a 3b 20 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |e..; -----------|
000005b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000005e0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 0a  |---------------.|
000005f0  0a 74 69 74 6c 65 20 20  20 20 20 20 20 20 20 20  |.title          |
00000600  20 64 63 62 20 20 20 20  20 20 22 52 75 6e 56 61  | dcb      "RunVa|
00000610  72 22 2c 30 0a 20 20 20  20 20 20 20 20 20 20 20  |r",0.           |
00000620  20 20 20 20 20 61 6c 69  67 6e 0a 0a 68 65 6c 70  |     align..help|
00000630  20 20 20 20 20 20 20 20  20 20 20 20 64 63 62 20  |            dcb |
00000640  20 20 20 20 20 22 52 75  6e 56 61 72 22 0a 20 20  |     "RunVar".  |
00000650  20 20 20 20 20 20 20 20  20 20 20 20 20 20 64 63  |              dc|
00000660  62 20 20 20 20 20 20 39  0a 20 20 20 20 20 20 20  |b      9.       |
00000670  20 20 20 20 20 20 20 20  20 64 63 62 20 20 20 20  |         dcb    |
00000680  20 20 39 20 20 20 20 20  20 20 20 20 20 20 20 20  |  9             |
00000690  20 20 20 20 3b 20 4e 6f  74 65 20 74 68 65 20 70  |    ; Note the p|
000006a0  72 65 73 65 6e 63 65 20  6f 66 20 54 57 4f 20 74  |resence of TWO t|
000006b0  61 62 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |ab.             |
000006c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000006d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
000006e0  63 68 61 72 61 63 74 65  72 73 2e 20 20 54 68 69  |characters.  Thi|
000006f0  73 20 69 73 20 73 6f 20  74 68 61 74 0a 20 20 20  |s is so that.   |
00000700  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000720  20 20 20 20 20 20 20 20  3b 20 74 68 65 20 6c 61  |        ; the la|
00000730  79 6f 75 74 20 6f 66 20  2a 48 65 6c 70 20 4d 6f  |yout of *Help Mo|
00000740  64 75 6c 65 73 20 6f 6e  0a 20 20 20 20 20 20 20  |dules on.       |
00000750  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000770  20 20 20 20 3b 20 73 63  72 65 65 6e 20 69 73 20  |    ; screen is |
00000780  63 6f 6e 73 69 73 74 65  6e 74 20 61 73 20 52 75  |consistent as Ru|
00000790  6e 56 61 72 0a 20 20 20  20 20 20 20 20 20 20 20  |nVar.           |
000007a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000007c0  3b 20 69 73 20 3c 38 20  63 68 61 72 61 63 74 65  |; is <8 characte|
000007d0  72 73 2e 0a 20 20 20 20  20 20 20 20 20 20 20 20  |rs..            |
000007e0  20 20 20 20 64 63 62 20  20 20 20 20 20 22 30 2e  |    dcb      "0.|
000007f0  38 36 20 28 30 33 20 44  65 63 20 31 39 39 33 29  |86 (03 Dec 1993)|
00000800  22 2c 30 0a 20 20 20 20  20 20 20 20 20 20 20 20  |",0.            |
00000810  20 20 20 20 61 6c 69 67  6e 0a 0a 3b 20 2d 2d 2d  |    align..; ---|
00000820  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000860  2d 2d 2d 2d 2d 2d 2d 0a  0a 69 6e 69 74 69 61 6c  |-------..initial|
00000870  69 73 65 20 20 20 20 20  20 73 74 6d 66 64 20 20  |ise      stmfd  |
00000880  20 20 72 31 33 21 2c 7b  72 30 2d 72 38 2c 72 31  |  r13!,{r0-r8,r1|
00000890  34 7d 20 20 3b 20 53 74  61 63 6b 20 72 65 67 69  |4}  ; Stack regi|
000008a0  73 74 65 72 73 0a 20 20  20 20 20 20 20 20 20 20  |sters.          |
000008b0  20 20 20 20 20 20 6d 6f  76 20 20 20 20 20 20 72  |      mov      r|
000008c0  30 2c 23 26 66 20 20 20  20 20 20 20 20 20 20 20  |0,#&f           |
000008d0  20 3b 20 3d 31 35 20 46  53 43 6f 6e 74 72 6f 6c  | ; =15 FSControl|
000008e0  56 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |V.              |
000008f0  20 20 61 64 72 20 20 20  20 20 20 72 31 2c 66 73  |  adr      r1,fs|
00000900  63 6f 6e 74 72 6f 6c 76  20 20 20 20 20 3b 20 41  |controlv     ; A|
00000910  64 64 72 65 73 73 20 6f  66 20 6f 75 72 20 63 6f  |ddress of our co|
00000920  64 65 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |de.             |
00000930  20 20 20 6d 6f 76 20 20  20 20 20 20 72 32 2c 23  |   mov      r2,#|
00000940  30 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |0             ; |
00000950  45 6e 74 65 72 20 77 69  74 68 20 72 31 32 20 3d  |Enter with r12 =|
00000960  20 30 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  | 0.             |
00000970  20 20 20 73 77 69 20 20  20 20 20 20 22 4f 53 5f  |   swi      "OS_|
00000980  43 6c 61 69 6d 22 20 20  20 20 20 20 20 20 3b 20  |Claim"        ; |
00000990  43 6c 61 69 6d 20 74 68  65 20 76 65 63 74 6f 72  |Claim the vector|
000009a0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
000009b0  20 6d 6f 76 20 20 20 20  20 20 72 30 2c 23 38 20  | mov      r0,#8 |
000009c0  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 3d 38  |            ; =8|
000009d0  20 46 69 6c 65 56 0a 20  20 20 20 20 20 20 20 20  | FileV.         |
000009e0  20 20 20 20 20 20 20 61  64 72 20 20 20 20 20 20  |       adr      |
000009f0  72 31 2c 66 69 6c 65 76  20 20 20 20 20 20 20 20  |r1,filev        |
00000a00  20 20 3b 20 41 64 64 72  65 73 73 20 6f 66 20 6f  |  ; Address of o|
00000a10  75 72 20 63 6f 64 65 0a  20 20 20 20 20 20 20 20  |ur code.        |
00000a20  20 20 20 20 20 20 20 20  6d 6f 76 20 20 20 20 20  |        mov     |
00000a30  20 72 32 2c 23 30 20 20  20 20 20 20 20 20 20 20  | r2,#0          |
00000a40  20 20 20 3b 20 45 6e 74  65 72 20 77 69 74 68 20  |   ; Enter with |
00000a50  72 31 32 20 3d 20 30 0a  20 20 20 20 20 20 20 20  |r12 = 0.        |
00000a60  20 20 20 20 20 20 20 20  73 77 69 20 20 20 20 20  |        swi     |
00000a70  20 22 4f 53 5f 43 6c 61  69 6d 22 20 20 20 20 20  | "OS_Claim"     |
00000a80  20 20 20 3b 20 43 6c 61  69 6d 20 74 68 65 20 76  |   ; Claim the v|
00000a90  65 63 74 6f 72 0a 20 20  20 20 20 20 20 20 20 20  |ector.          |
00000aa0  20 20 20 20 20 20 6c 64  6d 66 64 20 20 20 20 72  |      ldmfd    r|
00000ab0  31 33 21 2c 7b 72 30 2d  72 38 2c 70 63 7d 20 20  |13!,{r0-r8,pc}  |
00000ac0  20 3b 20 52 65 2d 6c 6f  61 64 20 72 65 67 69 73  | ; Re-load regis|
00000ad0  74 65 72 73 20 61 6e 64  20 65 78 69 74 0a 0a 66  |ters and exit..f|
00000ae0  69 6e 61 6c 69 73 65 20  20 20 20 20 20 20 20 73  |inalise        s|
00000af0  74 6d 66 64 20 20 20 20  72 31 33 21 2c 7b 72 30  |tmfd    r13!,{r0|
00000b00  2d 72 38 2c 72 31 34 7d  20 20 3b 20 53 74 61 63  |-r8,r14}  ; Stac|
00000b10  6b 20 72 65 67 69 73 74  65 72 73 0a 20 20 20 20  |k registers.    |
00000b20  20 20 20 20 20 20 20 20  20 20 20 20 6d 6f 76 20  |            mov |
00000b30  20 20 20 20 20 72 30 2c  23 26 66 20 20 20 20 20  |     r0,#&f     |
00000b40  20 20 20 20 20 20 20 3b  20 3d 31 35 20 46 53 43  |       ; =15 FSC|
00000b50  6f 6e 74 72 6f 6c 56 0a  20 20 20 20 20 20 20 20  |ontrolV.        |
00000b60  20 20 20 20 20 20 20 20  61 64 72 20 20 20 20 20  |        adr     |
00000b70  20 72 31 2c 66 73 63 6f  6e 74 72 6f 6c 76 20 20  | r1,fscontrolv  |
00000b80  20 20 20 3b 20 41 64 64  72 65 73 73 20 6f 66 20  |   ; Address of |
00000b90  6f 75 72 20 63 6f 64 65  0a 20 20 20 20 20 20 20  |our code.       |
00000ba0  20 20 20 20 20 20 20 20  20 6d 6f 76 20 20 20 20  |         mov    |
00000bb0  20 20 72 32 2c 23 30 20  20 20 20 20 20 20 20 20  |  r2,#0         |
00000bc0  20 20 20 20 3b 20 46 6f  72 20 63 6f 6d 70 6c 65  |    ; For comple|
00000bd0  74 65 6e 65 73 73 0a 20  20 20 20 20 20 20 20 20  |teness.         |
00000be0  20 20 20 20 20 20 20 73  77 69 20 20 20 20 20 20  |       swi      |
00000bf0  22 4f 53 5f 52 65 6c 65  61 73 65 22 20 20 20 20  |"OS_Release"    |
00000c00  20 20 3b 20 52 65 6c 65  61 73 65 20 63 6c 61 69  |  ; Release clai|
00000c10  6d 20 6f 6e 20 76 65 63  74 6f 72 0a 20 20 20 20  |m on vector.    |
00000c20  20 20 20 20 20 20 20 20  20 20 20 20 6d 6f 76 20  |            mov |
00000c30  20 20 20 20 20 72 30 2c  23 38 20 20 20 20 20 20  |     r0,#8      |
00000c40  20 20 20 20 20 20 20 3b  20 3d 38 20 46 69 6c 65  |       ; =8 File|
00000c50  56 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |V.              |
00000c60  20 20 61 64 72 20 20 20  20 20 20 72 31 2c 66 69  |  adr      r1,fi|
00000c70  6c 65 76 20 20 20 20 20  20 20 20 20 20 3b 20 41  |lev          ; A|
00000c80  64 64 72 65 73 73 20 6f  66 20 6f 75 72 20 63 6f  |ddress of our co|
00000c90  64 65 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |de.             |
00000ca0  20 20 20 6d 6f 76 20 20  20 20 20 20 72 32 2c 23  |   mov      r2,#|
00000cb0  30 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |0             ; |
00000cc0  46 6f 72 20 63 6f 6d 70  6c 65 74 65 6e 65 73 73  |For completeness|
00000cd0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000ce0  20 73 77 69 20 20 20 20  20 20 22 4f 53 5f 52 65  | swi      "OS_Re|
00000cf0  6c 65 61 73 65 22 20 20  20 20 20 20 3b 20 52 65  |lease"      ; Re|
00000d00  6c 65 61 73 65 20 63 6c  61 69 6d 20 6f 6e 20 76  |lease claim on v|
00000d10  65 63 74 6f 72 0a 20 20  20 20 20 20 20 20 20 20  |ector.          |
00000d20  20 20 20 20 20 20 6c 64  6d 66 64 20 20 20 20 72  |      ldmfd    r|
00000d30  31 33 21 2c 7b 72 30 2d  72 38 2c 70 63 7d 20 20  |13!,{r0-r8,pc}  |
00000d40  20 3b 20 52 65 2d 6c 6f  61 64 20 72 65 67 69 73  | ; Re-load regis|
00000d50  74 65 72 73 20 61 6e 64  20 65 78 69 74 0a 0a 73  |ters and exit..s|
00000d60  65 72 76 69 63 65 20 20  20 20 20 20 20 20 20 63  |ervice         c|
00000d70  6d 70 20 20 20 20 20 20  72 31 2c 23 26 32 37 20  |mp      r1,#&27 |
00000d80  20 20 20 20 20 20 20 20  20 20 3b 20 49 73 20 74  |          ; Is t|
00000d90  68 69 73 20 61 20 6d 61  63 68 69 6e 65 20 72 65  |his a machine re|
00000da0  73 65 74 20 3f 0a 20 20  20 20 20 20 20 20 20 20  |set ?.          |
00000db0  20 20 20 20 20 20 6d 6f  76 6e 65 20 20 20 20 70  |      movne    p|
00000dc0  63 2c 72 31 34 20 20 20  20 20 20 20 20 20 20 20  |c,r14           |
00000dd0  20 3b 20 49 66 20 6e 6f  74 2c 20 77 65 20 64 6f  | ; If not, we do|
00000de0  6e 27 74 20 77 61 6e 74  20 74 6f 20 6b 6e 6f 77  |n't want to know|
00000df0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000e00  20 73 74 6d 66 64 20 20  20 20 72 31 33 21 2c 7b  | stmfd    r13!,{|
00000e10  72 30 2d 72 31 31 2c 72  31 34 7d 20 3b 20 53 74  |r0-r11,r14} ; St|
00000e20  6f 72 65 20 41 4c 4c 20  72 65 67 69 73 74 65 72  |ore ALL register|
00000e30  73 20 2d 20 6d 75 73 74  20 62 65 0a 20 20 20 20  |s - must be.    |
00000e40  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000e60  20 20 20 20 20 20 20 3b  20 70 72 65 73 65 72 76  |       ; preserv|
00000e70  65 64 20 21 0a 20 20 20  20 20 20 20 20 20 20 20  |ed !.           |
00000e80  20 20 20 20 20 6d 6f 76  20 20 20 20 20 20 72 30  |     mov      r0|
00000e90  2c 23 26 66 20 20 20 20  20 20 20 20 20 20 20 20  |,#&f            |
00000ea0  3b 20 59 65 74 20 61 67  61 69 6e 2c 20 46 53 43  |; Yet again, FSC|
00000eb0  6f 6e 74 72 6f 6c 56 0a  20 20 20 20 20 20 20 20  |ontrolV.        |
00000ec0  20 20 20 20 20 20 20 20  61 64 72 20 20 20 20 20  |        adr     |
00000ed0  20 72 31 2c 66 73 63 6f  6e 74 72 6f 6c 76 20 20  | r1,fscontrolv  |
00000ee0  20 20 20 3b 20 41 6e 64  20 74 68 65 20 61 64 64  |   ; And the add|
00000ef0  72 65 73 73 20 6f 66 20  6f 75 72 20 63 6f 64 65  |ress of our code|
00000f00  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000f10  20 6d 6f 76 20 20 20 20  20 20 72 32 2c 23 30 20  | mov      r2,#0 |
00000f20  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 45 6e  |            ; En|
00000f30  74 65 72 20 77 69 74 68  20 72 31 32 20 3d 20 30  |ter with r12 = 0|
00000f40  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00000f50  20 73 77 69 20 20 20 20  20 20 22 4f 53 5f 43 6c  | swi      "OS_Cl|
00000f60  61 69 6d 22 20 20 20 20  20 20 20 20 3b 20 43 6c  |aim"        ; Cl|
00000f70  61 69 6d 20 74 68 65 20  76 65 63 74 6f 72 2e 20  |aim the vector. |
00000f80  20 57 68 79 3f 0a 20 20  20 20 20 20 20 20 20 20  | Why?.          |
00000f90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000fb0  20 3b 20 57 65 6c 6c 2c  20 61 20 72 65 73 65 74  | ; Well, a reset|
00000fc0  20 72 65 6c 65 61 73 65  73 20 61 6c 6c 0a 20 20  | releases all.  |
00000fd0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000ff0  20 20 20 20 20 20 20 20  20 3b 20 76 65 63 74 6f  |         ; vecto|
00001000  72 20 63 6c 61 69 6d 73  20 73 6f 20 77 65 20 68  |r claims so we h|
00001010  61 76 65 20 74 6f 0a 20  20 20 20 20 20 20 20 20  |ave to.         |
00001020  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001040  20 20 3b 20 72 65 69 6e  73 74 61 74 65 20 74 68  |  ; reinstate th|
00001050  65 6d 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |em.             |
00001060  20 20 20 6d 6f 76 20 20  20 20 20 20 72 30 2c 23  |   mov      r0,#|
00001070  38 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |8             ; |
00001080  3d 38 20 46 69 6c 65 56  0a 20 20 20 20 20 20 20  |=8 FileV.       |
00001090  20 20 20 20 20 20 20 20  20 61 64 72 20 20 20 20  |         adr    |
000010a0  20 20 72 31 2c 66 69 6c  65 76 20 20 20 20 20 20  |  r1,filev      |
000010b0  20 20 20 20 3b 20 41 64  64 72 65 73 73 20 6f 66  |    ; Address of|
000010c0  20 6f 75 72 20 63 6f 64  65 0a 20 20 20 20 20 20  | our code.      |
000010d0  20 20 20 20 20 20 20 20  20 20 6d 6f 76 20 20 20  |          mov   |
000010e0  20 20 20 72 32 2c 23 30  20 20 20 20 20 20 20 20  |   r2,#0        |
000010f0  20 20 20 20 20 3b 20 45  6e 74 65 72 20 77 69 74  |     ; Enter wit|
00001100  68 20 72 31 32 20 3d 20  30 0a 20 20 20 20 20 20  |h r12 = 0.      |
00001110  20 20 20 20 20 20 20 20  20 20 73 77 69 20 20 20  |          swi   |
00001120  20 20 20 22 4f 53 5f 43  6c 61 69 6d 22 20 20 20  |   "OS_Claim"   |
00001130  20 20 20 20 20 3b 20 43  6c 61 69 6d 20 74 68 65  |     ; Claim the|
00001140  20 76 65 63 74 6f 72 0a  20 20 20 20 20 20 20 20  | vector.        |
00001150  20 20 20 20 20 20 20 20  6c 64 6d 66 64 20 20 20  |        ldmfd   |
00001160  20 72 31 33 21 2c 7b 72  30 2d 72 31 31 2c 70 63  | r13!,{r0-r11,pc|
00001170  7d 20 20 3b 20 52 65 2d  6c 6f 61 64 20 72 65 67  |}  ; Re-load reg|
00001180  69 73 74 65 72 73 20 61  6e 64 20 65 78 69 74 0a  |isters and exit.|
00001190  0a 3b 20 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |.; -------------|
000011a0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000011d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 0a 0a 3b  |-------------..;|
000011e0  20 54 68 69 73 20 69 73  20 74 68 65 20 6d 61 69  | This is the mai|
000011f0  6e 20 70 61 72 74 20 6f  66 20 74 68 65 20 63 6f  |n part of the co|
00001200  64 65 20 61 6e 64 20 69  73 20 63 61 6c 6c 65 64  |de and is called|
00001210  20 77 68 65 6e 65 76 65  72 20 61 20 4f 53 5f 46  | whenever a OS_F|
00001220  53 43 6f 6e 74 72 6f 6c  0a 3b 20 53 57 49 20 69  |SControl.; SWI i|
00001230  73 20 70 61 73 73 65 64  20 74 6f 20 74 68 65 20  |s passed to the |
00001240  4f 53 2e 20 20 57 65 20  63 68 65 63 6b 20 74 6f  |OS.  We check to|
00001250  20 73 65 65 20 69 66 20  69 74 20 69 73 20 74 6f  | see if it is to|
00001260  20 64 6f 20 77 69 74 68  20 2a 52 55 4e 6e 69 6e  | do with *RUNnin|
00001270  67 0a 3b 20 61 20 66 69  6c 65 20 28 72 65 61 73  |g.; a file (reas|
00001280  6f 6e 20 63 6f 64 65 20  34 29 20 61 6e 64 20 69  |on code 4) and i|
00001290  66 20 69 74 20 69 73 20  74 68 65 6e 20 77 65 20  |f it is then we |
000012a0  70 65 72 66 6f 72 6d 20  61 20 62 69 74 20 6f 66  |perform a bit of|
000012b0  20 70 72 65 2d 70 72 6f  63 65 73 73 69 6e 67 0a  | pre-processing.|
000012c0  3b 20 61 6e 64 20 63 72  65 61 74 65 20 28 6f 72  |; and create (or|
000012d0  20 61 6c 74 65 72 29 20  74 68 65 20 61 70 70 72  | alter) the appr|
000012e0  6f 70 72 69 61 74 65 20  73 79 73 74 65 6d 20 76  |opriate system v|
000012f0  61 72 69 61 62 6c 65 2e  0a 0a 66 73 63 6f 6e 74  |ariable...fscont|
00001300  72 6f 6c 76 20 20 20 20  20 20 63 6d 70 20 20 20  |rolv      cmp   |
00001310  20 20 20 72 30 2c 23 34  20 20 20 20 20 20 20 20  |   r0,#4        |
00001320  20 20 20 20 20 3b 20 49  73 20 69 74 20 2a 52 55  |     ; Is it *RU|
00001330  4e 20 66 69 6c 65 20 3f  0a 20 20 20 20 20 20 20  |N file ?.       |
00001340  20 20 20 20 20 20 20 20  20 6d 6f 76 6e 65 20 20  |         movne  |
00001350  20 20 70 63 2c 72 31 34  20 20 20 20 20 20 20 20  |  pc,r14        |
00001360  20 20 20 20 3b 20 49 66  20 6e 6f 74 2c 20 70 61  |    ; If not, pa|
00001370  73 73 20 69 74 20 6f 6e  0a 20 20 20 20 20 20 20  |ss it on.       |
00001380  20 20 20 20 20 20 20 20  20 73 74 6d 66 64 20 20  |         stmfd  |
00001390  20 20 72 31 33 21 2c 7b  72 30 2d 72 39 2c 72 31  |  r13!,{r0-r9,r1|
000013a0  34 7d 20 20 3b 20 53 74  6f 72 65 20 72 65 67 69  |4}  ; Store regi|
000013b0  73 74 65 72 73 0a 20 20  20 20 20 20 20 20 20 20  |sters.          |
000013c0  20 20 20 20 20 20 61 64  72 20 20 20 20 20 20 72  |      adr      r|
000013d0  36 2c 66 69 72 73 74 5f  62 69 74 20 20 20 20 20  |6,first_bit     |
000013e0  20 3b 20 47 65 74 20 61  64 64 72 65 73 73 20 6f  | ; Get address o|
000013f0  66 20 52 75 6e 46 69 6c  65 20 62 69 74 0a 20 20  |f RunFile bit.  |
00001400  20 20 20 20 20 20 20 20  20 20 20 20 20 20 6d 6f  |              mo|
00001410  76 20 20 20 20 20 20 72  37 2c 23 41 53 43 22 20  |v      r7,#ASC" |
00001420  22 20 20 20 20 20 20 20  20 3b 20 53 70 61 63 65  |"        ; Space|
00001430  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00001440  20 73 74 72 62 20 20 20  20 20 72 37 2c 5b 72 36  | strb     r7,[r6|
00001450  5d 2c 23 31 20 20 20 20  20 20 20 20 3b 20 53 74  |],#1        ; St|
00001460  6f 72 65 20 69 74 0a 20  20 20 20 20 20 20 20 20  |ore it.         |
00001470  20 20 20 20 20 20 20 6d  6f 76 20 20 20 20 20 20  |       mov      |
00001480  72 37 2c 23 41 53 43 22  52 22 20 20 20 20 20 20  |r7,#ASC"R"      |
00001490  20 20 3b 20 52 0a 20 20  20 20 20 20 20 20 20 20  |  ; R.          |
000014a0  20 20 20 20 20 20 73 74  72 62 20 20 20 20 20 72  |      strb     r|
000014b0  37 2c 5b 72 36 5d 2c 23  31 20 20 20 20 20 20 20  |7,[r6],#1       |
000014c0  20 3b 20 53 74 6f 72 65  20 69 74 0a 20 20 20 20  | ; Store it.    |
000014d0  20 20 20 20 20 20 20 20  20 20 20 20 6d 6f 76 20  |            mov |
000014e0  20 20 20 20 20 72 37 2c  23 41 53 43 22 75 22 20  |     r7,#ASC"u" |
000014f0  20 20 20 20 20 20 20 3b  20 75 0a 20 20 20 20 20  |       ; u.     |
00001500  20 20 20 20 20 20 20 20  20 20 20 73 74 72 62 20  |           strb |
00001510  20 20 20 20 72 37 2c 5b  72 36 5d 2c 23 31 20 20  |    r7,[r6],#1  |
00001520  20 20 20 20 20 20 3b 20  53 74 6f 72 65 20 69 74  |      ; Store it|
00001530  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00001540  20 6d 6f 76 20 20 20 20  20 20 72 37 2c 23 41 53  | mov      r7,#AS|
00001550  43 22 6e 22 20 20 20 20  20 20 20 20 3b 20 6e 0a  |C"n"        ; n.|
00001560  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001570  73 74 72 62 20 20 20 20  20 72 37 2c 5b 72 36 5d  |strb     r7,[r6]|
00001580  2c 23 31 20 20 20 20 20  20 20 20 3b 20 53 74 6f  |,#1        ; Sto|
00001590  72 65 20 69 74 0a 64 6f  5f 76 61 72 5f 62 69 74  |re it.do_var_bit|
000015a0  20 20 20 20 20 20 6d 6f  76 20 20 20 20 20 20 72  |      mov      r|
000015b0  38 2c 72 31 20 20 20 20  20 20 20 20 20 20 20 20  |8,r1            |
000015c0  20 3b 20 4d 61 6b 65 20  61 20 63 6f 70 79 20 6f  | ; Make a copy o|
000015d0  66 20 66 69 6c 65 6e 61  6d 65 20 70 6f 69 6e 74  |f filename point|
000015e0  65 72 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |er.             |
000015f0  20 20 20 6d 6f 76 20 20  20 20 20 20 72 30 2c 23  |   mov      r0,#|
00001600  35 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |5             ; |
00001610  53 65 74 20 74 6f 20 69  6e 66 6f 20 6f 6e 20 66  |Set to info on f|
00001620  69 6c 65 0a 20 20 20 20  20 20 20 20 20 20 20 20  |ile.            |
00001630  20 20 20 20 73 77 69 20  20 20 20 20 20 22 58 4f  |    swi      "XO|
00001640  53 5f 46 69 6c 65 22 20  20 20 20 20 20 20 20 3b  |S_File"        ;|
00001650  20 47 65 74 20 74 68 65  20 64 61 74 61 0a 20 20  | Get the data.  |
00001660  20 20 20 20 20 20 20 20  20 20 20 20 20 20 6c 64  |              ld|
00001670  6d 76 73 66 64 20 20 72  31 33 21 2c 7b 72 30 2d  |mvsfd  r13!,{r0-|
00001680  72 38 2c 70 63 7d 20 20  20 3b 20 49 66 20 74 68  |r8,pc}   ; If th|
00001690  65 72 65 20 69 73 20 61  20 70 72 6f 62 6c 65 6d  |ere is a problem|
000016a0  2c 20 65 78 69 74 0a 20  20 20 20 20 20 20 20 20  |, exit.         |
000016b0  20 20 20 20 20 20 20 6d  6f 76 20 20 20 20 20 20  |       mov      |
000016c0  72 32 2c 72 32 2c 6c 73  72 20 23 38 20 20 20 20  |r2,r2,lsr #8    |
000016d0  20 20 3b 20 53 68 69 66  74 20 74 68 65 20 6c 6f  |  ; Shift the lo|
000016e0  61 64 20 61 64 64 72 65  73 73 20 72 69 67 68 74  |ad address right|
000016f0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00001700  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001710  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 38 20  |            ; 8 |
00001720  74 69 6d 65 73 0a 20 20  20 20 20 20 20 20 20 20  |times.          |
00001730  20 20 20 20 20 20 6c 64  72 20 20 20 20 20 20 72  |      ldr      r|
00001740  33 2c 6e 75 6d 5f 66 66  66 20 20 20 20 20 20 20  |3,num_fff       |
00001750  20 3b 20 47 65 74 20 74  68 65 20 63 6f 6e 73 74  | ; Get the const|
00001760  61 6e 74 20 34 30 39 35  20 28 26 46 46 46 29 0a  |ant 4095 (&FFF).|
00001770  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001780  61 6e 64 20 20 20 20 20  20 72 32 2c 72 32 2c 72  |and      r2,r2,r|
00001790  33 20 20 20 20 20 20 20  20 20 20 3b 20 4c 6f 67  |3          ; Log|
000017a0  69 63 61 6c 6c 79 20 41  4e 44 20 74 68 65 20 73  |ically AND the s|
000017b0  68 69 66 74 65 64 2d 72  69 67 68 74 0a 20 20 20  |hifted-right.   |
000017c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000017e0  20 20 20 20 20 20 20 20  3b 20 6c 6f 61 64 20 61  |        ; load a|
000017f0  64 64 72 65 73 73 20 77  69 74 68 20 34 30 39 35  |ddress with 4095|
00001800  20 28 26 46 46 46 29 0a  20 20 20 20 20 20 20 20  | (&FFF).        |
00001810  20 20 20 20 20 20 20 20  6d 6f 76 20 20 20 20 20  |        mov     |
00001820  20 72 30 2c 72 32 20 20  20 20 20 20 20 20 20 20  | r0,r2          |
00001830  20 20 20 3b 20 53 65 74  20 72 30 20 74 6f 20 70  |   ; Set r0 to p|
00001840  72 6f 63 65 73 73 65 64  20 6c 6f 61 64 20 61 64  |rocessed load ad|
00001850  64 72 65 73 73 0a 20 20  20 20 20 20 20 20 20 20  |dress.          |
00001860  20 20 20 20 20 20 61 64  72 20 20 20 20 20 20 72  |      adr      r|
00001870  31 2c 62 75 66 66 65 72  20 20 20 20 20 20 20 20  |1,buffer        |
00001880  20 3b 20 53 65 74 20 72  31 20 74 6f 20 70 6f 69  | ; Set r1 to poi|
00001890  6e 74 20 74 6f 20 61 20  62 75 66 66 65 72 0a 20  |nt to a buffer. |
000018a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 6d  |               m|
000018b0  6f 76 20 20 20 20 20 20  72 32 2c 23 38 20 20 20  |ov      r2,#8   |
000018c0  20 20 20 20 20 20 20 20  20 20 3b 20 53 65 74 20  |          ; Set |
000018d0  72 32 20 74 6f 20 6d 61  78 69 6d 75 6d 20 73 69  |r2 to maximum si|
000018e0  7a 65 20 6f 66 20 62 75  66 66 65 72 0a 20 20 20  |ze of buffer.   |
000018f0  20 20 20 20 20 20 20 20  20 20 20 20 20 73 77 69  |             swi|
00001900  20 20 20 20 20 20 22 4f  53 5f 43 6f 6e 76 65 72  |      "OS_Conver|
00001910  74 48 65 78 34 22 20 20  3b 20 43 6f 6e 76 65 72  |tHex4"  ; Conver|
00001920  74 20 72 30 20 74 6f 20  61 20 68 65 78 20 6e 75  |t r0 to a hex nu|
00001930  6d 62 65 72 0a 0a 3b 20  57 68 61 74 20 69 73 20  |mber..; What is |
00001940  74 68 65 20 70 6f 69 6e  74 20 6f 66 20 61 6c 6c  |the point of all|
00001950  20 74 68 65 20 61 62 6f  76 65 20 61 72 69 74 68  | the above arith|
00001960  6d 65 74 69 63 20 3f 20  20 57 68 61 74 20 69 74  |metic ?  What it|
00001970  20 61 63 74 75 61 6c 6c  79 20 63 6f 6d 65 73 0a  | actually comes.|
00001980  3b 20 64 6f 77 6e 20 74  6f 20 69 73 20 74 68 61  |; down to is tha|
00001990  74 20 74 68 65 20 6f 70  65 72 61 74 69 6e 67 20  |t the operating |
000019a0  73 79 73 74 65 6d 20 73  74 6f 72 65 73 20 74 68  |system stores th|
000019b0  65 20 66 69 6c 65 74 79  70 65 20 69 6e 20 74 68  |e filetype in th|
000019c0  65 20 6c 6f 61 64 0a 3b  20 61 64 64 72 65 73 73  |e load.; address|
000019d0  20 6f 66 20 61 20 66 69  6c 65 20 2d 20 6f 6e 20  | of a file - on |
000019e0  74 68 65 20 6f 6c 64 20  42 42 43 20 74 68 69 73  |the old BBC this|
000019f0  20 77 61 73 20 74 68 65  20 61 64 64 72 65 73 73  | was the address|
00001a00  20 28 69 6e 20 6d 65 6d  6f 72 79 29 20 77 68 65  | (in memory) whe|
00001a10  72 65 0a 3b 20 74 68 65  20 66 69 6c 65 20 77 61  |re.; the file wa|
00001a20  73 20 6c 6f 61 64 65 64  20 74 6f 20 69 66 20 6e  |s loaded to if n|
00001a30  6f 20 6f 74 68 65 72 20  61 64 64 72 65 73 73 20  |o other address |
00001a40  77 61 73 20 73 70 65 63  69 66 69 65 64 2e 20 20  |was specified.  |
00001a50  49 74 20 74 61 6b 65 73  20 74 68 65 0a 3b 20 66  |It takes the.; f|
00001a60  6f 72 6d 20 2d 0a 0a 3b  20 20 20 20 46 46 46 74  |orm -..;    FFFt|
00001a70  74 74 64 64 64 0a 0a 3b  20 57 68 65 72 65 20 74  |ttddd..; Where t|
00001a80  68 65 20 46 46 46 20 69  73 20 61 6e 20 61 63 74  |he FFF is an act|
00001a90  75 61 6c 20 63 6f 6e 73  74 61 6e 74 2c 20 74 68  |ual constant, th|
00001aa0  65 20 74 74 74 20 72 65  66 65 72 73 20 74 6f 20  |e ttt refers to |
00001ab0  74 68 65 20 66 69 6c 65  20 74 79 70 65 2c 20 61  |the file type, a|
00001ac0  6e 64 0a 3b 20 74 68 65  20 64 64 64 20 69 73 20  |nd.; the ddd is |
00001ad0  70 61 72 74 20 6f 66 20  74 68 65 20 64 61 74 65  |part of the date|
00001ae0  20 73 74 61 6d 70 2e 20  20 41 73 20 61 6e 20 65  | stamp.  As an e|
00001af0  78 61 6d 70 6c 65 2c 20  61 20 66 69 6c 65 20 6d  |xample, a file m|
00001b00  69 67 68 74 20 68 61 76  65 20 74 68 65 0a 3b 20  |ight have the.; |
00001b10  61 64 64 72 65 73 73 20  2d 0a 0a 3b 20 20 20 20  |address -..;    |
00001b20  46 46 46 46 46 39 33 41  39 0a 0a 3b 20 41 6e 64  |FFFFF93A9..; And|
00001b30  20 66 72 6f 6d 20 74 68  69 73 20 77 65 20 63 61  | from this we ca|
00001b40  6e 20 73 65 65 20 74 68  61 74 20 74 68 65 20 66  |n see that the f|
00001b50  69 6c 65 20 74 79 70 65  20 69 73 20 46 46 39 20  |ile type is FF9 |
00001b60  2d 20 61 20 73 70 72 69  74 65 20 66 69 6c 65 2e  |- a sprite file.|
00001b70  20 20 49 66 0a 3b 20 77  65 20 73 68 69 66 74 20  |  If.; we shift |
00001b80  72 69 67 68 74 20 38 20  74 69 6d 65 73 20 61 6e  |right 8 times an|
00001b90  64 20 41 4e 44 20 74 68  69 73 20 77 69 74 68 20  |d AND this with |
00001ba0  26 46 46 46 20 74 68 65  6e 20 77 65 20 63 61 6e  |&FFF then we can|
00001bb0  20 6f 62 74 61 69 6e 20  46 46 39 20 6f 6e 0a 3b  | obtain FF9 on.;|
00001bc0  20 69 74 73 20 6f 77 6e  2e 0a 0a 20 20 20 20 20  | its own...     |
00001bd0  20 20 20 20 20 20 20 20  20 20 20 20 20 61 64 72  |             adr|
00001be0  20 20 20 20 20 72 31 2c  72 75 6e 5f 74 79 70 65  |     r1,run_type|
00001bf0  20 20 20 20 20 20 20 3b  20 53 65 74 20 72 31 20  |       ; Set r1 |
00001c00  74 6f 20 70 6f 69 6e 74  20 74 6f 20 76 61 72 69  |to point to vari|
00001c10  61 62 6c 65 0a 20 20 20  20 20 20 20 20 20 20 20  |able.           |
00001c20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001c40  20 3b 20 74 79 70 65 20  73 65 63 74 69 6f 6e 20  | ; type section |
00001c50  28 74 68 65 20 58 58 58  20 6f 66 0a 20 20 20 20  |(the XXX of.    |
00001c60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001c80  20 20 20 20 20 20 20 20  3b 20 46 69 6c 65 5f 58  |        ; File_X|
00001c90  58 58 24 44 69 72 29 0a  20 20 20 20 20 20 20 20  |XX$Dir).        |
00001ca0  20 20 20 20 20 20 20 20  20 20 6c 64 72 62 20 20  |          ldrb  |
00001cb0  20 20 72 32 2c 5b 72 30  2c 23 31 5d 20 20 20 20  |  r2,[r0,#1]    |
00001cc0  20 20 20 20 3b 20 47 65  74 20 66 69 72 73 74 20  |    ; Get first |
00001cd0  62 79 74 65 0a 20 20 20  20 20 20 20 20 20 20 20  |byte.           |
00001ce0  20 20 20 20 20 20 20 73  74 72 62 20 20 20 20 72  |       strb    r|
00001cf0  32 2c 5b 72 31 2c 23 30  5d 20 20 20 20 20 20 20  |2,[r1,#0]       |
00001d00  20 3b 20 41 6e 64 20 73  74 6f 72 65 20 69 74 0a  | ; And store it.|
00001d10  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001d20  20 20 6c 64 72 62 20 20  20 20 72 32 2c 5b 72 30  |  ldrb    r2,[r0|
00001d30  2c 23 32 5d 20 20 20 20  20 20 20 20 3b 20 47 65  |,#2]        ; Ge|
00001d40  74 20 73 65 63 6f 6e 64  20 62 79 74 65 0a 20 20  |t second byte.  |
00001d50  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001d60  73 74 72 62 20 20 20 20  72 32 2c 5b 72 31 2c 23  |strb    r2,[r1,#|
00001d70  31 5d 20 20 20 20 20 20  20 20 3b 20 41 6e 64 20  |1]        ; And |
00001d80  73 74 6f 72 65 20 69 74  0a 20 20 20 20 20 20 20  |store it.       |
00001d90  20 20 20 20 20 20 20 20  20 20 20 6c 64 72 62 20  |           ldrb |
00001da0  20 20 20 72 32 2c 5b 72  30 2c 23 33 5d 20 20 20  |   r2,[r0,#3]   |
00001db0  20 20 20 20 20 3b 20 47  65 74 20 74 68 69 72 64  |     ; Get third|
00001dc0  20 62 79 74 65 0a 20 20  20 20 20 20 20 20 20 20  | byte.          |
00001dd0  20 20 20 20 20 20 20 20  73 74 72 62 20 20 20 20  |        strb    |
00001de0  72 32 2c 5b 72 31 2c 23  32 5d 20 20 20 20 20 20  |r2,[r1,#2]      |
00001df0  20 20 3b 20 41 6e 64 20  73 74 6f 72 65 20 69 74  |  ; And store it|
00001e00  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
00001e10  20 20 20 6d 6f 76 20 20  20 20 20 72 31 2c 72 38  |   mov     r1,r8|
00001e20  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 47  |             ; G|
00001e30  65 74 20 6f 75 72 20 63  6f 70 79 20 6f 66 20 74  |et our copy of t|
00001e40  68 65 20 66 69 6c 65 6e  61 6d 65 0a 20 20 20 20  |he filename.    |
00001e50  20 20 20 20 20 20 20 20  20 20 20 20 20 20 6d 6f  |              mo|
00001e60  76 20 20 20 20 20 72 39  2c 23 30 20 20 20 20 20  |v     r9,#0     |
00001e70  20 20 20 20 20 20 20 20  3b 20 53 65 74 20 61 20  |        ; Set a |
00001e80  66 6c 61 67 20 74 6f 20  30 20 2d 20 73 65 65 20  |flag to 0 - see |
00001e90  6c 61 74 65 72 0a 66 69  6e 64 5f 65 6e 64 20 20  |later.find_end  |
00001ea0  20 20 20 20 20 20 20 20  6c 64 72 62 20 20 20 20  |        ldrb    |
00001eb0  72 32 2c 5b 72 31 5d 2c  23 31 20 20 20 20 20 20  |r2,[r1],#1      |
00001ec0  20 20 3b 20 47 65 74 20  61 20 62 79 74 65 2e 2e  |  ; Get a byte..|
00001ed0  2e 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |..              |
00001ee0  20 20 20 20 63 6d 70 20  20 20 20 20 72 32 2c 23  |    cmp     r2,#|
00001ef0  41 53 43 22 2e 22 20 20  20 20 20 20 20 20 3b 20  |ASC"."        ; |
00001f00  49 73 20 69 74 20 61 20  64 6f 74 20 3f 0a 20 20  |Is it a dot ?.  |
00001f10  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001f20  6d 6f 76 65 71 20 20 20  72 39 2c 23 31 20 20 20  |moveq   r9,#1   |
00001f30  20 20 20 20 20 20 20 20  20 20 3b 20 49 66 20 69  |          ; If i|
00001f40  74 20 69 73 2c 20 73 65  74 20 74 68 65 20 66 6c  |t is, set the fl|
00001f50  61 67 20 74 6f 20 31 0a  20 20 20 20 20 20 20 20  |ag to 1.        |
00001f60  20 20 20 20 20 20 20 20  20 20 63 6d 70 20 20 20  |          cmp   |
00001f70  20 20 72 32 2c 23 33 32  20 20 20 20 20 20 20 20  |  r2,#32        |
00001f80  20 20 20 20 3b 20 43 6f  6d 70 61 72 65 20 69 74  |    ; Compare it|
00001f90  20 77 69 74 68 20 41 53  43 49 49 20 33 32 2e 2e  | with ASCII 32..|
00001fa0  2e 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |..              |
00001fb0  20 20 20 20 62 67 74 20  20 20 20 20 66 69 6e 64  |    bgt     find|
00001fc0  5f 65 6e 64 20 20 20 20  20 20 20 20 20 20 3b 20  |_end          ; |
00001fd0  49 66 20 67 72 65 61 74  65 72 20 74 68 61 6e 2c  |If greater than,|
00001fe0  20 62 72 61 6e 63 68 20  62 61 63 6b 2e 0a 20 20  | branch back..  |
00001ff0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002010  20 20 20 20 20 20 20 20  20 20 3b 20 72 31 20 6e  |          ; r1 n|
00002020  6f 77 20 70 6f 69 6e 74  73 20 74 6f 20 74 68 65  |ow points to the|
00002030  20 62 79 74 65 20 61 66  74 65 72 0a 20 20 20 20  | byte after.    |
00002040  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002060  20 20 20 20 20 20 20 20  3b 20 74 68 65 20 65 6e  |        ; the en|
00002070  64 20 6f 66 20 73 74 72  69 6e 67 20 6d 61 72 6b  |d of string mark|
00002080  65 72 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |er.             |
00002090  20 20 20 20 20 63 6d 70  20 20 20 20 20 72 39 2c  |     cmp     r9,|
000020a0  23 31 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |#1             ;|
000020b0  20 49 73 20 74 68 65 72  65 20 61 20 64 6f 74 20  | Is there a dot |
000020c0  69 6e 20 74 68 65 20 73  74 72 69 6e 67 20 3f 0a  |in the string ?.|
000020d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000020e0  20 20 6c 64 6d 6e 65 66  64 20 72 31 33 21 2c 7b  |  ldmnefd r13!,{|
000020f0  72 30 2d 72 39 2c 70 63  7d 20 20 20 3b 20 49 66  |r0-r9,pc}   ; If|
00002100  20 6e 6f 74 2c 20 65 78  69 74 2c 20 62 65 63 61  | not, exit, beca|
00002110  75 73 65 20 77 65 20 63  61 6e 27 74 0a 20 20 20  |use we can't.   |
00002120  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002140  20 20 20 20 20 20 20 20  20 3b 20 73 65 74 20 74  |         ; set t|
00002150  68 65 20 76 61 72 69 61  62 6c 65 20 74 6f 20 61  |he variable to a|
00002160  20 64 69 72 65 63 74 6f  72 79 0a 20 20 20 20 20  | directory.     |
00002170  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002190  20 20 20 20 20 20 20 3b  20 6e 61 6d 65 20 28 73  |       ; name (s|
000021a0  61 66 65 67 75 61 72 64  20 66 65 61 74 75 72 65  |afeguard feature|
000021b0  29 0a 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |).              |
000021c0  20 20 20 20 73 75 62 20  20 20 20 20 72 31 2c 72  |    sub     r1,r|
000021d0  31 2c 23 31 20 20 20 20  20 20 20 20 20 20 3b 20  |1,#1          ; |
000021e0  4e 6f 77 20 70 6f 69 6e  74 73 20 74 6f 20 65 6e  |Now points to en|
000021f0  64 20 6f 66 20 73 74 72  69 6e 67 0a 66 69 6e 64  |d of string.find|
00002200  5f 64 6f 74 20 20 20 20  20 20 20 20 20 20 6c 64  |_dot          ld|
00002210  72 62 20 20 20 20 72 32  2c 5b 72 31 5d 2c 23 2d  |rb    r2,[r1],#-|
00002220  31 20 20 20 20 20 20 20  3b 20 47 65 74 20 61 20  |1       ; Get a |
00002230  62 79 74 65 2e 2e 2e 0a  20 20 20 20 20 20 20 20  |byte....        |
00002240  20 20 20 20 20 20 20 20  20 20 63 6d 70 20 20 20  |          cmp   |
00002250  20 20 72 32 2c 23 41 53  43 22 2e 22 20 20 20 20  |  r2,#ASC"."    |
00002260  20 20 20 20 3b 20 43 6f  6d 70 61 72 65 20 69 74  |    ; Compare it|
00002270  20 77 69 74 68 20 41 53  43 49 49 20 66 6f 72 20  | with ASCII for |
00002280  22 2e 22 0a 20 20 20 20  20 20 20 20 20 20 20 20  |".".            |
00002290  20 20 20 20 20 20 62 6e  65 20 20 20 20 20 66 69  |      bne     fi|
000022a0  6e 64 5f 64 6f 74 20 20  20 20 20 20 20 20 20 20  |nd_dot          |
000022b0  3b 20 49 66 20 6e 6f 74  2c 20 62 72 61 6e 63 68  |; If not, branch|
000022c0  20 62 61 63 6b 0a 20 20  20 20 20 20 20 20 20 20  | back.          |
000022d0  20 20 20 20 20 20 20 20  6d 6f 76 20 20 20 20 20  |        mov     |
000022e0  72 32 2c 23 30 20 20 20  20 20 20 20 20 20 20 20  |r2,#0           |
000022f0  20 20 3b 20 45 6e 64 20  6f 66 20 73 74 72 69 6e  |  ; End of strin|
00002300  67 20 6d 61 72 6b 65 72  0a 20 20 20 20 20 20 20  |g marker.       |
00002310  20 20 20 20 20 20 20 20  20 20 20 73 74 72 62 20  |           strb |
00002320  20 20 20 72 32 2c 5b 72  31 2c 23 31 5d 20 20 20  |   r2,[r1,#1]   |
00002330  20 20 20 20 20 3b 20 53  74 6f 72 65 20 69 74 0a  |     ; Store it.|
00002340  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002350  20 20 6d 6f 76 20 20 20  20 20 72 39 2c 72 31 20  |  mov     r9,r1 |
00002360  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 4d 61  |            ; Ma|
00002370  6b 65 20 61 20 63 6f 70  79 20 6f 66 20 74 68 65  |ke a copy of the|
00002380  20 61 64 64 72 65 73 73  0a 20 20 20 20 20 20 20  | address.       |
00002390  20 20 20 20 20 20 20 20  20 20 20 61 64 72 20 20  |           adr  |
000023a0  20 20 20 72 30 2c 72 75  6e 5f 76 61 6c 20 20 20  |   r0,run_val   |
000023b0  20 20 20 20 20 3b 20 47  65 74 20 61 64 64 72 65  |     ; Get addre|
000023c0  73 73 20 6f 66 20 76 61  6c 75 65 20 73 6c 6f 74  |ss of value slot|
000023d0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
000023e0  20 20 20 6d 6f 76 20 20  20 20 20 72 31 2c 72 38  |   mov     r1,r8|
000023f0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 47  |             ; G|
00002400  65 74 20 63 6f 70 79 20  6f 66 20 66 69 6c 65 6e  |et copy of filen|
00002410  61 6d 65 0a 6d 61 6b 65  5f 63 6f 70 79 20 20 20  |ame.make_copy   |
00002420  20 20 20 20 20 20 6c 64  72 62 20 20 20 20 72 32  |      ldrb    r2|
00002430  2c 5b 72 31 5d 2c 23 31  20 20 20 20 20 20 20 20  |,[r1],#1        |
00002440  3b 20 47 65 74 20 61 20  62 79 74 65 2e 2e 2e 0a  |; Get a byte....|
00002450  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002460  20 20 63 6d 70 20 20 20  20 20 72 32 2c 23 33 32  |  cmp     r2,#32|
00002470  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 43 6f  |            ; Co|
00002480  6d 70 61 72 65 20 69 74  20 77 69 74 68 20 41 53  |mpare it with AS|
00002490  43 49 49 20 33 32 0a 20  20 20 20 20 20 20 20 20  |CII 32.         |
000024a0  20 20 20 20 20 20 20 20  20 73 74 72 62 20 20 20  |         strb   |
000024b0  20 72 32 2c 5b 72 30 5d  2c 23 31 20 20 20 20 20  | r2,[r0],#1     |
000024c0  20 20 20 3b 20 53 74 6f  72 65 20 69 74 2e 2e 2e  |   ; Store it...|
000024d0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
000024e0  20 20 20 62 67 74 20 20  20 20 20 6d 61 6b 65 5f  |   bgt     make_|
000024f0  63 6f 70 79 20 20 20 20  20 20 20 20 20 3b 20 49  |copy         ; I|
00002500  66 20 67 72 65 61 74 65  72 20 74 68 61 6e 2c 20  |f greater than, |
00002510  62 72 61 6e 63 68 20 62  61 63 6b 0a 20 20 20 20  |branch back.    |
00002520  20 20 20 20 20 20 20 20  20 20 20 20 20 20 61 64  |              ad|
00002530  72 20 20 20 20 20 72 30  2c 72 75 6e 5f 76 61 72  |r     r0,run_var|
00002540  20 20 20 20 20 20 20 20  3b 20 47 65 74 20 61 64  |        ; Get ad|
00002550  64 72 65 73 73 20 6f 66  20 43 4c 49 20 73 74 72  |dress of CLI str|
00002560  69 6e 67 0a 20 20 20 20  20 20 20 20 20 20 20 20  |ing.            |
00002570  20 20 20 20 20 20 73 77  69 20 20 20 20 20 22 4f  |      swi     "O|
00002580  53 5f 43 4c 49 22 20 20  20 20 20 20 20 20 20 20  |S_CLI"          |
00002590  3b 20 53 65 74 20 74 68  65 20 76 61 72 69 61 62  |; Set the variab|
000025a0  6c 65 20 76 61 6c 75 65  0a 20 20 20 20 20 20 20  |le value.       |
000025b0  20 20 20 20 20 20 20 20  20 20 20 6d 6f 76 20 20  |           mov  |
000025c0  20 20 20 72 32 2c 23 41  53 43 22 2e 22 20 20 20  |   r2,#ASC"."   |
000025d0  20 20 20 20 20 3b 20 4d  61 6b 65 20 72 32 20 3d  |     ; Make r2 =|
000025e0  20 22 2e 22 0a 20 20 20  20 20 20 20 20 20 20 20  | ".".           |
000025f0  20 20 20 20 20 20 20 73  74 72 62 20 20 20 20 72  |       strb    r|
00002600  32 2c 5b 72 39 2c 23 31  5d 20 20 20 20 20 20 20  |2,[r9,#1]       |
00002610  20 3b 20 41 6e 64 20 73  74 6f 72 65 20 69 74 20  | ; And store it |
00002620  6f 76 65 72 20 74 68 65  20 65 6e 64 20 6f 66 0a  |over the end of.|
00002630  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002650  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 73 74  |            ; st|
00002660  72 69 6e 67 20 6d 61 72  6b 65 72 0a 20 20 20 20  |ring marker.    |
00002670  20 20 20 20 20 20 20 20  20 20 20 20 20 20 6c 64  |              ld|
00002680  6d 66 64 20 20 20 72 31  33 21 2c 7b 72 30 2d 72  |mfd   r13!,{r0-r|
00002690  39 2c 70 63 7d 20 20 20  3b 20 52 65 2d 6c 6f 61  |9,pc}   ; Re-loa|
000026a0  64 20 72 65 67 69 73 74  65 72 73 20 61 6e 64 20  |d registers and |
000026b0  70 61 73 73 20 6f 6e 0a  20 20 20 20 20 20 20 20  |pass on.        |
000026c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000026e0  20 20 20 20 3b 20 74 68  65 20 63 61 6c 6c 0a 0a  |    ; the call..|
000026f0  3b 20 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |; --------------|
00002700  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00002730  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 0a 0a 3b 20  |------------..; |
00002740  54 68 69 73 20 69 73 20  74 68 65 20 73 65 63 6f  |This is the seco|
00002750  6e 64 20 69 6d 70 6f 72  74 61 6e 74 20 70 61 72  |nd important par|
00002760  74 20 6f 66 20 74 68 65  20 63 6f 64 65 20 61 6e  |t of the code an|
00002770  64 20 69 73 20 63 61 6c  6c 65 64 20 77 68 65 6e  |d is called when|
00002780  20 61 6e 20 4f 53 5f 46  69 6c 65 0a 3b 20 69 73  | an OS_File.; is|
00002790  20 64 69 73 63 6f 76 65  72 65 64 2e 20 20 49 74  | discovered.  It|
000027a0  20 63 68 65 63 6b 73 20  69 66 20 69 74 20 69 73  | checks if it is|
000027b0  20 6c 6f 61 64 20 66 69  6c 65 20 28 26 66 66 29  | load file (&ff)|
000027c0  20 61 6e 64 20 69 66 20  69 74 20 69 73 20 69 74  | and if it is it|
000027d0  20 73 65 74 73 0a 3b 20  61 20 76 61 72 69 61 62  | sets.; a variab|
000027e0  6c 65 20 4c 6f 61 64 46  69 6c 65 5f 58 58 58 24  |le LoadFile_XXX$|
000027f0  44 69 72 20 74 6f 20 74  68 65 20 64 69 72 65 63  |Dir to the direc|
00002800  74 6f 72 79 20 6f 66 20  74 68 65 20 66 69 6c 65  |tory of the file|
00002810  2c 20 61 73 20 61 62 6f  76 65 0a 0a 66 69 6c 65  |, as above..file|
00002820  76 20 20 20 20 20 20 20  20 20 20 20 20 20 63 6d  |v             cm|
00002830  70 20 20 20 20 20 72 30  2c 23 26 66 66 20 20 20  |p     r0,#&ff   |
00002840  20 20 20 20 20 20 20 20  3b 20 49 73 20 69 74 20  |        ; Is it |
00002850  6c 6f 61 64 20 66 69 6c  65 20 3f 0a 20 20 20 20  |load file ?.    |
00002860  20 20 20 20 20 20 20 20  20 20 20 20 20 20 63 6d  |              cm|
00002870  70 6e 65 20 20 20 72 30  2c 23 26 63 20 20 20 20  |pne   r0,#&c    |
00002880  20 20 20 20 20 20 20 20  3b 20 41 6e 6f 74 68 65  |        ; Anothe|
00002890  72 20 73 6f 72 74 20 6f  66 20 6c 6f 61 64 0a 20  |r sort of load. |
000028a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000028b0  20 63 6d 70 6e 65 20 20  20 72 30 2c 23 26 65 20  | cmpne   r0,#&e |
000028c0  20 20 20 20 20 20 20 20  20 20 20 3b 20 59 65 74  |           ; Yet|
000028d0  20 61 6e 6f 74 68 65 72  0a 20 20 20 20 20 20 20  | another.       |
000028e0  20 20 20 20 20 20 20 20  20 20 20 63 6d 70 6e 65  |           cmpne|
000028f0  20 20 20 72 30 2c 23 26  31 30 20 20 20 20 20 20  |   r0,#&10      |
00002900  20 20 20 20 20 3b 20 41  6e 64 20 61 6e 6f 74 68  |     ; And anoth|
00002910  65 72 0a 20 20 20 20 20  20 20 20 20 20 20 20 20  |er.             |
00002920  20 20 20 20 20 6d 6f 76  6e 65 20 20 20 70 63 2c  |     movne   pc,|
00002930  72 31 34 20 20 20 20 20  20 20 20 20 20 20 20 3b  |r14            ;|
00002940  20 49 66 20 69 74 20 69  73 6e 27 74 2c 20 67 6f  | If it isn't, go|
00002950  20 61 77 61 79 21 0a 20  20 20 20 20 20 20 20 20  | away!.         |
00002960  20 20 20 20 20 20 20 20  20 73 74 6d 66 64 20 20  |         stmfd  |
00002970  20 72 31 33 21 2c 7b 72  30 2d 72 39 2c 72 31 34  | r13!,{r0-r9,r14|
00002980  7d 20 20 3b 20 53 74 6f  72 65 20 72 65 67 69 73  |}  ; Store regis|
00002990  74 65 72 73 0a 20 20 20  20 20 20 20 20 20 20 20  |ters.           |
000029a0  20 20 20 20 20 20 20 61  64 72 20 20 20 20 20 72  |       adr     r|
000029b0  36 2c 66 69 72 73 74 5f  62 69 74 20 20 20 20 20  |6,first_bit     |
000029c0  20 3b 20 47 65 74 20 61  64 64 72 65 73 73 20 6f  | ; Get address o|
000029d0  66 20 4c 6f 61 64 46 69  6c 65 20 62 69 74 0a 20  |f LoadFile bit. |
000029e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000029f0  20 6d 6f 76 20 20 20 20  20 72 37 2c 23 41 53 43  | mov     r7,#ASC|
00002a00  22 4c 22 20 20 20 20 20  20 20 20 3b 20 4c 0a 20  |"L"        ; L. |
00002a10  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002a20  20 73 74 72 62 20 20 20  20 72 37 2c 5b 72 36 5d  | strb    r7,[r6]|
00002a30  2c 23 31 20 20 20 20 20  20 20 20 3b 20 53 74 6f  |,#1        ; Sto|
00002a40  72 65 20 69 74 0a 20 20  20 20 20 20 20 20 20 20  |re it.          |
00002a50  20 20 20 20 20 20 20 20  6d 6f 76 20 20 20 20 20  |        mov     |
00002a60  72 37 2c 23 41 53 43 22  6f 22 20 20 20 20 20 20  |r7,#ASC"o"      |
00002a70  20 20 3b 20 6f 0a 20 20  20 20 20 20 20 20 20 20  |  ; o.          |
00002a80  20 20 20 20 20 20 20 20  73 74 72 62 20 20 20 20  |        strb    |
00002a90  72 37 2c 5b 72 36 5d 2c  23 31 20 20 20 20 20 20  |r7,[r6],#1      |
00002aa0  20 20 3b 20 53 74 6f 72  65 20 69 74 0a 20 20 20  |  ; Store it.   |
00002ab0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 6d  |               m|
00002ac0  6f 76 20 20 20 20 20 72  37 2c 23 41 53 43 22 61  |ov     r7,#ASC"a|
00002ad0  22 20 20 20 20 20 20 20  20 3b 20 61 0a 20 20 20  |"        ; a.   |
00002ae0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 73  |               s|
00002af0  74 72 62 20 20 20 20 72  37 2c 5b 72 36 5d 2c 23  |trb    r7,[r6],#|
00002b00  31 20 20 20 20 20 20 20  20 3b 20 53 74 6f 72 65  |1        ; Store|
00002b10  20 69 74 0a 20 20 20 20  20 20 20 20 20 20 20 20  | it.            |
00002b20  20 20 20 20 20 20 6d 6f  76 20 20 20 20 20 72 37  |      mov     r7|
00002b30  2c 23 41 53 43 22 64 22  20 20 20 20 20 20 20 20  |,#ASC"d"        |
00002b40  3b 20 64 0a 20 20 20 20  20 20 20 20 20 20 20 20  |; d.            |
00002b50  20 20 20 20 20 20 73 74  72 62 20 20 20 20 72 37  |      strb    r7|
00002b60  2c 5b 72 36 5d 2c 23 31  20 20 20 20 20 20 20 20  |,[r6],#1        |
00002b70  3b 20 53 74 6f 72 65 20  69 74 0a 20 20 20 20 20  |; Store it.     |
00002b80  20 20 20 20 20 20 20 20  20 20 20 20 20 62 20 20  |             b  |
00002b90  20 20 20 20 20 64 6f 5f  76 61 72 5f 62 69 74 20  |     do_var_bit |
00002ba0  20 20 20 20 20 20 20 3b  20 43 72 65 61 74 65 20  |       ; Create |
00002bb0  74 68 65 20 76 61 72 69  61 62 6c 65 0a 0a 6e 75  |the variable..nu|
00002bc0  6d 5f 66 66 66 20 20 20  20 20 20 20 20 20 20 20  |m_fff           |
00002bd0  64 63 64 20 20 20 20 20  26 66 66 66 20 20 20 20  |dcd     &fff    |
00002be0  20 20 20 20 20 20 20 20  20 20 3b 20 41 20 63 6f  |          ; A co|
00002bf0  6e 73 74 61 6e 74 0a 2e  62 75 66 66 65 72 20 20  |nstant..buffer  |
00002c00  20 20 20 20 20 20 20 20  20 64 63 64 20 20 20 20  |         dcd    |
00002c10  20 30 3a 64 63 64 20 20  20 20 20 30 20 20 20 20  | 0:dcd     0    |
00002c20  20 20 20 3b 20 53 70 61  63 65 20 66 6f 72 20 63  |   ; Space for c|
00002c30  6f 6e 76 65 72 73 69 6f  6e 0a 72 75 6e 5f 76 61  |onversion.run_va|
00002c40  72 20 20 20 20 20 20 20  20 20 20 20 64 63 62 20  |r           dcb |
00002c50  20 20 20 20 22 53 65 74  20 22 0a 66 69 72 73 74  |    "Set ".first|
00002c60  5f 62 69 74 20 20 20 20  20 20 20 20 20 64 63 62  |_bit         dcb|
00002c70  20 20 20 20 20 22 20 52  75 6e 22 0a 73 65 63 6f  |     " Run".seco|
00002c80  6e 64 5f 62 69 74 20 20  20 20 20 20 20 20 64 63  |nd_bit        dc|
00002c90  62 20 20 20 20 20 22 46  69 6c 65 5f 22 0a 72 75  |b     "File_".ru|
00002ca0  6e 5f 74 79 70 65 20 20  20 20 20 20 20 20 20 20  |n_type          |
00002cb0  64 63 62 20 20 20 20 20  30 3a 64 63 62 20 20 20  |dcb     0:dcb   |
00002cc0  20 20 30 3a 64 63 62 20  20 20 20 20 30 20 20 20  |  0:dcb     0   |
00002cd0  20 20 20 20 20 20 20 3b  20 56 61 72 69 61 62 6c  |       ; Variabl|
00002ce0  65 20 6e 61 6d 65 0a 20  20 20 20 20 20 20 20 20  |e name.         |
00002cf0  20 20 20 20 20 20 20 20  20 64 63 62 20 20 20 20  |         dcb    |
00002d00  20 22 24 44 69 72 20 22  0a 72 75 6e 5f 76 61 6c  | "$Dir ".run_val|
00002d10  20 20 20 20 20 20 20 20  20 20 20 65 71 75 73 20  |           equs |
00002d20  20 20 20 53 54 52 49 4e  47 24 28 31 30 30 2c 43  |   STRING$(100,C|
00002d30  48 52 24 30 29                                    |HR$0)|
00002d35