ô >AddTPSrc  2ô AddToPath - adds a string to a path variable ô (c) DoggySoft Ltd., 1995  î … ñ ö$;" at line ";ž:à wk=12:sp=13:lk=14:pc=15  code_length% = 4*1024 base% = 0  Þ code% code_length%   wk% = 0 wk_args = ¤bk(wk%,256) wk_filename = ¤bk(wk%,256) wk_oldvalue = ¤bk(wk%,1024) wk_newvalue = ¤bk(wk%,1536)  ã p=%1100 ¸ %1110 ˆ %0010  P%=base%  O%=code%  L%=code%+code_length%  [OPT p   .start  STMFD (sp)!,{wk,lk} 6 MOV R4,R1 ; R4-> arguments  MOV R0,#6  MOV R3,#wk% € &FF  „R R3,R3,#wk% € ¬ &F : SWI "XOS_Module" ; allocate workspace ! LDMVSFD (sp)!,{wk,pc} " MOV wk,R2 #; .a ; skip leading spaces $ LDRB R0,[R4] % CMP R0,#&20 & ADDEQ R4,R4,#1 ' BEQ a ( BCC badsyntax ); MOV R11,R4 ; R11-> variable name *: .a ; skip variable name + LDRB R0,[R4] , CMP R0,#&20 - ADDHI R4,R4,#1 . BHI a / BCC badsyntax 0; .a ; skip leading spaces 1 LDRB R0,[R4] 2 CMP R0,#&20 3 ADDEQ R4,R4,#1 4 BEQ a 5 BCC badsyntax 66 MOV R10,R4 ; R10-> filename 75 .a ; skip filename 8 LDRB R0,[R4] 9 CMP R0,#&20 : ADDHI R4,R4,#1 ; BHI a << .a ; skip trailing spaces = LDRB R0,[R4] > CMP R0,#&20 ? ADDEQ R4,R4,#1 @ BEQ a AP BCS badsyntax ; make sure there's nothing after filename B MOV R0,#37 C MOV R1,R10 D ADRW R2,wk_filename E MOV R3,#0 F MOV R4,#0 G MOV R5,#1024 HJ SWI "XOS_FSControl" ; canonicalise filename, if possible I MOVVC R10,R2 J MOV R0,R11 K ADRW R1,wk_oldvalue L MOV R2,#1024 M MOV R3,#0 N MOV R4,#0 O SWI "XOS_ReadVarVal" PJ MOVVS R2,#0 ; variable doesn't exist, pretend we QF MOVVS R4,#0 ; found an empty string variable R MOV R0,#0 S: STRB R0,[R1,R2] ; terminate variable T ADRW R2,wk_newvalue U MOV R3,R10 VD .a ; copy new value as first item W LDRB R0,[R3],#1 X CMP R0,#&20 Y STRCSB R0,[R2],#1 Z BCS a [B .loop1 ; loop to copy path segments \ LDRB R0,[R1] ] CMP R0,#&20 ^ BCC notfound _ TEQNE R0,#—"," ` ADDEQ R1,R1,#1 a BEQ loop1 b MOV R0,R10 cF BL stricmp ; check if this value is our one d BEQ found e MOV R0,#—"," f STRB R0,[R2],#1 gA .a ; copy variable into output h LDRB R0,[R1] i TEQ R0,#—"," j BEQ loop1 k CMP R0,#&20 l BLS loop1 m ADD R1,R1,#1 n STRB R0,[R2],#1 o B a p .notfound q MOV R0,#0 r STRB R0,[R2],#1 s MOV R0,R11 t ADRW R1,wk_newvalue u SUB R2,R2,R1 v MOV R3,#0 w5 SWI "XOS_SetVarVal" ; set new value x BVS error y .found z .done { MOV R0,#7 | MOV R2,wk } SWI "XOS_Module" ~ LDMVCFD (sp)!,{wk,pc}^  LDMFD (sp)!,{wk,pc} € .badsyntax " ADR R0,error_badsyntax ‚ .error ƒ MOV R4,R0 „ MOV R0,#7 … MOV R2,wk † SWI "XOS_Module" ‡ MOV R0,R4 ˆ CMP pc,#&80000000 ‰ LDMFD (sp)!,{wk,pc} Š ‹B .stricmp ; R0-> string A, R1-> string B, exit Z set if equal Œ STMFD (sp)!,{R0-R3,lk}  .a Ž LDRB R2,[R0],#1  LDRB R3,[R1],#1  TEQ R2,#—"," ‘ ìQ R2,#0 ’ TEQ R3,#—"," “ ìQ R3,#0 ” CMP R2,#&21 • CMPCS R3,#&21 – BCC stricmp_t — CMP R2,#—"A" ˜ RSBCSS R14,R2,#—"Z" ™ ADDCS R2,R2,#32 š CMP R3,#—"A" › RSBCSS R14,R3,#—"Z" œ ADDCS R3,R3,#32  TEQ R2,R3 ž BEQ a Ÿ .stricmp_not   TEQ pc,#0 ¡ LDMFD (sp)!,{R0-R3,pc} ¢ .stricmp_t £ CMP R2,#&21 ¤ CMPCC R3,#&21 ¥ BCS stricmp_not ¦ TEQ lk,lk § LDMFD (sp)!,{R0-R3,pc} ¨ © .error_badsyntax ª EQUD 220 «: EQUZ "Syntax: AddToPath " ¬ ­ .trailer ® EQUB 10 ¯2 EQUS "AddToPath © DoggySoft Ltd., 1995" ° ± ] ²í p ³ ´DÈ™ "OS_File",10,".Misc.AddToPath",&FFC,,code%,O% µà ¶ ·Ý ¤bk(ø p%, s%) ¸ê q% ¹ q%=p% º p%+=(s%+3)€¬3 »=q% ÿ