home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
filemanager
/
imageprot_1
/
Extras
/
Source093
/
bin,FFF
Wrap
Text File
|
1995-01-27
|
7KB
|
254 lines
\ >Source94
\
\ SAsm source file for ImageProtect
\ history:
\ 1.00 • first working version (at last!)
\ (Source094)
\ 1.01 • now I can’t get rid of my archives!
\ --> added check on CMOS to see if ‘force’ flag is set; if so, allow deletion
#vers$ ="1.01" \ version number
\ Service calls
#Service_Reset =&27
\ Software vectors
#FileV =&08 \ OS_File vector
\ *************
\ MODULE HEADER
\ *************
dd 0 \ start code
dd init \ initialise
dd final \ finalise
dd service \ service calls
dd title \ module title string
dd help \ module help string
dd 0 \ command/keyword table
dd 0 \ SWI chunk base
dd 0 \ SWI handler code
dd 0 \ SWI decoding table
dd 0 \ SWI decoding code
\ ******************
\ TITLE/HELP STRINGS (PRM 1-212)
\ ******************
\
\ NB. Longest ROM module title is 21 chars
\ Longest ROM module name is 15 chars
.title db "ImageProtect",0
.help db "Image Protector",9,""+vers$+module$,0
@align
\ **********
\ INITIALISE (SVC mode) (PRM 1-207)
\ **********
\
\ Entry: R10 ................. environment string (command tail) pointer
\ R11 ................. I/O base / instantiation number
\ R12 ................. private word pointer
\ R13 ................. supervisor stack pointer
\ R14 ................. return address
\
\ Exit:
\ R0 .................. error pointer (else corrupted)
\ R1-R6,R12,R14,flags . corrupted
\ R7-R11,R13 .......... preserved
.init stmfd (sp)!,{lr} \ save r14_svc
mov r0,#FileV
adr r1,filev_handler
mov r2,#0
swi "XOS_Claim" \ PRM 1-66
ldmfd (sp)!,{pc}
\ ********
\ FINALISE (SVC mode) (PRM 1-209)
\ ********
\
\ Entry: R10 ........ fatality (0=non-fatal, 1=fatal)
\ R11 ........ instantiation number
\ R12 ........ private word pointer
\ R13 ........ supervisor stack pointer
\ R14 ........ return address
\
\ Exit: R0 .................. error pointer (else corrupted)
\ R1-R6,R12,R14,flags . corrupted
\ R7-R11,R13 .......... preserved
.final stmfd (sp)!,{lr} \ save r14_svc
mov r0,#FileV
adr r1,filev_handler
mov r2,#0
swi "XOS_Release" \ PRM 1-68
ldmfd (sp)!,{pc}
\ ********************
\ SERVICE CALL HANDLER (SVC/IRQ mode) (PRM 1-210; see 1-251)
\ ********************
\
\ Entry: R1 ................... service number
\ R12 .................. private word pointer
\ R13 .................. supervisor stack pointer
\ R14 .................. return address
\
\ Exit: >> If claimed <<
\ R1 ................... 0
\ R0,R2-R8 ............. results (else preserved)
\ R9-R11,R13,R14,flags . preserved
\ R12 .................. corrupted
\ >> Otherwise <<
\ R0-R11,R13,R14,flags . preserved
\ R12 .................. corrupted
.service teq r1,#Service_Reset
movnes pc,lr \ reject unrecognised calls asap
\ relink to vectors after reset (see PRM 1-80)
stmfd (sp)!,{r0-r2,lr}
mov r0,#FileV
adr r1,filev_handler
mov r2,#0
swi "XOS_Claim" \ PRM 1-66
ldmfd (sp)!,{r0-r2,pc}
\ ***************
\ VECTOR HANDLERS (SVC mode) (PRM 1-77)
\ ***************
\ FileV - OS_File 6 (PRM 2-37)
.filev_handler teq r0,#6 \ is it delete?
movnes pc,lr \ if not, return to next claimant
bic lr,lr,#v \ clear v flag (see PRM 1-32)
stmfd (sp)!,{r1-r6,lr} \ save registers on stack
mov r12,r1 \ save r1 in r12
mov r0,#161 \ read cmos ram
mov r1,#198 \ location 198
swi "XOS_Byte" \ PRM 1-363
tst r2,#b4
movne r0,#6 \ if force=1 (on) then restore registers
ldmnefd (sp)!,{r1-r6,pc}^ \ (incl. r0) and return to next claimant
mov r1,r12 \ else, restore r1 and continue
\ to allow the returning of errors, r0 IS NOT saved on the stack; this
\ may safely be reset manually since it always contains the number 6
mov r0,#23 \ read catalogue info
swi "XOS_File" \ PRM 2-43
ldmvsfd (sp)!,{r1-r6,lr,pc} \ if error, return to caller
teq r6,#&1000 \ is it a directory?
teqne r6,#&2000 \ else, is it an app. directory?
teqeq r0,#3 \ if it's either, is it an image file?
movne r0,#6 \ if not, restore registers (including
ldmnefd (sp)!,{r1-r6,pc}^ \ r0) and return to next claimant
\ find out if there are any files inside image file
\ • find length of image filename
mov r2,#0 \ init counter
.00 ldrb r0,[r1,r2] \ get char
cmp r0,#32
addge r2,r2,#1 \ if not control character, increment
bge 00 \ counter and loop
\ • claim temporary workspace for image path
mov r0,#6 \ claim heap block
add r3,r2,#4 \ length is string_length+4
swi "XOS_Module" \ PRM 1-233 (r1 preserved)
ldmvsfd (sp)!,{r1-r6,lr,pc} \ if error, return to caller
mov r6,r2 \ save workspace address in r6
\ • copy image filename into workspace
mov r2,#0 \ init counter
.00 ldrb r0,[r1,r2] \ get char
cmp r0,#32
strgeb r0,[r6,r2] \ if not control char, put char
addge r2,r2,#1 \ increment counter
bge 00 \ and loop
\ • write ‘.*’ suffix and null terminator to string
add r2,r6,r2
mov r0,#ASC"."
strb r0,[r2]
mov r0,#ASC"*"
strb r0,[r2,#1]
mov r0,#0
strb r0,[r2,#2]
\ • read catalogue information for <image_pathname>.*
mov r0,#17 \ no path
mov r1,r6 \ wildcarded path in workspace
swi "XOS_File" \ PRM 2-35 (r6 preserved)
bvs unreadable
mov r1,r0 \ save r0 (object type) in r1
\ • give back my workspace whether or not there's an error
mov r0,#7 \ free workspace
mov r2,r6 \ workspace ptr
swi "XOS_Module" \ PRM 1-234 (r1 preserved)
ldmvsfd (sp)!,{r1-r6,lr,pc} \ if error, return to caller
\ now what do I do..?
teq r1,#0 \ was anything found?
moveq r0,#6 \ if not, restore registers (including
ldmeqfd (sp)!,{r1-r6,pc}^ \ r0) and return to next claimant
\ if file is an image file which contains further files... complain!
ldmfd (sp)!,{r1-r6,r12,lr} \ load registers from stack (where r12 is
\ my lr, and lr is pc of caller)
orr lr,lr,#v \ set v flag
adr r0,nodel \ setup error pointer
movs pc,lr \ return to caller with my error
\ if error occurred when trying to read <image_pathname>.*
.unreadable mov r1,r0 \ save error pointer in r1
mov r0,#7 \ free workspace
mov r2,r6 \ workspace ptr
swi "XOS_Module" \ PRM 1-234 (r1 preserved)
mov r0,r1 \ restore error pointer
ldmfd (sp)!,{r1-r6,r12,lr}
orr lr,lr,#v
movs pc,lr
.nodel dd 1
db "Image not empty",0
#end