home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1996-11-17 | 3.2 KB | 100 lines |
- > AddPathSrc
- fnm$="AddToPath"
- ;bl$=
- 0:cr$=
- 13:lfcr$=
- 10+cr$:tab$=
- 9:esc$=
- 27:hspc$=
- 1codesize=&1000:
- org codesize:L%=org+codesize
- A%=%1100
- %1110
- %0010
- ?P%=0:O%=org :
- So that addresses are offsets within module
- [OPT A%
- J; /E R0->command, R1->command tail, R12->1024 bytes workspace, R13 SP,
- ; R14 link,
- mode
- O MOV R11,#0 ; Load a handy zero into spare reg
- MOV R7,R1
- MOV R5,R1
- #.findarg2lp LDRB R9,[r5,#1]!
- CMP R9,#32
- " BGT findarg2lp
- STREQB R11,[r5]
- .findarg2lp2
- # LDREQB R9,[r5,#1]!
- CMPEQ R9,#32
- # BEQ findarg2lp2
- ( ADRLT R0,versionstring
- $ SWILT "XOS_Write0"
- = MOVLT PC,R14 ; No second arg!
- G MOV R4,#0 ; Don't expand into string
- D.itsanumber MOV R0,R7 ; Start of command line
- MOV R1,R12
- MOV R2,#1024
- MOV R3,#0
- !( SWI "XOS_ReadVarVal"
- "$ BVS needtocreate
- #N TEQ R4,#1 ; If some hacker has set xxx$Path
- $L
- Q R4,#3 ; to a number, convert to a string
- %" BEQ itsanumber
- &? STRB R11,[R1,R2] ; Terminate string
- '/ ; R1->xxx$path, R5->path to add
- MOV R3,R5
- MOV R5,R1
- .complp MOV R0,R5
- +".despacelp LDRB R2,[R1],#1
- ,; TEQ R2,#32 ; Strip spaces
- -" STRNEB R2,[R5],#1
- TEQ R2,#0
- / TEQNE R2,#
- 0! BNE despacelp
- 1$ STRB R11,[R5,#-1]
- MOV R4,R3
- 3@.strcmplp LDRB R9,[R4],#1 ; Compare r0 and r4
- 4" LDRB R6,[R0],#1
- 5
- RS R10,R6,R9
- 6N
- Q PC,R14 ; Component already in path variable
- TEQ R6,R9
- 8 BEQ strcmplp
- 9L
- S R9,R2,#
- "," ; Neat tweak to save an instruction
- :E STREQB R2,[R5,#-1] ; EQ <=> r9=0 <=> r2=','
- ;< BEQ complp ; NE <=> r9=','
- <B STRB R9,[R5,#-1] ; Need to add to path
- =".copylp LDRB R9,[R3],#1
- CMP R9,#32
- ?" STRGTB R9,[R5],#1
- BGT copylp
- MOV R1,R12
- B .create STRB R11,[R5]
- MOV R0,R7
- D SUB R2,R5,R1
- MOV R3,#0
- F4 MOV R4,#2 ; Macro
- G' SWI "XOS_SetVarVal"
- MOV PC,R14
- .needtocreate
- K9 MOV R1,R5 ; Skip past
- L#.countlp LDRB R9,[R5,#1]!
- CMP R9,#32
- BGT countlp
- B create
- .versionstring
- R& EQUS "v1.00"+lfcr$+bl$
- S ALIGN
- "Size = ";P%" bytes"
- "OS_File",&0A,fnm$,&FFC,,org,O%
- align
- next line allows shuffling of strings to reduce wastage
- 2)=0
- 3" byte(s) wasted by FNalign"
- 3:[OPTA%:EQUB0:]:
-