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

  1.  ; Program Name: PRG_8CR.S
  2.  ;      Version: 1.003
  3.  
  4.  ; Assembly Instructions:
  5.  
  6.  ;      Assemble in Relocatable mode and save with a PRG extension.  From
  7.  ; the desktop, change the extension to ACC.
  8.  
  9.  ; Function:
  10.  
  11.  ;      Identical to that of PRG_8BR.S, but this program uses a group of
  12.  ; predeclared, function named arrays that are substituted for 'control' in
  13.  ; the aes_pb, as each AES function is invoked.  In addition, a path for the
  14.  ; data file is chosen via the AES file selector function.  An additional
  15.  ; array set is provided after the fsel_input function is invoked, then a
  16.  ; final set is printed when the message handler is entered the second time.
  17.  
  18.  ; Execution Instructions:
  19.  
  20.  ;      Place PRG_8CR.ACC in the root directory of your boot disk.  During the
  21.  ; next power-up cycle, the desk accessory will be installed.  From the desktop
  22.  ; select 'Accessory Arrays' two times in order to store the pertinent data in
  23.  ; the file buffer.  At the first selection, the file selector will appear so
  24.  ; that a path and filename can be chosen for the data file; the buffer contents
  25.  ; are written to the file when the accessory is chosen the second time.
  26.  
  27.  lea        stack, a7            ; This must be the first instruction.
  28.  
  29. initialize_register_variables:
  30.  move.w     #$C8, d3             ; *** D3 is variable for AES call number.
  31.  lea        buffer(pc), a5       ; A5 is pointer to buffer.
  32.  lea        aes_pb(pc), a4       ; A4 is pointer for aes pointer array.
  33.  lea        hex_table(pc), a3    ; A3 points to hexadecimal ASCII digits.
  34.  
  35.  ; For each test point, the contents of each AES array are printed.
  36.  
  37.  ;                           
  38.  ;                 TEST POINT 0: Before appl_init     
  39.  ;                           
  40.  bsr        print_arrays
  41.  
  42. initialize_application:          ; COMPUTE! AES book page 223.
  43.  
  44.  ; Application identification = apid returned in int_out[0] and global[2].
  45.  
  46.  ; Since the address of the predeclared appl_init array is already stored in
  47.  ; aes_pb, only the trap 2 invocation need be done here.
  48.  
  49.  bsr        aes                  ; Invoke trap #2 AES exception.
  50.  ;
  51.  ;          TEST POINT 1: After appl_init, before menu_register
  52.  ;
  53.  bsr        print_arrays
  54.  
  55. menu_installation:               ; COMPUTE! AES book page 248.
  56.  
  57.  ; Menu identification number returned in int_out[0].
  58.  
  59.  move.l     #menu_register, (a4) ; Store address of next 'control' array.             
  60.  lea        global(pc), a0       ; Fetch address of global array.
  61.  move.w     4(a0), int_in        ; Application identification to int_in[0].
  62.  move.l     #menu_text, addr_in  ; Menu text address to addr_in[0].
  63.  bsr        aes                 
  64.  move.w     int_out(pc), menu_id ; Store menu identification number.
  65.  
  66.  ; MAIN ACCESSORY LOOP
  67.  
  68.  ;
  69.  ;          TEST POINT 2: After menu_register, before evnt_mesag
  70.  ;
  71.  bsr        print_arrays
  72.  
  73.  
  74. wait_for_message:                ; Relinquish processor control.
  75.  move.l     #evnt_mesag, (a4)    ; Store address of next 'control' array.
  76.  move.l     #message, addr_in    ; Address of message array to addr_in.
  77.  
  78.  ; The above instruction must be executed each time evnt_mesag is invoked
  79.  ; because the fsel_input function must store addresses in addr_in also.
  80.  ; Furthermore, the evnt_mesag "control" array must be restored in aes_pb
  81.  ; because it is replaced by the fsel_input "control" array whenever that
  82.  ; function is invoked.  If these alterations did not take place, then the
  83.  ; evnt_mesag setup could be simplified as was done in PRG_8BR.S.
  84.  
  85.  bsr        aes
  86.  
  87.  ; When a message is received it is placed in array 'message'.
  88.  
  89.  ; ****************************************************************************
  90.  ; ****************************************************************************
  91.  
  92. message_handler:                 ; Entrance point when message is received.
  93.  lea        message(pc), a0      ; Fetch address of array 'message'.
  94.  cmpi.w     #$28, (a0)           ; Compare ACCESSORY OPEN code with message[0].
  95.  bne.s      wait_for_message     ; Execute the evnt