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

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