>SourceCode   DiscAccess module source ( 2 Version 0.01 < F% Assembler programming example 7 P: Downloaded from: http://www.heyrick.co.uk/assembler/ Z: d $+" at "+(/10) : n: x code% 2048 :  pass% = 4 6 2 P%=0 O%=code% [ OPT pass% F EQUD 0 ; Start-up code G EQUD initialise ; Initialisation E EQUD finalise ; Finalisation M EQUD 0 ; Service call handler E EQUD module_title ; Module title D EQUD module_help ; Module help X EQUD help_table ; Help and command decoding table N EQUD 0 ; SWI chunk base number J EQUD 0 ; SWI handling code J EQUD 0 ; SWI decoding code J EQUD 0 ; SWI decoding code " , 6 .module_title @ EQUS "DiscAccess" J EQUB 0 T ALIGN ^ h r .module_help |\ EQUS "DiscAccess"+(9)+"0.01 (14 Oct 2000) [http://www.heyrick.co.uk/assembler/]"  EQUB 0  ALIGN    .help_table G EQUS "DiscAccess" ; Keyword string  EQUB 0  ALIGN \ EQUD 0 ; Pointer to code (there is no code!) ^ EQUD 0 ; Parameter information (no parameters) Q EQUD 0 ; Pointer to syntax string O EQUD discaccess_help ; Pointer to help string M EQUD 0 ; End of command table    .discaccess_help &O ; Only put a linefeed where one is required, else put a trailing space. 0Z ; RISC OS will wrap the text as appropriate to fit the screen dimensions in use... :] EQUS "DiscAccess is a simple little module that blinks your Scroll Lock key when " D) EQUS "files are accessed."+13 N` EQUS "It is designed to take the place of a dedicated HD indicator on machines that " X^ EQUS "don't have such a thing (ie, the A3000); so you probably won't need it on a " b! EQUS "RiscPC!"+13+13 l^ EQUS "DiscAccess was written by Richard Murray as a tutorial for the "+34+"Teach " vR EQUS "yourself ARM assembler"+34+", which is freely available at:"+13 C EQUS 160+160+"http://www.heyrick.co.uk/assembler/"+13 < EQUS 160+160+"(this is example seven!)"+13+13  EQUB 0  ALIGN 6 ; The hard spaces (160) force a small indent.    .initialise  STMFD R13!, {R14}  K \ Attach vector handler to the six vectors that deal with file ops. > MOV R0, #&8 ; FileV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_AddToVector"   > MOV R0, #&9 ; ArgsV *" ADR R1, vector_handler 4 MOV R2, #0 > SWI "OS_AddToVector" H R> MOV R0, #&A ; BGetV \" ADR R1, vector_handler f MOV R2, #0 p SWI "OS_AddToVector" z > MOV R0, #&B ; BPutV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_AddToVector"  > MOV R0, #&C ; GBPBV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_AddToVector"  > MOV R0, #&D ; FindV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_AddToVector"   LDMFD R13!, {PC} $ . 8 .finalise B STMFD R13!, {R14} L V> MOV R0, #&8 ; FileV `" ADR R1, vector_handler j MOV R2, #0 t SWI "OS_Release" ~ > MOV R0, #&9 ; ArgsV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_Release"  > MOV R0, #&A ; BGetV " ADR R1, vector_handler  MOV R2, #0  SWI "OS_Release"  > MOV R0, #&B ; BPutV " ADR R1, vector_handler  MOV R2, #0   SWI "OS_Release"  > MOV R0, #&C ; GBPBV (" ADR R1, vector_handler 2 MOV R2, #0 < SWI "OS_Release" F P> MOV R0, #&D ; FindV Z" ADR R1, vector_handler d MOV R2, #0 n SWI "OS_Release" x  LDMFD R13!, {PC}    .vector_handler % \ IMPORTANT! WE ARE IN SVC ! K STMFD R13!, {R0 - R2, R14} ; Preserve registers   \ Read \ MOV R0, #202 ; Update keyboard status, but using [ MOV R1, #0 ; mask 0 and mask 255, we can read E MOV R2, #255 ; the state... H SWI "OS_Byte" ; New value in R1   \ Switch on Scroll Lock U R R1, R1, #2 ; Bit 1 is Scroll Lock, set it.  " \ Write ,Y MOV R2, #0 ; mask is 0, so value is used. 6 SWI "OS_Byte" @ J \ Update keyboard LEDs T MOV R0, #118 ^ SWI "OS_Byte" h r7 \ Set up timed callback to switch LED off again |M MOV R0, #2 ; After 2 centiseconds # ADR R1, callback_handler  MOV R2, #0  SWI "OS_CallAfter"  J LDMFD R13!, {R0 - R2, R14} ; Restore registers I MOVS PC, R14 ; Pass this one on    .callback_handler C \ This isn't quite interrupt-level code, but getting close!  $ STMFD R13!, {R0 - R2, R14}   \ Unset the keyboard LED  \ Read  MOV R0, #202 & MOV R1, #0 0 MOV R2, #255 : SWI "OS_Byte" D N \ Switch off Scroll Lock X\ R1, R1, #253 ; 253 preserves every bit EXCEPT bit 2. b l \ Write v MOV R2, #0  SWI "OS_Byte"   \ Update LEDs  MOV R0, #118  SWI "OS_Byte"   \ Remove callback $ ADR R0, callback_handler  MOV R1, #0 & SWI "OS_RemoveTickerEvent"   \ Return # LDMFD R13!, {R0 - R2, PC}     .stuff_at_the_end   EQUB 10 * EQUB 10 49 EQUS "DiscAccess module 2000 Richard Murray" > EQUB 10 HB EQUS "http://www.heyrick.co.uk/assembler/ (example 7)" R EQUB 10 \] f pass% p: z9("Save .DiscAccess "+~code%+" +"+~P%) -("SetType .DiscAccess FFA") :