Home » Archimedes archive » Zipped Apps » 1st Word Plus » WP/programs/hoare/DirPrmtSrc

WP/programs/hoare/DirPrmtSrc

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 » Zipped Apps » 1st Word Plus
Filename: WP/programs/hoare/DirPrmtSrc
Read OK:
File size: 05EF bytes
Load address: 0000
Exec address: 0000
File contents
   10REM >  $.DirPrmtSrc
   20REM Author Steve Hoare (based on PRM pages 349/350)
   30REM January 1989
   40REM Creates current directory CLI prompt utility
   50DIM Space 150
   60FOR Pass=0 TO 2 STEP 2
   70P%=Space
   80[OPT Pass
   90.CreateVar  ADR R0,VarName
  100            ADR R1,Code
  110            MOV R2,#(VarName-Code)
  120            MOV R3,#0
  130            MOV R4,#16              ;Special code calling type
  140            SWI "OS_SetVarVal"      ;Create variable, reporting errors
  150            ADR R0,Command
  160            SWI "OS_CLI"            ;Set Cli$Prompt
  170.Code       MOV PC,R14              ;Variable never written so just return
  180.ReadCode   STMFD R13!,{R3,R4,R14}  ;Stack Rs which may be changed by SWI
  190            MOV R0,#6               ;Set up to read directory name
  200            ADR R2,NameBuffer       ;Point to buffer created with variable
  210            SWI "XOS_GBPB"          ;Read current directory
  220            ADD R0,R2,#2            ;Point R0 to value of variable
  230            LDRB R2,[R2,#1]         ;Directory name length to R2
  240            MOVVS R2,#0             ;If error occurred variable length =0
  250            LDMFD R13!,{R3,R4,PC}^  ;Return, restoring regs & flags
  260.NameBuffer EQUB 0
  270            EQUB 10
  280            EQUS "NameString"
  290            EQUB 0
  300            ALIGN
  310.VarName    EQUS "Curr$Dir "
  320.Command    EQUS "SETMACRO Cli$Prompt <Curr$Dir><13><10>*"
  330            EQUB 0
  340]
  350NEXT
  360OSCLI("SAVE DirPrompt "+STR$~CreateVar+" "+STR$~P%)
  370*SETTYPE DirPrompt FFC

� >  $.DirPrmtSrc
5� Author Steve Hoare (based on PRM pages 349/350)
� January 1989
(2� Creates current directory CLI prompt utility
2� Space 150
<� Pass=0 � 2 � 2
FP%=Space
P
[OPT Pass
Z.CreateVar  ADR R0,VarName
d            ADR R1,Code
n&            MOV R2,#(VarName-Code)
x            MOV R3,#0
�B            MOV R4,#16              ;Special code calling type
�J            SWI "OS_SetVarVal"      ;Create variable, reporting errors
�            ADR R0,Command
�7            SWI "OS_CLI"            ;Set Cli$Prompt
�N.Code       MOV PC,R14              ;Variable never written so just return
�M.ReadCode   STMFD R13!,{R3,R4,R14}  ;Stack Rs which may be changed by SWI
�F            MOV R0,#6               ;Set up to read directory name
�N            ADR R2,NameBuffer       ;Point to buffer created with variable
�?            SWI "XOS_GBPB"          ;Read current directory
�F            ADD R0,R2,#2            ;Point R0 to value of variable
�D            LDRB R2,[R2,#1]         ;Directory name length to R2
�M            MOVVS R2,#0             ;If error occurred variable length =0
�G            LDMFD R13!,{R3,R4,PC}^  ;Return, restoring regs & flags
.NameBuffer EQUB 0
            EQUB 10
!            EQUS "NameString"
"            EQUB 0
,            ALIGN
6 .VarName    EQUS "Curr$Dir "
@>.Command    EQUS "SETMACRO Cli$Prompt <Curr$Dir><13><10>*"
J            EQUB 0
T]
^�
h-�("SAVE DirPrompt "+�~CreateVar+" "+�~P%)
r*SETTYPE DirPrompt FFC
�
00000000  0d 00 0a 15 f4 20 3e 20  20 24 2e 44 69 72 50 72  |..... >  $.DirPr|
00000010  6d 74 53 72 63 0d 00 14  35 f4 20 41 75 74 68 6f  |mtSrc...5. Autho|
00000020  72 20 53 74 65 76 65 20  48 6f 61 72 65 20 28 62  |r Steve Hoare (b|
00000030  61 73 65 64 20 6f 6e 20  50 52 4d 20 70 61 67 65  |ased on PRM page|
00000040  73 20 33 34 39 2f 33 35  30 29 0d 00 1e 12 f4 20  |s 349/350)..... |
00000050  4a 61 6e 75 61 72 79 20  31 39 38 39 0d 00 28 32  |January 1989..(2|
00000060  f4 20 43 72 65 61 74 65  73 20 63 75 72 72 65 6e  |. Creates curren|
00000070  74 20 64 69 72 65 63 74  6f 72 79 20 43 4c 49 20  |t directory CLI |
00000080  70 72 6f 6d 70 74 20 75  74 69 6c 69 74 79 0d 00  |prompt utility..|
00000090  32 0f de 20 53 70 61 63  65 20 31 35 30 0d 00 3c  |2.. Space 150..<|
000000a0  14 e3 20 50 61 73 73 3d  30 20 b8 20 32 20 88 20  |.. Pass=0 . 2 . |
000000b0  32 0d 00 46 0c 50 25 3d  53 70 61 63 65 0d 00 50  |2..F.P%=Space..P|
000000c0  0d 5b 4f 50 54 20 50 61  73 73 0d 00 5a 1e 2e 43  |.[OPT Pass..Z..C|
000000d0  72 65 61 74 65 56 61 72  20 20 41 44 52 20 52 30  |reateVar  ADR R0|
000000e0  2c 56 61 72 4e 61 6d 65  0d 00 64 1b 20 20 20 20  |,VarName..d.    |
000000f0  20 20 20 20 20 20 20 20  41 44 52 20 52 31 2c 43  |        ADR R1,C|
00000100  6f 64 65 0d 00 6e 26 20  20 20 20 20 20 20 20 20  |ode..n&         |
00000110  20 20 20 4d 4f 56 20 52  32 2c 23 28 56 61 72 4e  |   MOV R2,#(VarN|
00000120  61 6d 65 2d 43 6f 64 65  29 0d 00 78 19 20 20 20  |ame-Code)..x.   |
00000130  20 20 20 20 20 20 20 20  20 4d 4f 56 20 52 33 2c  |         MOV R3,|
00000140  23 30 0d 00 82 42 20 20  20 20 20 20 20 20 20 20  |#0...B          |
00000150  20 20 4d 4f 56 20 52 34  2c 23 31 36 20 20 20 20  |  MOV R4,#16    |
00000160  20 20 20 20 20 20 20 20  20 20 3b 53 70 65 63 69  |          ;Speci|
00000170  61 6c 20 63 6f 64 65 20  63 61 6c 6c 69 6e 67 20  |al code calling |
00000180  74 79 70 65 0d 00 8c 4a  20 20 20 20 20 20 20 20  |type...J        |
00000190  20 20 20 20 53 57 49 20  22 4f 53 5f 53 65 74 56  |    SWI "OS_SetV|
000001a0  61 72 56 61 6c 22 20 20  20 20 20 20 3b 43 72 65  |arVal"      ;Cre|
000001b0  61 74 65 20 76 61 72 69  61 62 6c 65 2c 20 72 65  |ate variable, re|
000001c0  70 6f 72 74 69 6e 67 20  65 72 72 6f 72 73 0d 00  |porting errors..|
000001d0  96 1e 20 20 20 20 20 20  20 20 20 20 20 20 41 44  |..            AD|
000001e0  52 20 52 30 2c 43 6f 6d  6d 61 6e 64 0d 00 a0 37  |R R0,Command...7|
000001f0  20 20 20 20 20 20 20 20  20 20 20 20 53 57 49 20  |            SWI |
00000200  22 4f 53 5f 43 4c 49 22  20 20 20 20 20 20 20 20  |"OS_CLI"        |
00000210  20 20 20 20 3b 53 65 74  20 43 6c 69 24 50 72 6f  |    ;Set Cli$Pro|
00000220  6d 70 74 0d 00 aa 4e 2e  43 6f 64 65 20 20 20 20  |mpt...N.Code    |
00000230  20 20 20 4d 4f 56 20 50  43 2c 52 31 34 20 20 20  |   MOV PC,R14   |
00000240  20 20 20 20 20 20 20 20  20 20 20 3b 56 61 72 69  |           ;Vari|
00000250  61 62 6c 65 20 6e 65 76  65 72 20 77 72 69 74 74  |able never writt|
00000260  65 6e 20 73 6f 20 6a 75  73 74 20 72 65 74 75 72  |en so just retur|
00000270  6e 0d 00 b4 4d 2e 52 65  61 64 43 6f 64 65 20 20  |n...M.ReadCode  |
00000280  20 53 54 4d 46 44 20 52  31 33 21 2c 7b 52 33 2c  | STMFD R13!,{R3,|
00000290  52 34 2c 52 31 34 7d 20  20 3b 53 74 61 63 6b 20  |R4,R14}  ;Stack |
000002a0  52 73 20 77 68 69 63 68  20 6d 61 79 20 62 65 20  |Rs which may be |
000002b0  63 68 61 6e 67 65 64 20  62 79 20 53 57 49 0d 00  |changed by SWI..|
000002c0  be 46 20 20 20 20 20 20  20 20 20 20 20 20 4d 4f  |.F            MO|
000002d0  56 20 52 30 2c 23 36 20  20 20 20 20 20 20 20 20  |V R0,#6         |
000002e0  20 20 20 20 20 20 3b 53  65 74 20 75 70 20 74 6f  |      ;Set up to|
000002f0  20 72 65 61 64 20 64 69  72 65 63 74 6f 72 79 20  | read directory |
00000300  6e 61 6d 65 0d 00 c8 4e  20 20 20 20 20 20 20 20  |name...N        |
00000310  20 20 20 20 41 44 52 20  52 32 2c 4e 61 6d 65 42  |    ADR R2,NameB|
00000320  75 66 66 65 72 20 20 20  20 20 20 20 3b 50 6f 69  |uffer       ;Poi|
00000330  6e 74 20 74 6f 20 62 75  66 66 65 72 20 63 72 65  |nt to buffer cre|
00000340  61 74 65 64 20 77 69 74  68 20 76 61 72 69 61 62  |ated with variab|
00000350  6c 65 0d 00 d2 3f 20 20  20 20 20 20 20 20 20 20  |le...?          |
00000360  20 20 53 57 49 20 22 58  4f 53 5f 47 42 50 42 22  |  SWI "XOS_GBPB"|
00000370  20 20 20 20 20 20 20 20  20 20 3b 52 65 61 64 20  |          ;Read |
00000380  63 75 72 72 65 6e 74 20  64 69 72 65 63 74 6f 72  |current director|
00000390  79 0d 00 dc 46 20 20 20  20 20 20 20 20 20 20 20  |y...F           |
000003a0  20 41 44 44 20 52 30 2c  52 32 2c 23 32 20 20 20  | ADD R0,R2,#2   |
000003b0  20 20 20 20 20 20 20 20  20 3b 50 6f 69 6e 74 20  |         ;Point |
000003c0  52 30 20 74 6f 20 76 61  6c 75 65 20 6f 66 20 76  |R0 to value of v|
000003d0  61 72 69 61 62 6c 65 0d  00 e6 44 20 20 20 20 20  |ariable...D     |
000003e0  20 20 20 20 20 20 20 4c  44 52 42 20 52 32 2c 5b  |       LDRB R2,[|
000003f0  52 32 2c 23 31 5d 20 20  20 20 20 20 20 20 20 3b  |R2,#1]         ;|
00000400  44 69 72 65 63 74 6f 72  79 20 6e 61 6d 65 20 6c  |Directory name l|
00000410  65 6e 67 74 68 20 74 6f  20 52 32 0d 00 f0 4d 20  |ength to R2...M |
00000420  20 20 20 20 20 20 20 20  20 20 20 4d 4f 56 56 53  |           MOVVS|
00000430  20 52 32 2c 23 30 20 20  20 20 20 20 20 20 20 20  | R2,#0          |
00000440  20 20 20 3b 49 66 20 65  72 72 6f 72 20 6f 63 63  |   ;If error occ|
00000450  75 72 72 65 64 20 76 61  72 69 61 62 6c 65 20 6c  |urred variable l|
00000460  65 6e 67 74 68 20 3d 30  0d 00 fa 47 20 20 20 20  |ength =0...G    |
00000470  20 20 20 20 20 20 20 20  4c 44 4d 46 44 20 52 31  |        LDMFD R1|
00000480  33 21 2c 7b 52 33 2c 52  34 2c 50 43 7d 5e 20 20  |3!,{R3,R4,PC}^  |
00000490  3b 52 65 74 75 72 6e 2c  20 72 65 73 74 6f 72 69  |;Return, restori|
000004a0  6e 67 20 72 65 67 73 20  26 20 66 6c 61 67 73 0d  |ng regs & flags.|
000004b0  01 04 16 2e 4e 61 6d 65  42 75 66 66 65 72 20 45  |....NameBuffer E|
000004c0  51 55 42 20 30 0d 01 0e  17 20 20 20 20 20 20 20  |QUB 0....       |
000004d0  20 20 20 20 20 45 51 55  42 20 31 30 0d 01 18 21  |     EQUB 10...!|
000004e0  20 20 20 20 20 20 20 20  20 20 20 20 45 51 55 53  |            EQUS|
000004f0  20 22 4e 61 6d 65 53 74  72 69 6e 67 22 0d 01 22  | "NameString".."|
00000500  16 20 20 20 20 20 20 20  20 20 20 20 20 45 51 55  |.            EQU|
00000510  42 20 30 0d 01 2c 15 20  20 20 20 20 20 20 20 20  |B 0..,.         |
00000520  20 20 20 41 4c 49 47 4e  0d 01 36 20 2e 56 61 72  |   ALIGN..6 .Var|
00000530  4e 61 6d 65 20 20 20 20  45 51 55 53 20 22 43 75  |Name    EQUS "Cu|
00000540  72 72 24 44 69 72 20 22  0d 01 40 3e 2e 43 6f 6d  |rr$Dir "..@>.Com|
00000550  6d 61 6e 64 20 20 20 20  45 51 55 53 20 22 53 45  |mand    EQUS "SE|
00000560  54 4d 41 43 52 4f 20 43  6c 69 24 50 72 6f 6d 70  |TMACRO Cli$Promp|
00000570  74 20 3c 43 75 72 72 24  44 69 72 3e 3c 31 33 3e  |t <Curr$Dir><13>|
00000580  3c 31 30 3e 2a 22 0d 01  4a 16 20 20 20 20 20 20  |<10>*"..J.      |
00000590  20 20 20 20 20 20 45 51  55 42 20 30 0d 01 54 05  |      EQUB 0..T.|
000005a0  5d 0d 01 5e 05 ed 0d 01  68 2d ff 28 22 53 41 56  |]..^....h-.("SAV|
000005b0  45 20 44 69 72 50 72 6f  6d 70 74 20 22 2b c3 7e  |E DirPrompt "+.~|
000005c0  43 72 65 61 74 65 56 61  72 2b 22 20 22 2b c3 7e  |CreateVar+" "+.~|
000005d0  50 25 29 0d 01 72 1a 2a  53 45 54 54 59 50 45 20  |P%)..r.*SETTYPE |
000005e0  44 69 72 50 72 6f 6d 70  74 20 46 46 43 0d ff     |DirPrompt FFC..|
000005ef