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

  1.  ; Program Name: DONGLE.S
  2.  ;      Version: 1.004
  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 and copy DONGLE.ACC to the
  8.  ; C partition of the hard disk.
  9.  
  10.  ; Execution Instructions:
  11.  
  12.  ;     Execute this program by selecting DONGLE from the accessory menu.
  13.  
  14. program_start:
  15.  lea       stack(pc), a7        ; A7 points to program's stack address.
  16.  
  17. install_trap_11_routine:
  18.  pea       trap_11_routine(pc)  ; Push address of custom routine.
  19.  move.w    #43, -(sp)           ; Trap 11 vector number.
  20.  move.w    #5, -(sp)            ; Function = BIOS  set_exec.
  21.  trap      #13                  ; See COMPUTE! TOS book page 180.
  22.  addq.l    #8, sp
  23.  
  24.  lea       aes_pb(pc), a3       ; aes_pb = AES parameter block.
  25.  move.l    a3, d5               ; Use D5 as variable for aes_pb address.
  26.  lea       control(pc), a4      ; A4 is pointer for array "control".
  27.  lea       int_out(pc), a5      ; A5 is pointer for array "int_out".
  28.  lea       addr_in, a3          ; A3 is pointer for array "addr_in".
  29.  move.w    #$C8, d3             ; *** AES call number in D3.
  30.  
  31. initialize_application:
  32.  move.w    #$A, (a4)            ; Function = appl_init = AES $A.
  33.  move.w    #1, 4(a4)            ; Return one int_out parameter.
  34.  move.l    d5, d1               ; A3 contains address of aes parameter block.
  35.  move.w    d3, d0               ; D3 contains AES call number.
  36.  trap      #2                   ; apid returned in int_out[0] and global[2].
  37.  
  38. menu_installation:             
  39.  move.w    #$23, (a4)           ; Function = menu_register = AES $23.
  40.  move.w    #1, 2(a4)            ; Pass one int_in parameter.         
  41.  move.w    #1, 6(a4)            ; Pass one addr_in parameter.
  42.  move.w    (a5), int_in         ; Application identification to int_in[0].
  43.  move.l    #menu_text, (a3)     ; Menu text address to addr_in[0].
  44.  move.l    d5, d1               ; Address of aes parameter block to D1.
  45.  move.w    d3, d0               ; D3 contains AES call number.
  46.  trap      #2                   ; Menu id returned in int_out[0].
  47.  move.w    (a5), d4             ; Store menu identification number in D4.
  48.  
  49.  ; MAIN ACCESSORY LOOP
  50.  
  51.  lea       message(pc), a5      ; Message received in stored at address in A5.
  52.  move.l    a5, (a3)             ; Address of message array to addr_in.
  53.  move.w    #$17, (a4)           ; Function = evnt_mesag = AES $17.
  54.  move.w    #0, 2(a4)            ; Pass no int_in parameters.
  55. wait_for_message:               ; Relinquish processor control.
  56.  move.l    d5, d1               ; Address of aes parameter block to D1.
  57.  move.w    d3, d0               ; AES call number to D0.
  58.  trap      #2                
  59.  
  60. ; Enters here only when a message is received.
  61.  
  62. message_handler:                ; Entrance point when message is received.
  63.  cmpi.w    #$28, (a5)           ; Compare AC OPEN code with message[0].
  64.  bne.s     wait_for_message     ; Execute the evnt_mesag function.
  65.  move.w    8(a5), d0            ; Fetch menu id selected.
  66.  cmp.w     d4, d0               ; Was this application selected.
  67.  bne.s     wait_for_message     ; Execute the evnt_mesag function.
  68.  
  69. invoke_software_dongle:
  70.  trap      #11
  71.  bra       wait_for_message
  72.  
  73. trap_11_routine:                ; See text in book for explaination.
  74.  move.w    SR, -(a7)
  75.  move.w    #$2700, SR
  76.  movem.l   d0-a6, -(a7)
  77.  move.l    usp, a0
  78.  move.l    a0, -(a7)
  79.  lea       $B27E, a0
  80.  jmp       (a0)
  81.  
  82.  data
  83. menu_text:  dc.b '  DONGLE  ',0
  84.  align           
  85. aes_pb:     dc.l control,global,int_in,int_out,addr_in,addr_out
  86.  bss
  87. control:          ds.w    5
  88. global:           ds.w    3
  89.                   ds.l    6
  90. int_in:           ds.w    1     ; Input parameter.
  91. int_out:          ds.w    1     ; Output parameter.
  92. addr_in:          ds.l    1     ; Input address.
  93. addr_out:         ds.l    1     ; Output address.
  94.  ;
  95.  ; OTHER VARIABLES
  96.  ;
  97. message:          ds.w    8
  98.                   ds.l   48
  99. stack:            ds.l    0
  100. program_end:      ds.l    0
  101.  end
  102.