[comp.sys.acorn] More usefulness in 52 bytes!

nbvs@cl.cam.ac.uk (Nicko van Someren) (02/28/91)

Here is yet another useful utility, infact about six utilities but the source
to them is very similar.  This code is for IfFile, which executes the command
tail if the first parameter if a file that exists.  You can change this to test
for directories or the absence of the named object.

(As before, assemble and save as a utility (&FFC)).

 MOV   R8,R1
.loop
 LDRB  R0,[R8],#1
 CMP   R0,#32
 BHI   loop
 MOV   R0,#0
 STRB  R0,[R8,#-1]
 MOV   R0,#5
 SWI   "XOS_File"
 MOVVS PC,R14
.fix
 CMP   R0,#1        ; 0 for IfNoFile, 2 for IfDir
 MOV   R0,R8
 SWIEQ "XOS_CLI"    ; NE for not
 MOV   PC,R14

Share and enjoy...

Nicko
+-----------------------------------------------------------------------------+
| Nicko van Someren, nbvs@cl.cam.ac.uk, (44) 223 358707 or (44) 860 498903    |
|       "Go and buy an Aleph One ARM3 card and stop whining!!!"               |
+-----------------------------------------------------------------------------+