home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / books / 68k_book / arp_src / prg_2cc.s < prev    next >
Text File  |  1985-11-20  |  2KB  |  61 lines

  1.  ; Program Name: PRG_2CC.S
  2.  ;      Version: 1.002
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;     Assemble in Relocatable mode and save with a TOS extension.
  7.  
  8.  ; Execution Instructions:
  9.  
  10.  ;     Execute program SPEEDTST.TTP and type PRG_2CC.TOS on the input
  11.  ; parameter line.  SPEEDTST.TTP will produce a data file named PRG_2CC.DAT
  12.  ; on disk.  You will be able to compare the data for this program to that
  13.  ; produced for programs PRG_2CP.TOS and PRG_2CR.TOS.
  14.  
  15.  ; Program Function:
  16.  
  17.  ;     Statements within a nested loop structure are executed 50,000 times
  18.  ; so that the load and execution time of this program can be compared with
  19.  ; similar programs assembled in the PC-relative and Relocatable modes.
  20.     
  21. store_after_load_time:
  22.  trap       #3                  ; Returns value of system clock in D0. 
  23.  lea        after_load_time(pc), a0   
  24.  move.w     d0, (a0)
  25.  
  26.  move.w     #9, d1              ; Initialize outer loop counter.
  27. outer_loop:                     ; Loop ten times.
  28.  move.w     #49999, d0          ; Initialize inner loop counter.
  29. inner_loop:                     ; Loop 50,000 times.
  30.  move.l     #label, a0          ; Can't use (pc) here.
  31.  lea        label(pc), a0   
  32.  move.l     label(pc), a0
  33.  move.l     #label, -(sp)       ; Can't use (pc) here.
  34.  pea        label(pc)
  35.  move.l     label(pc), -(sp)
  36.  lea        $C(sp), sp          ; Reposition stack pointer to top of stack.
  37.  dbra       d0, inner_loop      ; Loop back until D0 = -1.
  38.  dbra       d1, outer_loop      ; Loop back until D1 = -1.
  39.  
  40. terminate:
  41.  move.w    after_load_time(pc), -(sp) ; Pass after load time to SPEEDTST.TTP.
  42.  move.w     #$4C, -(sp)               ; Function = p_term = GEMDOS $4C.
  43.  trap       #1        
  44.  
  45.  data
  46.  
  47.  ; NOTE: Below, the variable "label" is supposed to be a pointer to the
  48.  ;       variable "after_load_time".  If this program is assembled in
  49.  ;       Relocatable mode, the "run time" address of "after_load_time" will be
  50.  ;       stored in the 4 bytes declared at "label" when the program is loaded
  51.  ;       from disk to ram.
  52.  
  53.  ;       But, if the program is assembled in PC-relative mode, the "run time"
  54.  ;       address will not be stored there; instead, the "assembly time" address
  55.  ;       will be stored in the 4 bytes.  That is undesirable.
  56.  
  57. label:           dc.l after_load_time     ; This works for COMBO assembly.
  58.  bss
  59. after_load_time: ds.w 1
  60.  end
  61.