home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 4
/
AUCD4.iso
/
acornuser
/
1998
/
nov1998
/
regulars
/
StarInfo
/
Fletcher
/
SlowTWsrc
< prev
Wrap
Text File
|
1998-05-13
|
4KB
|
102 lines
In -
Out SlowTW
Type Module
Ver 1.00f
Define Workspace
Name module
Default r12
`runtime ! how often it should run
`nexttime ! the time we should run again
`starttime ! the time it started waiting
`slowtask ! domain id of task to slow
End Workspace
Define Module
Name SlowTW
Author Justin Fletcher
PostFilter
Name SlowTW
Task -
Accept Null Pollword
Code slowtw
End PostFilter
PreFilter
Name SlowTW
Task -
Code slowtw_pre
End PreFilter
Workspace *`len_module
Init initcode
Commands
Name SlowTW
Min 1
Max 1
Code com_slow
End Commands
End Module
#rem off
>initcode
STMFD (sp)!,{r0-r5,link} ; Stack registers
MOV r0,#15 ; number of cs/poll
STRW r0,`runtime
LDMFD (sp)!,{r0-r5,pc} ; Return from call
>slowtw_pre
STMFD (sp)!,{r0-r1,link} ; Stack registers
LDRW r0,`nexttime ; read the next time
TEQ r0,#0 ; is it set ?
LDMNEFD (sp)!,{r0-r1,pc}^ ; if so, return
SWI "XOS_ReadMonotonicTime" ; read the time
LDRW r1,`starttime ; read the time we started this poll
SUB r1,r0,r1 ; r1 = time taken in poll
REM "%c04Penalise by %r1"
LDRW r14,`runtime ; read the runtime
ADD r0,r0,r14 ; add it on
ADD r0,r0,r1 ; add on the time it took
STRW r0,`nexttime ; store back
LDMFD (sp)!,{r0-r1,pc}^ ; Return from call
>slowtw
TEQ r0,#0 ; Wimp_Poll reason
TEQNE r0,#13 ; NULL or Pollword
MOVNES pc,link ; if not NULL, return
STMFD (sp)!,{r1-r5,link} ; Stack registers
MOV r2,#0
LDR r2,[r2,#&ff8] ; read domain id
LDRW r3,`slowtask ; read task to slow
TEQ r2,r3 ; slow ?
LDMNEFD (sp)!,{r1-r5,pc}^ ; if not, return
SWI "XOS_ReadMonotonicTime" ; read the time
MOVVS r0,#0 ; if error, clear 0
BVS $error
LDRW r2,`nexttime ; read next time
CMP r2,r0 ; compare them
STRWLS r0,`starttime ; the time it started running
MOVLS r0,#0 ; if <= make sure it runs now
STRWLS r0,`nexttime ; and zero the next time
MVNHI r0,#NOT -1 ; if > make sure it runs later
$error
LDMFD (sp)!,{r1-r5,pc}^ ; Return from call
>com_slow
STMFD (sp)!,{r0-r5,link} ; Stack registers
LDR r12,[r12] ; read our workspace
MOV r1,r0 ; r1 = value to delay by
XSWI "XOS_ReadUnsigned",10 ; read the value
BVS $error ; if error, process
STRW r2,`runtime ; store as the wait time
MOV r2,#0
LDR r2,[r2,#&ff8] ; read domain id
STRW r2,`slowtask ; read task to slow
SWI "XOS_ReadMonotonicTime" ; read the time
STRW r0,`starttime ; store as the start time
STRW r0,`nexttime ; store as the next time too
$error
XLDMFD (sp)!,{r0-r5,pc} ; Return from call
#POST
#RUN <CODE>