home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / forthmac / !Forthmacs / extend / arm / runtimer next >
Encoding:
Text File  |  1996-12-10  |  1.1 KB  |  47 lines

  1. \ cpu-specific part for the runtimer
  2. only forth also definitions  decimal
  3.  
  4. 10000000 constant nsec/tick    \ 100hz tickerV
  5.  
  6. variable ticker
  7. code interrupt-code
  8.     r0    sp        push
  9.     r0    'body ticker    pcr ldr
  10.     r0    1        incr
  11.     r0    'body ticker    pcr str
  12.     r0    sp        pop
  13.     pc    lk        s mov end-code
  14.  
  15. \ install ticker in the TICKERV
  16. code install-ticker
  17.     r0    h# 1c #        mov    \ vector-id for tickerV
  18.     r1    'body interrupt-code adr
  19.     r2    0 #        mov
  20.         h# 47        swix c; install-ticker
  21.  
  22. \ remove-ticker stops ticker and removes the rma
  23. code remove-ticker
  24.     r0    h# 1c #        mov    \ id for tickerV
  25.     r1  'body interrupt-code adr
  26.     r2    0 #        mov
  27.         h# 20        swix c;    \ release tickerV
  28.  
  29. code time)    \ (r ret_to  data #time -- ) points to the following code
  30.     here /token + a,
  31.     r1 r2 ip 3    rp ia!    ldm  \ r1:#time, r2:next-ip
  32.     r0    'body ticker    pcr ldr
  33.     r0    r0    r1    sub  \ r0:used time
  34.     r3 r4    2     r2 db!    ldm  \ r3:calls r4:time
  35.     r3    1        incr
  36.     r4    r4    r0    add                              
  37.     r3 r4 2 r2 ia!        stm c;
  38.  
  39. code (time    \ (r ret_to -- ret_to  next-ip #time 'timer> )
  40.     r1    'body ticker    pcr ldr
  41.     r0    'body time)    adr
  42.     ip    2 cells        incr
  43.     r0 r1 ip 3    rp db!    stm c;
  44.  
  45.  
  46. only forth also definitions
  47.