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

  1.  ; Program Name: PRG_5AP.S
  2.  ; Version 1.003
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;    Assemble in PC-relative mode and save with a TOS extension.
  7.  
  8.  ; Execution Note:
  9.  
  10.  ;    This program invokes custom traps which must be installed by
  11.  ; TRAPS.PRG prior to its execution.
  12.  
  13.  ; Program Function:
  14.  
  15.  ;    This program illustrates the use of custom traps #3, #6 and #8.
  16.  ; If the program is executed from the desktop, trap #8 will execute the
  17.  ; wait_for_keypress algorithm, then, when a key is pressed it will execute
  18.  ; GEMDOS function 0.
  19.  
  20.  ;    If, instead, this program is executed by typing its name on
  21.  ; SPEEDTST.TTP's input parameter line, trap #8 will not execute the
  22.  ; wait_for_keypress algorithm, but it will immediately execute GEMDOS
  23.  ; function $4C.
  24.  
  25.  ;    Trap #3 returns, in D0, the value of the system clock as it is
  26.  ; immediately after this program has been loaded.  The value in D0 is not
  27.  ; corrupted before trap #6 is invoked, therefore, it is still valid when
  28.  ; the trap #6 routine begins to execute.  Trap #6 saves the "after-load"
  29.  ; value of the system clock in its own local variable, where it is available
  30.  ; for processing during the execution of trap #8.
  31.  
  32.  ;    Trap #6 also calculates the memory occupied by this program and releases
  33.  ; the memory not occupied by this program to the operating system.
  34.   
  35. fetch_load_time:              
  36.  trap       #3                  ; Returns value of system clock in D0.
  37. release_excess_memory:          ; Also stores after-load time in TRAPS bss.
  38.  lea        program_end, a0     ; Put "end of program" address in A0.
  39.  movea.l    4(a7), a1           ; Put "basepage" address in A1.
  40.  trap       #6                  ; Calculate program size and release memory.
  41.  
  42. waste_time:
  43.  move.l     #$1, d0
  44. outer_loop:
  45.  move.l     #$FDE8, d1
  46. inner_loop:
  47.  move.l     #$FDE8, d2
  48.  dbra       d1, inner_loop
  49.  dbra       d0, outer_loop
  50.  
  51.  lea        heading, a0
  52.  bsr.s      print_string
  53.  lea        string, a0
  54.  bsr.s      print_string
  55.  
  56.  trap       #8                  ; Terminate.
  57.  
  58. print_string:
  59.  pea        (a0)
  60.  move.w     #9, -(sp)
  61.  trap       #1
  62.  addq.l     #6, sp
  63.  rts
  64.  
  65.  data
  66. heading:     dc.b 'PRG_5AP.TOS Execution Results',$D,$A,$D,$A,0
  67. string:      dc.b '  When executed from the desktop, this program will print '
  68.              dc.b 'this string on the',$D,$A
  69.              dc.b '  video screen and pause for a keypress.  But, when this '
  70.              dc.b 'program is spawned by',$D,$A
  71.              dc.b '  SPEED_1, SPEED_2, SPEED_3 or SPEEDTST, the string will '
  72.              dc.b 'be stored in a file ',$D,$A
  73.              dc.b '  named PRG_5AP.DAT and the program will not pause for a '
  74.              dc.b ' keypress.',$D,$A,0
  75.  bss
  76.  align
  77. program_end: ds.l 0
  78.  end                            ; Assembler pseudo-op.
  79.  
  80.